Package com.persequor.xml
Class XmlNamespaceConfiguration
java.lang.Object
com.persequor.xml.XmlNamespaceConfiguration
The XmlNamespaceConfiguration is used to map xml namespaces prefixes, in here called aliases, to full xml namespaces.
If you wish to add an alias you can call XmlNamespaceConfiguration.getInstance().register("alias", "namespace", null);
It is important that this is only done once at application startup or the like.
The default mappings are:
psqr -> urn:psqr:extension:xsd
saga -> urn:saga:extension:xsd
epcis -> urn:epcglobal:epcis:xsd:1 (unqualified)
epcismd -> urn:epcglobal:epcis-masterdata:xsd:1 (unqualified)
epcisq -> urn:epcglobal:epcis-query:xsd:1 (unqualified)
sbdh -> http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionAdd or replace qualified namespace mapping.addUnqualified
(String prefix, String namespace) Add or replace unqualified namespace mapping.static XmlNamespaceConfiguration
getNamespaceConfiguration
(Node node, String namespaceURI) Find a configuration for node and namespaceUrigetNamespaceForPrefix
(Namespace namespace) static void
reset()
This method resets xml namespace configuration to SAGA defaultsvoid
setNamespace
(Document document) Register namespaces in this configuration into this document
-
Field Details
-
EPCIS_QUERY
- See Also:
-
EPCIS_MASTER_DATA
- See Also:
-
EPCIS
- See Also:
-
STANDARD_BUSINESS_HEADER
- See Also:
-
-
Method Details
-
reset
public static void reset()This method resets xml namespace configuration to SAGA defaults -
getInstance
- Returns:
- the active xml configuration instance
-
addUnqualified
Add or replace unqualified namespace mapping. For unqualified namespaces only the top most tag in the namespace has an xml prefix, like so:<my:tag> <childTag> <grandChild>value</grandChild> </childTag> </my:tag>
- Parameters:
prefix
- prefix used for accessing this namespace in xpaths and other data queries in SAGAnamespace
- namespace value in the xml document, like urn:epcglobal:epcis:xsd:1- Returns:
- a reference to this
-
add
Add or replace qualified namespace mapping. For qualified namespaces all tags under the top most one in this namespace, should also have the alias set. Like so:<my:tag> <my:childTag> <my:grandChild>value</my:grandChild> </my:childTag> </my:tag>
- Parameters:
prefix
- prefix used for accessing this namespace in xpaths and other data queries in SAGAnamespace
- namespace value in the xml document, like urn:epcglobal:epcis:xsd:1- Returns:
- a reference to this
-
getNamespaceContext
- Returns:
- a javax namespace context configured by this class
-
setNamespace
Register namespaces in this configuration into this document- Parameters:
document
- The document to enrich
-
getNamespaceForPrefix
- Parameters:
namespace
- A namespace which may only have alias or full name set- Returns:
- A namespace with both alias and full name set, according to this configuration
-
getNamespaceConfiguration
public Optional<XmlNamespaceConfigurationElement> getNamespaceConfiguration(Node node, String namespaceURI) Find a configuration for node and namespaceUri- Parameters:
node
- The nodenamespaceURI
- The namespace uri- Returns:
- an optional configuration element
-
getElements
-