Package org.apache.commons.jxpath.xml
Class DocumentContainer
java.lang.Object
org.apache.commons.jxpath.xml.XMLParser2
org.apache.commons.jxpath.xml.DocumentContainer
- All Implemented Interfaces:
Serializable
,Container
,XMLParser
An XML document container reads and parses XML only when it is
accessed. JXPath traverses Containers transparently -
you use the same paths to access objects in containers as you
do to access those objects directly. You can create
XMLDocumentContainers for various XML documents that may or
may not be accessed by XPaths. If they are, they will be automatically
read, parsed and traversed. If they are not - they won't be
read at all.
- Version:
- $Revision: 668329 $ $Date: 2008-06-16 16:59:48 -0500 (Mon, 16 Jun 2008) $
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDocumentContainer
(URL xmlURL) Use this constructor if the desired model is DOM.DocumentContainer
(URL xmlURL, String model) Construct a new DocumentContainer. -
Method Summary
Modifier and TypeMethodDescriptionprivate static XMLParser
Maps a model type to a parser.getValue()
Reads XML, caches it internally and returns the Document.parseXML
(InputStream stream) Parses XML using the parser for the specified model.static void
registerXMLParser
(String model, String parserClassName) Add a class of a custom XML parser.static void
registerXMLParser
(String model, XMLParser parser) Add an XML parser.void
Throws an UnsupportedOperationException.Methods inherited from class org.apache.commons.jxpath.xml.XMLParser2
isCoalescing, isExpandEntityReferences, isIgnoringComments, isIgnoringElementContentWhitespace, isNamespaceAware, isValidating, setCoalescing, setExpandEntityReferences, setIgnoringComments, setIgnoringElementContentWhitespace, setNamespaceAware, setValidating
-
Field Details
-
MODEL_DOM
DOM constant- See Also:
-
MODEL_JDOM
JDOM constant- See Also:
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
parserClasses
-
parsers
-
document
-
xmlURL
-
model
-
-
Constructor Details
-
DocumentContainer
Use this constructor if the desired model is DOM.- Parameters:
xmlURL
- is a URL for an XML file. Use getClass().getResource(resourceName) to load XML from a resource file.
-
DocumentContainer
Construct a new DocumentContainer.- Parameters:
xmlURL
- is a URL for an XML file. Use getClass().getResource (resourceName) to load XML from a resource file.model
- is one of the MODEL_* constants defined in this class. It determines which parser should be used to load the XML.
-
-
Method Details
-
registerXMLParser
Add an XML parser. Parsers for the models "DOM" and "JDOM" are pre-registered.- Parameters:
model
- model nameparser
- parser
-
registerXMLParser
Add a class of a custom XML parser. Parsers for the models "DOM" and "JDOM" are pre-registered.- Parameters:
model
- model nameparserClassName
- parser classname
-
getValue
Reads XML, caches it internally and returns the Document. -
parseXML
Parses XML using the parser for the specified model.- Specified by:
parseXML
in interfaceXMLParser
- Specified by:
parseXML
in classXMLParser2
- Parameters:
stream
- InputStream- Returns:
- Object
-
setValue
Throws an UnsupportedOperationException. -
getParser
Maps a model type to a parser.- Parameters:
model
- input model type- Returns:
- XMLParser
-