Package org.eclipse.jetty.xml
Class XmlParser
- java.lang.Object
-
- org.eclipse.jetty.xml.XmlParser
-
- Direct Known Subclasses:
XmlConfiguration.ConfigurationParser
public class XmlParser extends java.lang.Object
XML Parser wrapper. This class wraps any standard JAXP1.1 parser with convieniant 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
Nested Classes Modifier and Type Class Description static class
XmlParser.Attribute
XML Attribute.private class
XmlParser.Handler
static class
XmlParser.Node
XML Node.private class
XmlParser.NoopHandler
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
_dtd
private java.util.Map<java.lang.String,org.xml.sax.ContentHandler>
_observerMap
private java.util.Stack<org.xml.sax.ContentHandler>
_observers
private javax.xml.parsers.SAXParser
_parser
private java.util.Map<java.lang.String,java.net.URL>
_redirectMap
private java.lang.String
_xpath
private java.lang.Object
_xpaths
private static Logger
LOG
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addContentHandler(java.lang.String trigger, org.xml.sax.ContentHandler observer)
Add a ContentHandler.java.lang.String
getDTD()
java.lang.String
getXpath()
boolean
isValidating()
XmlParser.Node
parse(java.io.File file)
Parse File.XmlParser.Node
parse(java.io.InputStream in)
Parse InputStream.XmlParser.Node
parse(java.lang.String url)
Parse String URL.XmlParser.Node
parse(org.xml.sax.InputSource source)
void
redirectEntity(java.lang.String name, java.net.URL entity)
protected org.xml.sax.InputSource
resolveEntity(java.lang.String pid, java.lang.String sid)
void
setValidating(boolean validating)
void
setXpath(java.lang.String xpath)
Set an XPath A very simple subset of xpath is supported to select a partial tree.
-
-
-
Field Detail
-
LOG
private static final Logger LOG
-
_redirectMap
private java.util.Map<java.lang.String,java.net.URL> _redirectMap
-
_parser
private javax.xml.parsers.SAXParser _parser
-
_observerMap
private java.util.Map<java.lang.String,org.xml.sax.ContentHandler> _observerMap
-
_observers
private java.util.Stack<org.xml.sax.ContentHandler> _observers
-
_xpath
private java.lang.String _xpath
-
_xpaths
private java.lang.Object _xpaths
-
_dtd
private java.lang.String _dtd
-
-
Method Detail
-
setValidating
public void setValidating(boolean validating)
-
isValidating
public boolean isValidating()
-
redirectEntity
public void redirectEntity(java.lang.String name, java.net.URL entity)
-
getXpath
public java.lang.String getXpath()
- Returns:
- Returns the xpath.
-
setXpath
public void setXpath(java.lang.String xpath)
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
public java.lang.String getDTD()
-
addContentHandler
public void addContentHandler(java.lang.String trigger, org.xml.sax.ContentHandler observer)
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
public XmlParser.Node parse(org.xml.sax.InputSource source) throws java.io.IOException, org.xml.sax.SAXException
- Throws:
java.io.IOException
org.xml.sax.SAXException
-
parse
public XmlParser.Node parse(java.lang.String url) throws java.io.IOException, org.xml.sax.SAXException
Parse String URL.- Parameters:
url
- the url to the xml to parse- Returns:
- the root node of the xml
- Throws:
java.io.IOException
- if unable to load the xmlorg.xml.sax.SAXException
- if unable to parse the xml
-
parse
public XmlParser.Node parse(java.io.File file) throws java.io.IOException, org.xml.sax.SAXException
Parse File.- Parameters:
file
- the file to the xml to parse- Returns:
- the root node of the xml
- Throws:
java.io.IOException
- if unable to load the xmlorg.xml.sax.SAXException
- if unable to parse the xml
-
parse
public XmlParser.Node parse(java.io.InputStream in) throws java.io.IOException, org.xml.sax.SAXException
Parse InputStream.- Parameters:
in
- the input stream of the xml to parse- Returns:
- the root node of the xml
- Throws:
java.io.IOException
- if unable to load the xmlorg.xml.sax.SAXException
- if unable to parse the xml
-
resolveEntity
protected org.xml.sax.InputSource resolveEntity(java.lang.String pid, java.lang.String sid)
-
-