com.ibm.commerce.foundation.dataload.xmlhandler

Class NVPXmlHandler

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


    public class NVPXmlHandler
    extends AbstractXmlHandler
    This xml handler will handle the XML file which is in the name value format. For example, the following inventory XML file is in the name value format:

     <Inventories 
      xmlns:_cat="http://www.ibm.com/xmlns/prod/commerce/9/catalog" 
      xmlns:_inv="http://www.ibm.com/xmlns/prod/commerce/9/inventory" 
     >
    
      <_inv:Inventory ProductPartNumber="TAPL-01" >
              <_cat:Item ItemPartNumber="TAPL-0101" >
                    <Quantity>101</Quantity>
              </_cat:Item>
              <_cat:Item ItemPartNumber="TAPL-0102">
                    <Quantity>102</Quantity>
              </_cat:Item>
      </_inv:Inventory>
     </Inventories>
    
     

    It will build a map and the key is the name and the value is either a string or a list if there are multiple values for the same name.
    • Constructor Summary

      Constructors 
      Constructor and Description
      NVPXmlHandler() 
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void characters(char[] chars, int start, int length)
      Handle the characters event in the xml.
      void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
      Handle the end element event in the xml.
      void init()
      Initializes some instance variables.
      void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
      Handle the start element event in the xml.
      • Methods inherited from class org.xml.sax.helpers.DefaultHandler

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

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.xml.sax.ContentHandler

        endDocument, endPrefixMapping, ignorableWhitespace, processingInstruction, skippedEntity, startDocument, startPrefixMapping
      • Methods inherited from interface org.xml.sax.DTDHandler

        notationDecl, unparsedEntityDecl
      • Methods inherited from interface org.xml.sax.EntityResolver

        resolveEntity
      • Methods inherited from interface org.xml.sax.ErrorHandler

        warning
    • Constructor Detail

      • NVPXmlHandler

        public NVPXmlHandler()
    • Method Detail

      • characters

        public void characters(char[] chars,
                               int start,
                               int length)
                        throws org.xml.sax.SAXException
        Handle the characters event in the xml.
        Specified by:
        characters in interface org.xml.sax.ContentHandler
        Overrides:
        characters in class AbstractXmlHandler
        Parameters:
        chars - the char array
        start - the start index position in the char array
        length - the length
        Throws:
        org.xml.sax.SAXException - if there are some errors to handle it.
      • 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
        Handle the start element event in the xml.
        Specified by:
        startElement in interface org.xml.sax.ContentHandler
        Overrides:
        startElement in class AbstractXmlHandler
        Parameters:
        uri - the uri of the element
        localName - the location name of the element
        qName - the qualified name of the element
        attributes - the attributes in the element.
        Throws:
        org.xml.sax.SAXException - if there are some errors to handle it.
      • endElement

        public void endElement(java.lang.String uri,
                               java.lang.String localName,
                               java.lang.String qName)
                        throws org.xml.sax.SAXException
        Handle the end element event in the xml.
        Specified by:
        endElement in interface org.xml.sax.ContentHandler
        Overrides:
        endElement in class AbstractXmlHandler
        Parameters:
        uri - the uri of the element
        localName - the location name of the element
        qName - the qualified name of the element
        Throws:
        org.xml.sax.SAXException - if there are some errors to handle it.