Package org.apache.sis.xml
Class TransformedEvent.Start
- All Implemented Interfaces:
StartElement
,XMLEvent
,XMLStreamConstants
- Direct Known Subclasses:
TransformingWriter.Event
- Enclosing class:
- TransformedEvent<E extends XMLEvent>
Wrapper over an element emitted during the reading or writing of an XML document.
This wrapper is used for changing the namespace and sometimes the name of the element.
The attributes may also be modified.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.sis.xml.TransformedEvent
TransformedEvent.Attr, TransformedEvent.End, TransformedEvent.NS, TransformedEvent.Start, TransformedEvent.Type
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe attributes, may or may not be the same than the wrapped event.The namespaces, may or may not be the same than the wrapped event.(package private) final TransformVersion
The version to export, used for wrapping namespace context.Fields inherited from class org.apache.sis.xml.TransformedEvent
event, name
Fields inherited from interface javax.xml.stream.XMLStreamConstants
ATTRIBUTE, CDATA, CHARACTERS, COMMENT, DTD, END_DOCUMENT, END_ELEMENT, ENTITY_DECLARATION, ENTITY_REFERENCE, NAMESPACE, NOTATION_DECLARATION, PROCESSING_INSTRUCTION, SPACE, START_DOCUMENT, START_ELEMENT
-
Constructor Summary
ConstructorsConstructorDescriptionStart
(StartElement event, QName name, List<Namespace> namespaces, List<Attribute> attributes, TransformVersion version) Wraps the given event with potentially different name, namespaces and attributes. -
Method Summary
Modifier and TypeMethodDescriptionfinal StartElement
final Attribute
getAttributeByName
(QName name) Returns the attribute referred to by the given name, ornull
if none.final int
Returns a context mapping prefixes used in XML document to namespaces used in JAXB annotations.getNamespaceURI
(String prefix) Gets the URI used by JAXB annotations for the given prefix used in the XML document.final boolean
(package private) final void
write
(Appendable out) Writes the event as per the XML 1.0 without indentation or whitespace.Methods inherited from class org.apache.sis.xml.TransformedEvent
asCharacters, asEndElement, getLocation, getName, getSchemaType, isAttribute, isCharacters, isEndDocument, isEndElement, isEntityReference, isNamespace, isProcessingInstruction, isStartDocument, name, toString, writeAsEncodedUnicode
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface javax.xml.stream.events.StartElement
getName
Methods inherited from interface javax.xml.stream.events.XMLEvent
asCharacters, asEndElement, getLocation, getSchemaType, isAttribute, isCharacters, isEndDocument, isEndElement, isEntityReference, isNamespace, isProcessingInstruction, isStartDocument, writeAsEncodedUnicode
-
Field Details
-
namespaces
The namespaces, may or may not be the same than the wrapped event. -
attributes
The attributes, may or may not be the same than the wrapped event. -
version
The version to export, used for wrapping namespace context.
-
-
Constructor Details
-
Start
Start(StartElement event, QName name, List<Namespace> namespaces, List<Attribute> attributes, TransformVersion version) Wraps the given event with potentially different name, namespaces and attributes.
-
-
Method Details
-
isStartElement
public final boolean isStartElement()- Specified by:
isStartElement
in interfaceXMLEvent
- Overrides:
isStartElement
in classTransformedEvent<StartElement>
-
asStartElement
- Specified by:
asStartElement
in interfaceXMLEvent
- Overrides:
asStartElement
in classTransformedEvent<StartElement>
-
getEventType
public final int getEventType()- Specified by:
getEventType
in interfaceXMLEvent
-
getNamespaces
- Specified by:
getNamespaces
in interfaceStartElement
-
getAttributes
- Specified by:
getAttributes
in interfaceStartElement
-
getAttributeByName
Returns the attribute referred to by the given name, ornull
if none. Current implementation is okay on the assumption that there is few attributes.- Specified by:
getAttributeByName
in interfaceStartElement
-
getNamespaceURI
Gets the URI used by JAXB annotations for the given prefix used in the XML document. Returnsnull
if no unique URI can be provided for the given prefix.Example: the"gmd"
prefix from legacy ISO 19139:2007 standard can map to the"http://standards.iso.org/iso/19115/-3/mdb/1.0"
,"…/cit/1.0"
and other namespaces in ISO 19115-3:2016. Because of this ambiguity, this method returnsnull
.At unmarshalling time, events are created by an arbitrary
XMLEventReader
with namespaces used in the XML document.TransformingReader
wraps those events using this class for converting the XML namespaces to the namespaces used by JAXB annotations.At marshalling time, events are created by JAXB using namespaces used in JAXB annotations.
TransformingWriter
wraps those events for converting those namespaces to the ones used in the XML document. This is the opposite than the work performed by this default implementation and must be handled by aStart
subclass.- Specified by:
getNamespaceURI
in interfaceStartElement
-
getNamespaceContext
Returns a context mapping prefixes used in XML document to namespaces used in JAXB annotations. TheTransformingNamespaces.Inverse.getNamespaceURI(String)
method in that context shall do the same work thangetNamespaceURI(String)
in this event.- Specified by:
getNamespaceContext
in interfaceStartElement
-
write
Writes the event as per the XML 1.0 without indentation or whitespace.- Specified by:
write
in classTransformedEvent<StartElement>
- Throws:
IOException
-