Package org.apache.sis.xml
Class TransformingNamespaces
java.lang.Object
org.apache.sis.xml.TransformingNamespaces
- All Implemented Interfaces:
NamespaceContext
- Direct Known Subclasses:
TransformingNamespaces.Inverse
In the associations between prefixes and namespaces, substitutes the namespaces used in JAXB annotations
by the namespaces used in the XML document at marshalling time. This class is used internally by
TransformingWriter
and TransformedEvent
only.- Since:
- 0.4
- Version:
- 1.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
Substitutes the XML namespaces used in XML documents by namespaces used in JAXB annotations.private static final class
Iterator for the prefixes to be returned bygetPrefixes(String)
. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) final NamespaceContext
The context to wrap, given byTransformingReader
orTransformingWriter
.(package private) final TransformVersion
The URI replacements to apply when exporting from the JAXB annotations to the XML documents. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
TransformingNamespaces
(NamespaceContext context, TransformVersion version) Creates a new namespaces transformer for the given target version. -
Method Summary
Modifier and TypeMethodDescription(package private) static NamespaceContext
asJAXB
(NamespaceContext context, TransformVersion version) Given a context for namespaces used in XML document, returns a context working with the namespaces used in our JAXB annotations.(package private) static NamespaceContext
asXML
(NamespaceContext context, TransformVersion version) Given the context for namespaces used in our JAXB annotations, returns a context working with namespaces used in XML document.getNamespaceURI
(String prefix) Returns the namespace for the given prefix.Returns an arbitrary prefix for the given namespace.getPrefixes
(String namespaceURI) Returns all prefixes for the given namespace.
-
Field Details
-
context
The context to wrap, given byTransformingReader
orTransformingWriter
.- See Also:
-
version
The URI replacements to apply when exporting from the JAXB annotations to the XML documents.
-
-
Constructor Details
-
TransformingNamespaces
Creates a new namespaces transformer for the given target version.
-
-
Method Details
-
asXML
Given the context for namespaces used in our JAXB annotations, returns a context working with namespaces used in XML document. The returned context converts namespace arguments from XML to JAXB namespaces, and converts returned namespaces from JAXB to XML.Example: for a"http://www.isotc211.org/2005/gmd"
namespace (legacy ISO 19139:2007) given in argument togetPrefixes(String)
, the context converts that namespace to all possible ISO 19115-3 namespaces (there is many) and returns the associated prefixes:"mdb"
,"cit"
, etc. Conversely given a"mdb"
,"cit"
, etc., prefix,getNamespaceURI(String)
method returns the above-cited legacy GMD namespace. -
asJAXB
Given a context for namespaces used in XML document, returns a context working with the namespaces used in our JAXB annotations. The returned context converts namespace arguments from JAXB to XML namespaces before to delegate to the wrapped context, and converts returned namespaces from XML to JAXB.This can be used when a
XMLEventWriter
has been created for writing a legacy XML document and we want to expose aTransformingWriter
view to give to JAXB. -
getNamespaceURI
Returns the namespace for the given prefix. The same URI may be returned for many prefixes. For example, when exporting from ISO 19115-3:2016 to legacy ISO 19139:2007, the"mdb"
,"cit"
and many other prefixes are all mapped to"http://www.isotc211.org/2005/gmd"
. This is legal accordingNamespaceContext
javadoc.- Specified by:
getNamespaceURI
in interfaceNamespaceContext
-
getPrefix
Returns an arbitrary prefix for the given namespace. More than one prefix may be bounded to a namespace, in which case this method returns an arbitrary prefix (which may differ between different JVM executions).- Specified by:
getPrefix
in interfaceNamespaceContext
-
getPrefixes
Returns all prefixes for the given namespace. For example, given the"http://www.isotc211.org/2005/gmd"
namespace from legacy ISO 19139:2007, this method returns"mdb"
,"cit"
and all other prefixes from the new ISO 19115-3:2016 specification which are used in replacement of the legacy"gmd"
prefix.- Specified by:
getPrefixes
in interfaceNamespaceContext
-