Class AttributeSynchronizer

  • All Implemented Interfaces:
    org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

    class AttributeSynchronizer
    extends org.xml.sax.helpers.DefaultHandler
    Implements an XML attribute synchronizer. As DOM parsing does (usually) not preserve attribute sequences, we synchronize XML attributes if needed through an additional SAX parsing run. This is a SAX content handler maintaining an internal iterator. For each matching element, we synchronize the attributes in the respective VIL attribute fragment.
    Author:
    Holger Eichelberger
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private XmlNode advanceIter​(XmlNode current)
      Advances the iterator position.
      private XmlNode checkPositions​(XmlNode node)
      Checks whether the initial position of node is stored in positions.
      private XmlNode consumeNonXmlElements​(XmlNode node)
      Consumes all following non-XmlElements.
      void startElement​(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)  
      • Methods inherited from class org.xml.sax.helpers.DefaultHandler

        characters, endDocument, endElement, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AttributeSynchronizer

        AttributeSynchronizer​(XmlElement root)
        Creates an attribute synchronizer.
        Parameters:
        root - the root node to start from
    • Method Detail

      • startElement

        public void startElement​(java.lang.String uri,
                                 java.lang.String localName,
                                 java.lang.String qName,
                                 org.xml.sax.Attributes attributes)
                          throws org.xml.sax.SAXException
        Specified by:
        startElement in interface org.xml.sax.ContentHandler
        Overrides:
        startElement in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException
      • checkPositions

        private XmlNode checkPositions​(XmlNode node)
        Checks whether the initial position of node is stored in positions.
        Parameters:
        node - the node to check (may be null, ignored then)
        Returns:
        node
      • advanceIter

        private XmlNode advanceIter​(XmlNode current)
        Advances the iterator position. Does not change iter directly, but returns the next value of iter
        Parameters:
        current - the current node
        Returns:
        the next iterator position
      • consumeNonXmlElements

        private XmlNode consumeNonXmlElements​(XmlNode node)
        Consumes all following non-XmlElements.
        Parameters:
        node - the node to start consuming for (may be null)
        Returns:
        the next non-XmlElement, may be node, may be null
        See Also:
        advanceIter(XmlNode)