Class TransformedEvent.Start

java.lang.Object
org.apache.sis.xml.TransformedEvent<StartElement>
org.apache.sis.xml.TransformedEvent.Start
All Implemented Interfaces:
StartElement, XMLEvent, XMLStreamConstants
Direct Known Subclasses:
TransformingWriter.Event
Enclosing class:
TransformedEvent<E extends XMLEvent>

static class TransformedEvent.Start extends TransformedEvent<StartElement> implements StartElement
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.
  • Field Details

    • namespaces

      private final List<Namespace> namespaces
      The namespaces, may or may not be the same than the wrapped event.
    • attributes

      private final List<Attribute> attributes
      The attributes, may or may not be the same than the wrapped event.
    • version

      final TransformVersion version
      The version to export, used for wrapping namespace context.
  • Constructor Details

  • Method Details

    • isStartElement

      public final boolean isStartElement()
      Specified by:
      isStartElement in interface XMLEvent
      Overrides:
      isStartElement in class TransformedEvent<StartElement>
    • asStartElement

      public final StartElement asStartElement()
      Specified by:
      asStartElement in interface XMLEvent
      Overrides:
      asStartElement in class TransformedEvent<StartElement>
    • getEventType

      public final int getEventType()
      Specified by:
      getEventType in interface XMLEvent
    • getNamespaces

      public final Iterator<Namespace> getNamespaces()
      Specified by:
      getNamespaces in interface StartElement
    • getAttributes

      public final Iterator<Attribute> getAttributes()
      Specified by:
      getAttributes in interface StartElement
    • getAttributeByName

      public final Attribute getAttributeByName(QName name)
      Returns the attribute referred to by the given name, or null if none. Current implementation is okay on the assumption that there is few attributes.
      Specified by:
      getAttributeByName in interface StartElement
    • getNamespaceURI

      public String getNamespaceURI(String prefix)
      Gets the URI used by JAXB annotations for the given prefix used in the XML document. Returns null 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 returns null.

      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 a Start subclass.

      Specified by:
      getNamespaceURI in interface StartElement
    • getNamespaceContext

      public NamespaceContext getNamespaceContext()
      Returns a context mapping prefixes used in XML document to namespaces used in JAXB annotations. The TransformingNamespaces.Inverse.getNamespaceURI(String) method in that context shall do the same work than getNamespaceURI(String) in this event.
      Specified by:
      getNamespaceContext in interface StartElement
    • write

      final void write(Appendable out) throws IOException
      Writes the event as per the XML 1.0 without indentation or whitespace.
      Specified by:
      write in class TransformedEvent<StartElement>
      Throws:
      IOException