Package groovy.xml
Class DOMBuilder
java.lang.Object
groovy.lang.GroovyObjectSupport
groovy.util.BuilderSupport
groovy.xml.DOMBuilder
- All Implemented Interfaces:
GroovyObject
A helper class for creating a W3C DOM tree
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidappendNamespaceAttributes(Element element, Map<Object, Object> attributes) protected Documentprotected ObjectcreateNode(Object name) protected ObjectcreateNode(Object name, Object value) protected ObjectcreateNode(Object name, Map attributes) protected ObjectcreateNode(Object name, Map attributes, Object value) static DOMBuilderstatic DOMBuildernewInstance(boolean validating, boolean namespaceAware) static DocumentCreates a DocumentBuilder and uses it to parse the XML text read from the given reader.static DocumentCreates a DocumentBuilder and uses it to parse the XML text read from the given reader, allowing parser validation and namespace awareness to be controlled.static DocumentCreates a DocumentBuilder and uses it to parse the XML text read from the given reader, allowing parser validation, namespace awareness and permission of DOCTYPE declarations to be controlled.A helper method to parse the given text as XML.protected voidMethods inherited from class groovy.util.BuilderSupport
doInvokeMethod, getCurrent, getName, invokeMethod, invokeMethod, nodeCompleted, postNodeCompletion, setClosureDelegate, setCurrentMethods inherited from class groovy.lang.GroovyObjectSupport
getMetaClass, setMetaClassMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface groovy.lang.GroovyObject
getProperty, setProperty
-
Constructor Details
-
DOMBuilder
-
DOMBuilder
-
-
Method Details
-
newInstance
- Throws:
ParserConfigurationException
-
newInstance
public static DOMBuilder newInstance(boolean validating, boolean namespaceAware) throws ParserConfigurationException - Throws:
ParserConfigurationException
-
parse
public static Document parse(Reader reader) throws SAXException, IOException, ParserConfigurationException Creates a DocumentBuilder and uses it to parse the XML text read from the given reader. A non-validating, namespace aware parser which does not allow DOCTYPE declarations is used.- Parameters:
reader- the reader to read the XML text from- Returns:
- the root node of the parsed tree of Nodes
- Throws:
SAXException- Any SAX exception, possibly wrapping another exception.IOException- An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.ParserConfigurationException- if a DocumentBuilder cannot be created which satisfies the configuration requested.- See Also:
-
parse
public static Document parse(Reader reader, boolean validating, boolean namespaceAware) throws SAXException, IOException, ParserConfigurationException Creates a DocumentBuilder and uses it to parse the XML text read from the given reader, allowing parser validation and namespace awareness to be controlled. Documents are not allowed to contain DOCYTYPE declarations.- Parameters:
reader- the reader to read the XML text fromvalidating- whether to validate the XMLnamespaceAware- whether the parser should be namespace aware- Returns:
- the root node of the parsed tree of Nodes
- Throws:
SAXException- Any SAX exception, possibly wrapping another exception.IOException- An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.ParserConfigurationException- if a DocumentBuilder cannot be created which satisfies the configuration requested.
-
parse
public static Document parse(Reader reader, boolean validating, boolean namespaceAware, boolean allowDocTypeDeclaration) throws SAXException, IOException, ParserConfigurationException Creates a DocumentBuilder and uses it to parse the XML text read from the given reader, allowing parser validation, namespace awareness and permission of DOCTYPE declarations to be controlled.- Parameters:
reader- the reader to read the XML text fromvalidating- whether to validate the XMLnamespaceAware- whether the parser should be namespace awareallowDocTypeDeclaration- whether the parser should allow DOCTYPE declarations- Returns:
- the root node of the parsed tree of Nodes
- Throws:
SAXException- Any SAX exception, possibly wrapping another exception.IOException- An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.ParserConfigurationException- if a DocumentBuilder cannot be created which satisfies the configuration requested.
-
parseText
public Document parseText(String text) throws SAXException, IOException, ParserConfigurationException A helper method to parse the given text as XML.- Parameters:
text- the XML text to parse- Returns:
- the root node of the parsed tree of Nodes
- Throws:
SAXException- Any SAX exception, possibly wrapping another exception.IOException- An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.ParserConfigurationException- if a DocumentBuilder cannot be created which satisfies the configuration requested.- See Also:
-
setParent
- Specified by:
setParentin classBuilderSupport
-
createNode
- Specified by:
createNodein classBuilderSupport
-
createDocument
-
createNode
- Specified by:
createNodein classBuilderSupport
-
createNode
- Specified by:
createNodein classBuilderSupport
-
createNode
- Specified by:
createNodein classBuilderSupport
-
appendNamespaceAttributes
-