Package groovy.xml

Class DOMBuilder

    • Constructor Detail

      • DOMBuilder

        public DOMBuilder​(org.w3c.dom.Document document)
      • DOMBuilder

        public DOMBuilder​(javax.xml.parsers.DocumentBuilder documentBuilder)
    • Method Detail

      • newInstance

        public static DOMBuilder newInstance()
                                      throws javax.xml.parsers.ParserConfigurationException
        Throws:
        javax.xml.parsers.ParserConfigurationException
      • newInstance

        public static DOMBuilder newInstance​(boolean validating,
                                             boolean namespaceAware)
                                      throws javax.xml.parsers.ParserConfigurationException
        Throws:
        javax.xml.parsers.ParserConfigurationException
      • parse

        public static org.w3c.dom.Document parse​(java.io.Reader reader)
                                          throws org.xml.sax.SAXException,
                                                 java.io.IOException,
                                                 javax.xml.parsers.ParserConfigurationException
        Creates a DocumentBuilder and uses it to parse the XML text read from the given reader. A non-validating, namespace aware parser is used.
        Parameters:
        reader - the reader to read the XML text from
        Returns:
        the root node of the parsed tree of Nodes
        Throws:
        org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
        java.io.IOException - An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
        javax.xml.parsers.ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the configuration requested.
        See Also:
        parse(Reader, boolean, boolean)
      • parse

        public static org.w3c.dom.Document parse​(java.io.Reader reader,
                                                 boolean validating,
                                                 boolean namespaceAware)
                                          throws org.xml.sax.SAXException,
                                                 java.io.IOException,
                                                 javax.xml.parsers.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.
        Parameters:
        reader - the reader to read the XML text from
        validating - whether to validate the XML
        namespaceAware - whether the parser should be namespace aware
        Returns:
        the root node of the parsed tree of Nodes
        Throws:
        org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
        java.io.IOException - An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
        javax.xml.parsers.ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the configuration requested.
      • parseText

        public org.w3c.dom.Document parseText​(java.lang.String text)
                                       throws org.xml.sax.SAXException,
                                              java.io.IOException,
                                              javax.xml.parsers.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:
        org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
        java.io.IOException - An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
        javax.xml.parsers.ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the configuration requested.
        See Also:
        parse(Reader)
      • setParent

        protected void setParent​(java.lang.Object parent,
                                 java.lang.Object child)
        Specified by:
        setParent in class BuilderSupport
      • createNode

        protected java.lang.Object createNode​(java.lang.Object name)
        Specified by:
        createNode in class BuilderSupport
      • createDocument

        protected org.w3c.dom.Document createDocument()
      • createNode

        protected java.lang.Object createNode​(java.lang.Object name,
                                              java.lang.Object value)
        Specified by:
        createNode in class BuilderSupport
      • createNode

        protected java.lang.Object createNode​(java.lang.Object name,
                                              java.util.Map attributes,
                                              java.lang.Object value)
        Specified by:
        createNode in class BuilderSupport
      • createNode

        protected java.lang.Object createNode​(java.lang.Object name,
                                              java.util.Map attributes)
        Specified by:
        createNode in class BuilderSupport
      • appendNamespaceAttributes

        protected void appendNamespaceAttributes​(org.w3c.dom.Element element,
                                                 java.util.Map<java.lang.Object,​java.lang.Object> attributes)