Package org.eclipse.jetty.xml
Class XmlParser
java.lang.Object
org.eclipse.jetty.xml.XmlParser
XML Parser wrapper. This class wraps any standard JAXP1.1 parser with convenient error and
entity handlers and a mini dom-like document tree.
By default, the parser is created as a validating parser only if xerces is present. This can be configured by setting the "org.eclipse.jetty.xml.XmlParser.Validating" system property.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
XML Attribute.static class
XML Node. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addCatalog
(URI catalogXml) Load the specified URI as a catalog for entity mapping purposes.void
addCatalog
(URI catalogXml, Class<?> baseClassLocation) Load the specified URI as a catalog for entity mapping purposes.void
addContentHandler
(String trigger, ContentHandler observer) Add a ContentHandler.protected void
getDTD()
getXpath()
boolean
protected SAXParser
protected SAXParserFactory
Parse File.parse
(InputStream in) Parse InputStream.Parse String URL.parse
(InputSource source) protected static void
setFeature
(SAXParserFactory factory, String name, boolean value) protected static void
setFeature
(XMLReader xmlReader, String name, boolean value) void
setValidating
(boolean validating) void
Set an XPath A very simple subset of xpath is supported to select a partial tree.
-
Constructor Details
-
XmlParser
public XmlParser()Construct XmlParser -
XmlParser
public XmlParser(boolean validating) Construct XmlParser- Parameters:
validating
- true to enable validation, false to disable- See Also:
-
-
Method Details
-
newSAXParserFactory
-
newSAXParser
-
configure
-
setFeature
-
setFeature
-
setValidating
public void setValidating(boolean validating) -
isValidating
public boolean isValidating() -
getSAXParser
-
addCatalog
Load the specified URI as a catalog for entity mapping purposes.This is a temporary Catalog implementation, and should be removed once all of our usages of
servlet-api-<ver>.jar
have their owncatalog.xml
files.- Parameters:
catalogXml
- the URI pointing to the XML catalogbaseClassLocation
- the base class to use for finding relative resources defined in the Catalog XML. This is resolved to the Class location with package location and is used as the XML Catalog Base URI.- Throws:
IOException
-
addCatalog
Load the specified URI as a catalog for entity mapping purposes.- Parameters:
catalogXml
- the uri to the catalog
-
getXpath
- Returns:
- Returns the xpath.
-
setXpath
Set an XPath A very simple subset of xpath is supported to select a partial tree. Currently only path like "/node1/nodeA | /node1/nodeB" are supported.- Parameters:
xpath
- The xpath to set.
-
getDTD
-
addContentHandler
Add a ContentHandler. Add an additional _content handler that is triggered on a tag name. SAX events are passed to the ContentHandler provided from a matching start element to the corresponding end element. Only a single _content handler can be registered against each tag.- Parameters:
trigger
- Tag local or q name.observer
- SAX ContentHandler
-
parse
- Throws:
IOException
SAXException
-
parse
Parse String URL.- Parameters:
url
- the url to the xml to parse- Returns:
- the root node of the xml
- Throws:
IOException
- if unable to load the xmlSAXException
- if unable to parse the xml
-
parse
Parse File.- Parameters:
file
- the file to the xml to parse- Returns:
- the root node of the xml
- Throws:
IOException
- if unable to load the xmlSAXException
- if unable to parse the xml
-
parse
Parse InputStream.- Parameters:
in
- the input stream of the xml to parse- Returns:
- the root node of the xml
- Throws:
IOException
- if unable to load the xmlSAXException
- if unable to parse the xml
-