org.apache.ws.commons.schema.docpath
Class DomBuilderFromSax

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.apache.ws.commons.schema.docpath.DomBuilderFromSax
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public final class DomBuilderFromSax
extends DefaultHandler

Builds an XML Document from an XML Schema during a SAX walk.


Constructor Summary
DomBuilderFromSax(XmlSchemaCollection xmlSchemaCollection)
          Creates a new DocumentBuilderFromSax.
 
Method Summary
 void characters(char[] ch, int start, int length)
          Adds content to the current element.
 void endDocument()
           
 void endElement(String uri, String localName, String qName)
          Closes the current element in the generated XML document.
 void endPrefixMapping(String prefix)
           
 Document getDocument()
          Retrieves the document constructed from the SAX walk.
 Map<String,String> getNamespaceToLocationMapping()
          Retrieves the XML Schema namespace -> location mapping set by the last call to setNamespaceToLocationMapping(Map).
 Map<QName,XmlSchemaStateMachineNode> getStateMachinesByQName()
          Retrieves the QName -> XmlSchemaStateMachineNode mapping defined by the call to setStateMachinesByQName(Map).
 void setNamespaceToLocationMapping(Map<String,String> nsToLocMapping)
          Sets the XML Schema namespace -> location mapping to use when defining the schemaLocation attribute in the generated XML document.
 void setStateMachinesByQName(Map<QName,XmlSchemaStateMachineNode> statesByQName)
          Sets the mapping of QNames to XmlSchemaStateMachineNodes.
 void startDocument()
           
 void startElement(String uri, String localName, String qName, Attributes atts)
          Starts a new element in the generated XML document.
 void startPrefixMapping(String prefix, String uri)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DomBuilderFromSax

public DomBuilderFromSax(XmlSchemaCollection xmlSchemaCollection)
                  throws ParserConfigurationException
Creates a new DocumentBuilderFromSax.

Throws:
ParserConfigurationException - If unable to create a DocumentBuilder.
Method Detail

startDocument

public void startDocument()
                   throws SAXException
Specified by:
startDocument in interface ContentHandler
Overrides:
startDocument in class DefaultHandler
Throws:
SAXException
See Also:
DefaultHandler.startDocument()

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
                        throws SAXException
Specified by:
startPrefixMapping in interface ContentHandler
Overrides:
startPrefixMapping in class DefaultHandler
Throws:
SAXException
See Also:
DefaultHandler.startPrefixMapping(String, String)

endPrefixMapping

public void endPrefixMapping(String prefix)
                      throws SAXException
Specified by:
endPrefixMapping in interface ContentHandler
Overrides:
endPrefixMapping in class DefaultHandler
Throws:
SAXException
See Also:
DefaultHandler.endPrefixMapping(String)

startElement

public void startElement(String uri,
                         String localName,
                         String qName,
                         Attributes atts)
                  throws SAXException
Starts a new element in the generated XML document. If the previous element was not closed, adds this element as a child to that element.

Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class DefaultHandler
Throws:
SAXException
See Also:
DefaultHandler.startElement(String, String, String, Attributes)

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
Adds content to the current element.

Specified by:
characters in interface ContentHandler
Overrides:
characters in class DefaultHandler
Throws:
SAXException
See Also:
DefaultHandler.characters(char[], int, int)

endElement

public void endElement(String uri,
                       String localName,
                       String qName)
                throws SAXException
Closes the current element in the generated XML document.

Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class DefaultHandler
Throws:
SAXException
See Also:
DefaultHandler.endElement(String, String, String)

endDocument

public void endDocument()
                 throws SAXException
Specified by:
endDocument in interface ContentHandler
Overrides:
endDocument in class DefaultHandler
Throws:
SAXException
See Also:
DefaultHandler.endDocument()

getDocument

public Document getDocument()
Retrieves the document constructed from the SAX walk.


getNamespaceToLocationMapping

public Map<String,String> getNamespaceToLocationMapping()
Retrieves the XML Schema namespace -> location mapping set by the last call to setNamespaceToLocationMapping(Map).


setNamespaceToLocationMapping

public void setNamespaceToLocationMapping(Map<String,String> nsToLocMapping)
Sets the XML Schema namespace -> location mapping to use when defining the schemaLocation attribute in the generated XML document.

Parameters:
nsToLocMapping - The namespace -> location mapping.

getStateMachinesByQName

public Map<QName,XmlSchemaStateMachineNode> getStateMachinesByQName()
Retrieves the QName -> XmlSchemaStateMachineNode mapping defined by the call to setStateMachinesByQName(Map).


setStateMachinesByQName

public void setStateMachinesByQName(Map<QName,XmlSchemaStateMachineNode> statesByQName)
Sets the mapping of QNames to XmlSchemaStateMachineNodes. This is used to disambiguate:

Parameters:
statesByQName - The state-machine-node-by-QName mapping.


Copyright © 2004-2015 The Apache Software Foundation. All Rights Reserved.