Class DOMForest
A forest is a transitive reflexive closure of referenced documents.
IOW, if a document is in a forest, all the documents referenced from
it is in a forest, too. To support this semantics, DOMForest
uses InternalizationLogic
to find referenced documents.
Some documents are marked as "root"s, meaning those documents were put into a forest explicitly, not because it is referenced from another document. (However, a root document can be referenced from other documents, too.)
- Author:
- Kohsuke Kawaguchi ([email protected])
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal LocatorTable
Stores location information for all the trees in this forest.protected final InternalizationLogic
Schema language dependent part of the processing.Stores all the outer-most<jaxb:bindings>
customizations. -
Constructor Summary
ConstructorsConstructorDescriptionDOMForest
(InternalizationLogic logic, Options opt) DOMForest
(SAXParserFactory parserFactory, DocumentBuilder documentBuilder, InternalizationLogic logic) -
Method Summary
Modifier and TypeMethodDescriptionboolean
checkSchemaCorrectness
(ErrorReceiver errorHandler) Checks the correctness of the XML Schema documents and return true if it's OK.CreatesXMLParser
for XSOM which reads documents from this DOMForest rather than doing a fresh parse.createSAXSource
(String systemId) Creates aSAXSource
that, when parsed, reads from this (instead of parsing the original source identified by the system ID.)void
dump
(OutputStream out) Dumps the contents of the forest to the specified stream.Gets the DOM tree associated with the specified system ID, or null if none is found.Picks one document at random and returns it.getParserHandler
(String systemId, boolean root) Returns aContentHandler
to feed SAX events into.Returns a read-only set of root document system IDs.getSystemId
(Document dom) Gets the system ID from which the given DOM is parsed.Document[]
Gets all the parsed documents.String[]
Gets all the system IDs of the documents.Parses an XML at the given location ( and XMLs referenced by it) into DOM trees and stores them to this forest.parse
(String systemId, XMLStreamReader parser, boolean root) parse
(String systemId, InputSource inputSource, boolean root) Parses the given document and add it to the DOM forest.parse
(InputSource source, boolean root) void
setEntityResolver
(EntityResolver entityResolver) void
setErrorHandler
(ErrorReceiver errorHandler) transform
(boolean enableSCD) Performs internalization.void
Performs the schema correctness check by using JAXP 1.3.
-
Field Details
-
locatorTable
Stores location information for all the trees in this forest. -
outerMostBindings
Stores all the outer-most<jaxb:bindings>
customizations. -
logic
Schema language dependent part of the processing.
-
-
Constructor Details
-
DOMForest
public DOMForest(SAXParserFactory parserFactory, DocumentBuilder documentBuilder, InternalizationLogic logic) -
DOMForest
-
-
Method Details
-
get
Gets the DOM tree associated with the specified system ID, or null if none is found. -
getRootDocuments
Returns a read-only set of root document system IDs. -
getOneDocument
Picks one document at random and returns it. -
checkSchemaCorrectness
Checks the correctness of the XML Schema documents and return true if it's OK.This method performs a weaker version of the tests where error messages are provided without line number information. So whenever possible use
SchemaConstraintChecker
.- See Also:
-
getSystemId
Gets the system ID from which the given DOM is parsed.Poor-man's base URI.
-
parse
- Throws:
SAXException
-
parse
Parses an XML at the given location ( and XMLs referenced by it) into DOM trees and stores them to this forest.- Returns:
- the parsed DOM document object.
- Throws:
SAXException
IOException
-
getParserHandler
Returns aContentHandler
to feed SAX events into.The client of this class can feed SAX events into the handler to parse a document into this DOM forest.
-
parse
Parses the given document and add it to the DOM forest.- Returns:
- null if there was a parse error. otherwise non-null.
- Throws:
SAXException
-
parse
public Document parse(String systemId, XMLStreamReader parser, boolean root) throws XMLStreamException - Throws:
XMLStreamException
-
transform
Performs internalization. This method should be called only once, only after all the schemas are parsed.- Returns:
- the returned bindings need to be applied after schema components are built.
-
weakSchemaCorrectnessCheck
Performs the schema correctness check by using JAXP 1.3.This is "weak", because
SchemaFactory.newSchema(Source[])
doesn't handle inclusions very correctly (it ends up parsing it from its original source, not in this tree), and because it doesn't handle two documents for the same namespace very well.We should eventually fix JAXP (and Xerces), but meanwhile this weaker and potentially wrong correctness check is still better than nothing when used inside JAX-WS (JAXB CLI and Ant does a better job of checking this.)
To receive errors, use
SchemaFactory.setErrorHandler(ErrorHandler)
. -
createSAXSource
Creates aSAXSource
that, when parsed, reads from this (instead of parsing the original source identified by the system ID.) -
createParser
CreatesXMLParser
for XSOM which reads documents from this DOMForest rather than doing a fresh parse. The net effect is that XSOM will read transformed XML Schemas instead of the original documents. -
getEntityResolver
-
setEntityResolver
-
getErrorHandler
-
setErrorHandler
-
listDocuments
Gets all the parsed documents. -
listSystemIDs
Gets all the system IDs of the documents. -
dump
Dumps the contents of the forest to the specified stream. This is a debug method. As such, error handling is sloppy.- Throws:
IOException
-