/** * Return a QName representing the value of the xsi:type attribute or null if one is not present */ private QName getTypeAttributeQName(Attributes atts) { int attributeSize = atts.getLength(); for (int i = 0; i < attributeSize; i++) { String stringValue = atts.getValue(i); String uri = atts.getURI(i); String attrName = atts.getLocalName(i); if (javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(uri) && XMLConstants.SCHEMA_TYPE_ATTRIBUTE.equals(attrName)) { int colonIndex = stringValue.indexOf(':'); String localPrefix = stringValue.substring(0, colonIndex); String localURI = unmarshalNamespaceResolver.getNamespaceURI(localPrefix); if (localURI != null) { String localName = stringValue.substring(colonIndex + 1, stringValue.length()); QName theQName = new QName(localURI, localName); currentSchemaType = theQName; return theQName; } else { throw XMLMarshalException.namespaceNotFound(localPrefix); } } } return null; }
/** * Return a QName representing the value of the xsi:type attribute or null if one is not present */ private QName getTypeAttributeQName(Attributes atts) { int attributeSize = atts.getLength(); for (int i = 0; i < attributeSize; i++) { String stringValue = atts.getValue(i); String uri = atts.getURI(i); String attrName = atts.getLocalName(i); if (javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(uri) && XMLConstants.SCHEMA_TYPE_ATTRIBUTE.equals(attrName)) { int colonIndex = stringValue.indexOf(':'); String localPrefix = stringValue.substring(0, colonIndex); String localURI = unmarshalNamespaceResolver.getNamespaceURI(localPrefix); if (localURI != null) { String localName = stringValue.substring(colonIndex + 1, stringValue.length()); QName theQName = new QName(localURI, localName); currentSchemaType = theQName; return theQName; } else { throw XMLMarshalException.namespaceNotFound(localPrefix); } } } return null; }
/** * INTERNAL: * Return the namespace uri for the prefix of the given local name */ private String resolveNamespace(NamespaceResolver namespaceResolver, String localName) { int colonIndex = localName.indexOf(':'); if (colonIndex < 0) { // handle target/default namespace if (namespaceResolver != null) { return namespaceResolver.resolveNamespacePrefix(Constants.EMPTY_STRING); } return null; } else { if (namespaceResolver == null) { //throw an exception if the name has a : in it but the namespaceresolver is null throw XMLMarshalException.namespaceResolverNotSpecified(localName); } String prefix = localName.substring(0, colonIndex); String uri = namespaceResolver.resolveNamespacePrefix(prefix); if (uri == null) { //throw an exception if the prefix is not found in the namespaceresolver throw XMLMarshalException.namespaceNotFound(prefix); } return uri; } }
/** * INTERNAL: * Return the namespace uri for the prefix of the given local name */ private String resolveNamespace(NamespaceResolver namespaceResolver, String localName) { int colonIndex = localName.indexOf(':'); if (colonIndex < 0) { // handle target/default namespace if (namespaceResolver != null) { return namespaceResolver.resolveNamespacePrefix(XMLConstants.EMPTY_STRING); } return null; } else { if (namespaceResolver == null) { //throw an exception if the name has a : in it but the namespaceresolver is null throw XMLMarshalException.namespaceResolverNotSpecified(localName); } String prefix = localName.substring(0, colonIndex); String uri = namespaceResolver.resolveNamespacePrefix(prefix); if (uri == null) { //throw an exception if the prefix is not found in the namespaceresolver throw XMLMarshalException.namespaceNotFound(prefix); } return uri; } }
/** * INTERNAL: * Return the namespace uri for the prefix of the given local name */ private String resolveNamespace(NamespaceResolver namespaceResolver, String localName) { if(localName == null) { return null; } int colonIndex = localName.indexOf(XMLConstants.COLON); if (colonIndex < 0) { // handle target/default namespace if (namespaceResolver != null) { return namespaceResolver.getDefaultNamespaceURI(); } return null; } else { if (namespaceResolver == null) { //throw an exception if the name has a : in it but the namespaceresolver is null throw XMLMarshalException.namespaceResolverNotSpecified(localName); } String prefix = localName.substring(0, colonIndex); String uri = namespaceResolver.resolveNamespacePrefix(prefix); if (uri == null) { //throw an exception if the prefix is not found in the namespaceresolver throw XMLMarshalException.namespaceNotFound(prefix); } return uri; } }
/** * INTERNAL: * Return the namespace uri for the prefix of the given local name */ private String resolveNamespace(NamespaceResolver namespaceResolver, String localName) { int colonIndex = localName.indexOf(':'); if (colonIndex < 0) { // handle target/default namespace if (namespaceResolver != null) { return namespaceResolver.resolveNamespacePrefix(Constants.EMPTY_STRING); } return null; } else { if (namespaceResolver == null) { //throw an exception if the name has a : in it but the namespaceresolver is null throw XMLMarshalException.namespaceResolverNotSpecified(localName); } String prefix = localName.substring(0, colonIndex); String uri = namespaceResolver.resolveNamespacePrefix(prefix); if (uri == null) { //throw an exception if the prefix is not found in the namespaceresolver throw XMLMarshalException.namespaceNotFound(prefix); } return uri; } }
/** * INTERNAL: * Return the namespace uri for the prefix of the given local name */ private String resolveNamespace(NamespaceResolver namespaceResolver, String localName) { if(localName == null) { return null; } int colonIndex = localName.indexOf(XMLConstants.COLON); if (colonIndex < 0) { // handle target/default namespace if (namespaceResolver != null) { return namespaceResolver.getDefaultNamespaceURI(); } return null; } else { if (namespaceResolver == null) { //throw an exception if the name has a : in it but the namespaceresolver is null throw XMLMarshalException.namespaceResolverNotSpecified(localName); } String prefix = localName.substring(0, colonIndex); String uri = namespaceResolver.resolveNamespacePrefix(prefix); if (uri == null) { //throw an exception if the prefix is not found in the namespaceresolver throw XMLMarshalException.namespaceNotFound(prefix); } return uri; } }
/** * INTERNAL: * Return the namespace uri for the prefix of the given local name */ private String resolveNamespace(NamespaceResolver namespaceResolver, String localName) { if(localName == null) { return null; } int colonIndex = localName.indexOf(XMLConstants.COLON); if (colonIndex < 0) { // handle target/default namespace if (namespaceResolver != null) { return namespaceResolver.getDefaultNamespaceURI(); } return null; } else { if (namespaceResolver == null) { //throw an exception if the name has a : in it but the namespaceresolver is null throw XMLMarshalException.namespaceResolverNotSpecified(localName); } String prefix = localName.substring(0, colonIndex); String uri = namespaceResolver.resolveNamespacePrefix(prefix); if (uri == null) { //throw an exception if the prefix is not found in the namespaceresolver throw XMLMarshalException.namespaceNotFound(prefix); } return uri; } }
private void initializeXPathFragment(XPathFragment xPathFragment) { String localName = xPathFragment.getLocalName(); if(localName !=null && !localName.equals(XMLConstants.EMPTY_STRING)){ if(null == xPathFragment.getNamespaceURI()) { if(xPathFragment.hasNamespace()) { if(null == namespaceResolver) { throw XMLMarshalException.namespaceNotFound(xPathFragment.getShortName()); } else { String uri = namespaceResolver.resolveNamespacePrefix(xPathFragment.getPrefix()); if(null == uri && null != xPathFragment.getPrefix()) { throw XMLMarshalException.namespaceNotFound(xPathFragment.getShortName()); } xPathFragment.setNamespaceURI(uri); } } else if(!xPathFragment.isAttribute() && null != namespaceResolver) { xPathFragment.setNamespaceURI(namespaceResolver.getDefaultNamespaceURI()); } } } XPathFragment nextXPathFragment = xPathFragment.getNextFragment(); if(null != nextXPathFragment) { initializeXPathFragment(nextXPathFragment); } }
private void initializeXPathFragment(XPathFragment xPathFragment) { XPathPredicate predicate = xPathFragment.getPredicate(); if(null != predicate) { initializeXPathFragment(predicate.getXPathFragment()); } String localName = xPathFragment.getLocalName(); if(localName !=null && !localName.equals(XMLConstants.EMPTY_STRING)){ if(null == xPathFragment.getNamespaceURI()) { if(xPathFragment.hasNamespace()) { if(null == namespaceResolver) { throw XMLMarshalException.namespaceNotFound(xPathFragment.getShortName()); } else { String uri = namespaceResolver.resolveNamespacePrefix(xPathFragment.getPrefix()); if(null == uri && null != xPathFragment.getPrefix()) { throw XMLMarshalException.namespaceNotFound(xPathFragment.getShortName()); } xPathFragment.setNamespaceURI(uri); } } else if(!xPathFragment.isAttribute() && null != namespaceResolver) { xPathFragment.setNamespaceURI(namespaceResolver.getDefaultNamespaceURI()); } } } XPathFragment nextXPathFragment = xPathFragment.getNextFragment(); if(null != nextXPathFragment) { initializeXPathFragment(nextXPathFragment); } }
private void initializeXPathFragment(XPathFragment xPathFragment) { XPathPredicate predicate = xPathFragment.getPredicate(); if(null != predicate) { initializeXPathFragment(predicate.getXPathFragment()); } String localName = xPathFragment.getLocalName(); if(localName !=null && !localName.equals(XMLConstants.EMPTY_STRING)){ if(null == xPathFragment.getNamespaceURI()) { if(xPathFragment.hasNamespace()) { if(null == namespaceResolver) { throw XMLMarshalException.namespaceNotFound(xPathFragment.getShortName()); } else { String uri = namespaceResolver.resolveNamespacePrefix(xPathFragment.getPrefix()); if(null == uri && null != xPathFragment.getPrefix()) { throw XMLMarshalException.namespaceNotFound(xPathFragment.getShortName()); } xPathFragment.setNamespaceURI(uri); } } else if(!xPathFragment.isAttribute() && null != namespaceResolver) { xPathFragment.setNamespaceURI(namespaceResolver.getDefaultNamespaceURI()); } } } XPathFragment nextXPathFragment = xPathFragment.getNextFragment(); if(null != nextXPathFragment) { initializeXPathFragment(nextXPathFragment); } }