Package org.eclipse.persistence.internal.oxm

Examples of org.eclipse.persistence.internal.oxm.NamespaceResolver


            }
            if(next != null){
                NamespaceInfo info = getNamespaceInfoForURI(namespaceUri);

          if(info != null) {
            NamespaceResolver resolver = info.getNamespaceResolverForDescriptor();
           
            String prefix = null;
            if(namespaceUri != Constants.EMPTY_STRING){
                prefix = resolver.resolveNamespaceURI(namespaceUri);
                if(prefix == null){
                  prefix = getPrefixForNamespace(namespaceUri, resolver);             
                }
            }
            desc.setNamespaceResolver(resolver);
            if(nextElement.isXmlRootElement()) {
                desc.setDefaultRootElement(getQualifiedString(prefix, next.getLocalPart()));
            } else {
                desc.setDefaultRootElement("");
                desc.addRootElement(getQualifiedString(prefix, next.getLocalPart()));
            }
                } else {
                    if(namespaceUri.equals("")) {
                        desc.setDefaultRootElement(next.getLocalPart());
                    } else {
                        NamespaceResolver resolver = new org.eclipse.persistence.oxm.NamespaceResolver();
                        String prefix = getPrefixForNamespace(namespaceUri, resolver);

                        desc.setNamespaceResolver(resolver);
                          if(nextElement.isXmlRootElement()) {
                              desc.setDefaultRootElement(getQualifiedString(prefix, next.getLocalPart()));
View Full Code Here


            }
            if(next != null){
                NamespaceInfo info = getNamespaceInfoForURI(namespaceUri);

          if(info != null) {
            NamespaceResolver resolver = info.getNamespaceResolverForDescriptor();
           
            String prefix = null;
            if(namespaceUri != Constants.EMPTY_STRING){
                prefix = resolver.resolveNamespaceURI(namespaceUri);
                if(prefix == null){
                  prefix = getPrefixForNamespace(namespaceUri, resolver);             
                }
            }
            desc.setNamespaceResolver(resolver);
            if(nextElement.isXmlRootElement()) {
                desc.setDefaultRootElement(getQualifiedString(prefix, next.getLocalPart()));
            } else {
                desc.setDefaultRootElement("");
                desc.addRootElement(getQualifiedString(prefix, next.getLocalPart()));
                desc.setResultAlwaysXMLRoot(true);
            }
                } else {
                    if(namespaceUri.equals("")) {
                        desc.setDefaultRootElement(next.getLocalPart());
                    } else {
                        NamespaceResolver resolver = new org.eclipse.persistence.oxm.NamespaceResolver();
                        String prefix = getPrefixForNamespace(namespaceUri, resolver);

                        desc.setNamespaceResolver(resolver);
                          if(nextElement.isXmlRootElement()) {
                              desc.setDefaultRootElement(getQualifiedString(prefix, next.getLocalPart()));
View Full Code Here

        } else {
            namespaceUri = newUri;
            lname = newName;           
            qname = newName;
            if(namespaceUri != null && isNamespaceAware()){
                NamespaceResolver tmpNR = new NamespaceResolver();
                tmpNR.setDOM(elem);

                 String prefix = tmpNR.resolveNamespaceURI(namespaceUri);
                 if(prefix == null || prefix.length() == 0){
                     String defaultNamespace = elem.getAttributeNS(javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI, javax.xml.XMLConstants.XMLNS_ATTRIBUTE);
           
                     if(defaultNamespace == null){
                         prefix = tmpNR.generatePrefix();   
                         contentHandler.startPrefixMapping(prefix, namespaceUri);
                     }else if(defaultNamespace != namespaceUri){
                         prefix = tmpNR.generatePrefix();
                         contentHandler.startPrefixMapping(prefix, namespaceUri);
                     }else{
                         prefix = Constants.EMPTY_STRING;
                     }     
                 }                
View Full Code Here

    public Object get(CoreField key) {
        Field xmlField = this.convertToXMLField(key);
        XPathFragment lastFragment = xmlField.getLastXPathFragment();       
        String namespaceURI = lastFragment.getNamespaceURI();
        if(namespaceURI == null){
          NamespaceResolver namespaceResolver = xmlField.getNamespaceResolver();
            namespaceURI = Constants.EMPTY_STRING;
            if (null != namespaceResolver && !(lastFragment.isAttribute() && lastFragment.getPrefix() == null)) {
                namespaceURI = namespaceResolver.resolveNamespacePrefix(lastFragment.getPrefix());
                if (null == namespaceURI) {
                    namespaceURI = Constants.EMPTY_STRING;
                }
            }
        }
View Full Code Here

    protected static final String TRUE = "true";
   
   
    public MarshalRecord() {
        super(null);
        namespaceResolver = new NamespaceResolver();
    }
View Full Code Here

                //need to add a default namespace declaration.               
                defaultNamespaceDeclaration(namespaceURI);
            }
            return qName.getLocalPart();
        } else {
            NamespaceResolver namespaceResolver = getNamespaceResolver();
            if(namespaceResolver == null){
                throw XMLMarshalException.namespaceResolverNotSpecified(namespaceURI);
            }
            if(namespaceURI.equals(namespaceResolver.getDefaultNamespaceURI())) {
                return qName.getLocalPart();
            }
            String prefix = namespaceResolver.resolveNamespaceURI(namespaceURI);
            if(null == prefix) {
              if(namespaceURI.equals(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI)){
                 prefix = namespaceResolver.generatePrefix(Constants.SCHEMA_PREFIX)
              }else{
                   prefix = namespaceResolver.generatePrefix();
              }
                namespaceDeclaration(prefix, namespaceURI);
            }
            if(Constants.EMPTY_STRING.equals(prefix)){
              return qName.getLocalPart();
View Full Code Here

    protected String processNamespaceResolverForXSIPrefix(NamespaceResolver namespaceResolver) {
        String xsiPrefix;
        if (null == namespaceResolver) {
            // add new xsi entry into the properties map
            xsiPrefix = Constants.SCHEMA_INSTANCE_PREFIX;
            namespaceResolver = new NamespaceResolver();
            namespaceResolver.put(xsiPrefix, javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);           
            namespaceDeclaration(xsiPrefix, javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
        } else {
            // find an existing xsi entry in the map
            xsiPrefix = namespaceResolver.resolveNamespaceURI(javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
View Full Code Here

    public XMLTransformationRecord(String rootName, UnmarshalRecord owner) {
        super(rootName);
        owningRecord = owner;
        session = (AbstractSession) owner.getSession();
        resolver = new NamespaceResolver();
        initializeNamespaceMaps();
    }
View Full Code Here

    public Object get(CoreField key) {
        Field xmlField = this.convertToXMLField(key);
        XPathFragment lastFragment = xmlField.getLastXPathFragment();       
        String namespaceURI = lastFragment.getNamespaceURI();
        if(namespaceURI == null){
          NamespaceResolver namespaceResolver = xmlField.getNamespaceResolver();
            namespaceURI = Constants.EMPTY_STRING;
            if (null != namespaceResolver && !(lastFragment.isAttribute() && lastFragment.getPrefix() == null)) {
                namespaceURI = namespaceResolver.resolveNamespacePrefix(lastFragment.getPrefix());
                if (null == namespaceURI) {
                    namespaceURI = Constants.EMPTY_STRING;
                }
            }
        }
View Full Code Here

        Descriptor schemaDescriptor = (Descriptor)proj.getDescriptor(Schema.class);
        int schemaCount = 0;
        for (Entry<String, Schema> entry : schemas.entrySet()) {
            Schema schema = entry.getValue();
            try {
                NamespaceResolver schemaNamespaces = schema.getNamespaceResolver();
                schemaNamespaces.put(Constants.SCHEMA_PREFIX, "http://www.w3.org/2001/XMLSchema");
                schemaDescriptor.setNamespaceResolver(schemaNamespaces);
                javax.xml.transform.Result target = outputResolver.createOutput(schema.getTargetNamespace(), schema.getName());
                marshaller.marshal(schema, target);
                schemaCount++;
            } catch (IOException ex) {
View Full Code Here

TOP

Related Classes of org.eclipse.persistence.internal.oxm.NamespaceResolver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.