public class XmlParser extends Object
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Constructor and description |
---|
XmlParser
() Creates a non-validating and non-namespace-aware XmlParser which does not allow DOCTYPE declarations in documents. |
XmlParser
(boolean validating, boolean namespaceAware) Creates a XmlParser which does not allow DOCTYPE declarations in documents. |
XmlParser
(boolean validating, boolean namespaceAware, boolean allowDocTypeDeclaration) Creates a XmlParser . |
XmlParser
(XMLReader reader) |
XmlParser
(SAXParser parser) |
Type | Name and description |
---|---|
protected void |
addTextToNode() |
void |
characters(char[] buffer, int start, int length) |
protected Node |
createNode(Node parent, Object name, Map attributes) Creates a new node with the given parent, name, and attributes. |
void |
endDocument() |
void |
endElement(String namespaceURI, String localName, String qName) |
void |
endPrefixMapping(String prefix) |
DTDHandler |
getDTDHandler() |
Locator |
getDocumentLocator() |
protected Object |
getElementName(String namespaceURI, String localName, String qName) Return a name given the namespaceURI, localName and qName. |
EntityResolver |
getEntityResolver() |
ErrorHandler |
getErrorHandler() |
boolean |
getFeature(String uri) |
Object |
getProperty(String uri) |
protected XMLReader |
getXMLReader() |
void |
ignorableWhitespace(char[] buffer, int start, int len) |
boolean |
isKeepIgnorableWhitespace() Returns the current keep ignorable whitespace setting. |
boolean |
isNamespaceAware() Determine if namespace handling is enabled. |
boolean |
isTrimWhitespace() Returns the current trim whitespace setting. |
Node |
parse(File file) Parses the content of the given file as XML turning it into a tree of Nodes. |
Node |
parse(InputSource input) Parse the content of the specified input source into a tree of Nodes. |
Node |
parse(InputStream input) Parse the content of the specified input stream into a tree of Nodes. |
Node |
parse(Reader in) Parse the content of the specified reader into a tree of Nodes. |
Node |
parse(String uri) Parse the content of the specified URI into a tree of Nodes. |
Node |
parseText(String text) A helper method to parse the given text as XML. |
void |
processingInstruction(String target, String data) |
void |
setDTDHandler(DTDHandler dtdHandler) |
void |
setDocumentLocator(Locator locator) |
void |
setEntityResolver(EntityResolver entityResolver) |
void |
setErrorHandler(ErrorHandler errorHandler) |
void |
setFeature(String uri, boolean value) |
void |
setKeepIgnorableWhitespace(boolean keepIgnorableWhitespace) Sets the keep ignorable whitespace setting value. |
void |
setNamespaceAware(boolean namespaceAware) Enable and/or disable namespace handling. |
void |
setProperty(String uri, Object value) |
void |
setTrimWhitespace(boolean trimWhitespace) Sets the trim whitespace setting value. |
void |
skippedEntity(String name) |
void |
startDocument() |
void |
startElement(String namespaceURI, String localName, String qName, Attributes list) |
void |
startPrefixMapping(String prefix, String namespaceURI) |
Creates a non-validating and non-namespace-aware XmlParser
which does not allow DOCTYPE declarations in documents.
Creates a XmlParser
which does not allow DOCTYPE declarations in documents.
validating
- true
if the parser should validate documents as they are parsed; false otherwise.namespaceAware
- true
if the parser should provide support for XML namespaces; false
otherwise. Creates a XmlParser
.
validating
- true
if the parser should validate documents as they are parsed; false otherwise.namespaceAware
- true
if the parser should provide support for XML namespaces; false
otherwise.allowDocTypeDeclaration
- true
if the parser should provide support for DOCTYPE declarations; false
otherwise. Creates a new node with the given parent, name, and attributes. The
default implementation returns an instance of
groovy.util.Node
.
parent
- the parent node, or null if the node being created is the
root nodename
- an Object representing the name of the node (typically
an instance of QName)attributes
- a Map of attribute names to attribute valuesReturn a name given the namespaceURI, localName and qName.
namespaceURI
- the namespace URIlocalName
- the local nameqName
- the qualified nameReturns the current keep ignorable whitespace setting.
Determine if namespace handling is enabled.
Returns the current trim whitespace setting.
Parses the content of the given file as XML turning it into a tree of Nodes.
file
- the File containing the XML to be parsedParse the content of the specified input source into a tree of Nodes.
input
- the InputSource for the XML to parseParse the content of the specified input stream into a tree of Nodes.
Note that using this method will not provide the parser with any URI for which to find DTDs etc
input
- an InputStream containing the XML to be parsedParse the content of the specified reader into a tree of Nodes.
Note that using this method will not provide the parser with any URI for which to find DTDs etc
in
- a Reader to read the XML to be parsedParse the content of the specified URI into a tree of Nodes.
uri
- a String containing a uri pointing to the XML to be parsedA helper method to parse the given text as XML.
text
- the XML text to parseSets the keep ignorable whitespace setting value.
keepIgnorableWhitespace
- the desired new valueEnable and/or disable namespace handling.
namespaceAware
- the new desired valueSets the trim whitespace setting value.
trimWhitespace
- the desired setting valueCopyright © 2003-2015 The Apache Software Foundation. All rights reserved.