Parses the input stream into a yaidom Document.
Parses the input stream into a yaidom Document. Closes the input stream afterwards.
Parses the content of the given File into a eu.cdevreeze.yaidom.simple.Document.
Parses the content of the given File into a eu.cdevreeze.yaidom.simple.Document.
Parses the content of the given URI into a eu.cdevreeze.yaidom.simple.Document.
Parses the content of the given URI into a eu.cdevreeze.yaidom.simple.Document.
StAX-based
Documentparser.Typical non-trivial creation is as follows, assuming a class
MyXmlResolver, which extendsXMLResolver, and a classMyXmlReporter, which extendsXMLReporter:A custom
XMLResolvercould be used to retrieve DTDs locally, or even to suppress DTD resolution. The latter can be coded as follows (compare with http://stuartsierra.com/2008/05/08/stop-your-java-sax-parser-from-downloading-dtds), risking some loss of information:A trivial
XMLReportercould look like this:If more flexibility is needed in configuring the
DocumentParserthan offered by this class, consider writing a wrapperDocumentParserwhich wraps aDocumentParserUsingStax, but adapts theparsemethod. This would make it possible to adapt the conversion from StAX events to yaidomDocument, for example.A
DocumentParserUsingStaxinstance can be re-used multiple times, from the same thread. If theXMLInputFactoryis thread-safe, it can even be re-used from multiple threads. Typically aXMLInputFactorycannot be trusted to be thread-safe, however. In a web application, one (safe) way to deal with that is to use oneXMLInputFactoryinstance per request.