Class DomBuilderFromSax
java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.apache.ws.commons.schema.docpath.DomBuilderFromSax
- All Implemented Interfaces:
ContentHandler,DTDHandler,EntityResolver,ErrorHandler
Builds an XML
Document from an XML Schema during a SAX
walk.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringBuilderprivate final DocumentBuilderprivate Documentprivate Map<QName, XmlSchemaStateMachineNode> private XmlSchemaNamespaceContextprivate final XmlSchemaCollectionprivate static final Stringprivate static final Stringprivate static final String -
Constructor Summary
ConstructorsConstructorDescriptionDomBuilderFromSax(XmlSchemaCollection xmlSchemaCollection) Creates a newDocumentBuilderFromSax. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddContentToCurrentElement(boolean isEnd) private voidaddNamespaceLocationMappings(Element rootElement) voidcharacters(char[] ch, int start, int length) Adds content to the current element.voidvoidendElement(String uri, String localName, String qName) Closes the current element in the generated XML document.voidendPrefixMapping(String prefix) Retrieves the document constructed from the SAX walk.Retrieves the XML Schema namespace -> location mapping set by the last call tosetNamespaceToLocationMapping(Map).Retrieves theQName->XmlSchemaStateMachineNodemapping defined by the call tosetStateMachinesByQName(Map).voidsetNamespaceToLocationMapping(Map<String, String> nsToLocMapping) Sets the XML Schema namespace -> location mapping to use when defining the schemaLocation attribute in the generated XML document.voidsetStateMachinesByQName(Map<QName, XmlSchemaStateMachineNode> statesByQName) Sets the mapping ofQNames toXmlSchemaStateMachineNodes.voidvoidstartElement(String uri, String localName, String qName, Attributes atts) Starts a new element in the generated XML document.voidstartPrefixMapping(String prefix, String uri) Methods inherited from class org.xml.sax.helpers.DefaultHandler
error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, unparsedEntityDecl, warning
-
Field Details
-
XSI_NS
- See Also:
-
XSI_SCHEMALOC
- See Also:
-
XSI_NIL
- See Also:
-
document
-
-
namespaceToLocationMapping
-
newPrefixes
-
nsContext
-
elementsByQName
-
elementStack
-
docBuilder
-
schemas
-
globalNamespaces
-
-
Constructor Details
-
DomBuilderFromSax
public DomBuilderFromSax(XmlSchemaCollection xmlSchemaCollection) throws ParserConfigurationException Creates a newDocumentBuilderFromSax.- Throws:
ParserConfigurationException- If unable to create aDocumentBuilder.
-
-
Method Details
-
startDocument
- Specified by:
startDocumentin interfaceContentHandler- Overrides:
startDocumentin classDefaultHandler- Throws:
SAXException- See Also:
-
startPrefixMapping
- Specified by:
startPrefixMappingin interfaceContentHandler- Overrides:
startPrefixMappingin classDefaultHandler- Throws:
SAXException- See Also:
-
endPrefixMapping
- Specified by:
endPrefixMappingin interfaceContentHandler- Overrides:
endPrefixMappingin classDefaultHandler- Throws:
SAXException- See Also:
-
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:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler- Throws:
SAXException- See Also:
-
characters
Adds content to the current element.- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classDefaultHandler- Throws:
SAXException- See Also:
-
endElement
Closes the current element in the generated XML document.- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classDefaultHandler- Throws:
SAXException- See Also:
-
endDocument
- Specified by:
endDocumentin interfaceContentHandler- Overrides:
endDocumentin classDefaultHandler- Throws:
SAXException- See Also:
-
addContentToCurrentElement
private void addContentToCurrentElement(boolean isEnd) -
getDocument
Retrieves the document constructed from the SAX walk. -
getNamespaceToLocationMapping
Retrieves the XML Schema namespace -> location mapping set by the last call tosetNamespaceToLocationMapping(Map). -
setNamespaceToLocationMapping
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
Retrieves theQName->XmlSchemaStateMachineNodemapping defined by the call tosetStateMachinesByQName(Map). -
setStateMachinesByQName
Sets the mapping ofQNames toXmlSchemaStateMachineNodes. This is used to disambiguate:- Whether empty content indicates nil
- If an element's attribute requires a namespace
- Parameters:
statesByQName- The state-machine-node-by-QName mapping.
-
addNamespaceLocationMappings
-