public final class DOMForest extends Object
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.)
Modifier and Type | Class and Description |
---|---|
static interface |
DOMForest.Handler |
Modifier and Type | Field and Description |
---|---|
LocatorTable |
locatorTable
Stores location information for all the trees in this forest.
|
protected InternalizationLogic |
logic
Schema language dependent part of the processing.
|
Set<Element> |
outerMostBindings
Stores all the outer-most <jaxb:bindings> customizations.
|
Constructor and Description |
---|
DOMForest(InternalizationLogic logic,
Options opt) |
DOMForest(SAXParserFactory parserFactory,
DocumentBuilder documentBuilder,
InternalizationLogic logic) |
Modifier and Type | Method and Description |
---|---|
boolean |
checkSchemaCorrectness(ErrorReceiver errorHandler)
Checks the correctness of the XML Schema documents and return true
if it's OK.
|
com.sun.xml.xsom.parser.XMLParser |
createParser()
Creates
XMLParser for XSOM which reads documents from
this DOMForest rather than doing a fresh parse. |
SAXSource |
createSAXSource(String systemId)
|
void |
dump(OutputStream out)
Dumps the contents of the forest to the specified stream.
|
Document |
get(String systemId)
Gets the DOM tree associated with the specified system ID,
or null if none is found.
|
EntityResolver |
getEntityResolver() |
ErrorReceiver |
getErrorHandler() |
Document |
getOneDocument()
Picks one document at random and returns it.
|
DOMForest.Handler |
getParserHandler(String systemId,
boolean root)
Returns a
ContentHandler to feed SAX events into. |
Set<String> |
getRootDocuments()
Returns a read-only set of root document system IDs.
|
String |
getSystemId(Document dom)
Gets the system ID from which the given DOM is parsed.
|
Document[] |
listDocuments()
Gets all the parsed documents.
|
String[] |
listSystemIDs()
Gets all the system IDs of the documents.
|
Document |
parse(InputSource source,
boolean root) |
Document |
parse(String systemId,
boolean root)
Parses an XML at the given location (
and XMLs referenced by it) into DOM trees
and stores them to this forest.
|
Document |
parse(String systemId,
InputSource inputSource,
boolean root)
Parses the given document and add it to the DOM forest.
|
Document |
parse(String systemId,
XMLStreamReader parser,
boolean root) |
void |
setEntityResolver(EntityResolver entityResolver) |
void |
setErrorHandler(ErrorReceiver errorHandler) |
SCDBasedBindingSet |
transform(boolean enableSCD)
Performs internalization.
|
void |
weakSchemaCorrectnessCheck(SchemaFactory sf)
Performs the schema correctness check by using JAXP 1.3.
|
public final LocatorTable locatorTable
public final Set<Element> outerMostBindings
protected final InternalizationLogic logic
public DOMForest(SAXParserFactory parserFactory, DocumentBuilder documentBuilder, InternalizationLogic logic)
public DOMForest(InternalizationLogic logic, Options opt)
public Document get(String systemId)
public Set<String> getRootDocuments()
public Document getOneDocument()
public boolean checkSchemaCorrectness(ErrorReceiver errorHandler)
This method performs a weaker version of the tests where error messages
are provided without line number information. So whenever possible
use SchemaConstraintChecker
.
SchemaConstraintChecker
public String getSystemId(Document dom)
Poor-man's base URI.
public Document parse(InputSource source, boolean root) throws SAXException
SAXException
public Document parse(String systemId, boolean root) throws SAXException, IOException
SAXException
IOException
public DOMForest.Handler getParserHandler(String systemId, boolean root)
ContentHandler
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.
public Document parse(String systemId, InputSource inputSource, boolean root) throws SAXException
SAXException
public Document parse(String systemId, XMLStreamReader parser, boolean root) throws XMLStreamException
XMLStreamException
public SCDBasedBindingSet transform(boolean enableSCD)
public void weakSchemaCorrectnessCheck(SchemaFactory sf)
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)
.
public com.sun.xml.xsom.parser.XMLParser createParser()
XMLParser
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.public EntityResolver getEntityResolver()
public void setEntityResolver(EntityResolver entityResolver)
public ErrorReceiver getErrorHandler()
public void setErrorHandler(ErrorReceiver errorHandler)
public Document[] listDocuments()
public String[] listSystemIDs()
public void dump(OutputStream out) throws IOException
IOException
Copyright © 2017 JBoss by Red Hat. All rights reserved.