Class XMLUtil


  • public class XMLUtil
    extends java.lang.Object
    XML utility functions.
    Author:
    Ariel Backenroth
    • Constructor Summary

      Constructors 
      Constructor Description
      XMLUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String buildXPath​(org.w3c.dom.Node from, org.w3c.dom.Element to)
      FOR DIAGNOSTIC PURPOSES ONLY - incomplete
      Builds a path to the node relative to the to node provided.
      static org.w3c.dom.NodeList combine​(org.w3c.dom.NodeList... nls)
      Provides a NodeList of multiple nodelists
      static javax.xml.parsers.DocumentBuilder getDocumentBuilder()
      provides a document builder that is namespace aware but not validating by default
      static javax.xml.parsers.DocumentBuilder getDocumentBuilder​(boolean namespaceAware, boolean validating)  
      static org.w3c.dom.Document newDocument()
      utility function for creating a document
      static org.w3c.dom.Document parse​(java.io.File source)
      utility function for parsing xml
      static org.w3c.dom.Document parse​(java.io.InputStream source)
      utility function for parsing xml
      static org.w3c.dom.Document parse​(java.io.Reader source)
      utility function for parsing xml
      static org.w3c.dom.Document parse​(java.lang.String source)
      utility function for parsing xml
      static org.w3c.dom.Document parse​(org.alfresco.service.cmr.repository.NodeRef nodeRef, ContentService contentService)
      utility function for parsing xml
      static void print​(org.w3c.dom.Node n, java.io.File output)
      utility function for serializing a node
      static void print​(org.w3c.dom.Node n, java.io.Writer output)
      utility function for serializing a node
      static void print​(org.w3c.dom.Node n, java.io.Writer output, boolean indent)
      utility function for serializing a node
      static java.lang.String toString​(org.w3c.dom.Node n)
      utility function for serializing a node
      static java.lang.String toString​(org.w3c.dom.Node n, boolean indent)
      utility function for serializing a node
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • XMLUtil

        public XMLUtil()
    • Method Detail

      • newDocument

        public static org.w3c.dom.Document newDocument()
        utility function for creating a document
      • print

        public static void print​(org.w3c.dom.Node n,
                                 java.io.Writer output)
        utility function for serializing a node
      • print

        public static void print​(org.w3c.dom.Node n,
                                 java.io.Writer output,
                                 boolean indent)
        utility function for serializing a node
      • print

        public static void print​(org.w3c.dom.Node n,
                                 java.io.File output)
                          throws java.io.IOException
        utility function for serializing a node
        Throws:
        java.io.IOException
      • toString

        public static java.lang.String toString​(org.w3c.dom.Node n)
        utility function for serializing a node
      • toString

        public static java.lang.String toString​(org.w3c.dom.Node n,
                                                boolean indent)
        utility function for serializing a node
      • parse

        public static org.w3c.dom.Document parse​(java.lang.String source)
                                          throws org.xml.sax.SAXException,
                                                 java.io.IOException
        utility function for parsing xml
        Throws:
        org.xml.sax.SAXException
        java.io.IOException
      • parse

        public static org.w3c.dom.Document parse​(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                                                 ContentService contentService)
                                          throws org.xml.sax.SAXException,
                                                 java.io.IOException
        utility function for parsing xml
        Throws:
        org.xml.sax.SAXException
        java.io.IOException
      • parse

        public static org.w3c.dom.Document parse​(java.io.File source)
                                          throws org.xml.sax.SAXException,
                                                 java.io.IOException
        utility function for parsing xml
        Throws:
        org.xml.sax.SAXException
        java.io.IOException
      • parse

        public static org.w3c.dom.Document parse​(java.io.InputStream source)
                                          throws org.xml.sax.SAXException,
                                                 java.io.IOException
        utility function for parsing xml
        Throws:
        org.xml.sax.SAXException
        java.io.IOException
      • parse

        public static org.w3c.dom.Document parse​(java.io.Reader source)
                                          throws org.xml.sax.SAXException,
                                                 java.io.IOException
        utility function for parsing xml
        Throws:
        org.xml.sax.SAXException
        java.io.IOException
      • getDocumentBuilder

        public static javax.xml.parsers.DocumentBuilder getDocumentBuilder()
        provides a document builder that is namespace aware but not validating by default
      • buildXPath

        public static java.lang.String buildXPath​(org.w3c.dom.Node from,
                                                  org.w3c.dom.Element to)
        FOR DIAGNOSTIC PURPOSES ONLY - incomplete
        Builds a path to the node relative to the to node provided.
        Parameters:
        from - the node from which to build the xpath
        to - an ancestor of from which will be the root of the path
        Returns:
        an xpath to to rooted at from.
      • getDocumentBuilder

        public static javax.xml.parsers.DocumentBuilder getDocumentBuilder​(boolean namespaceAware,
                                                                           boolean validating)
      • combine

        public static org.w3c.dom.NodeList combine​(org.w3c.dom.NodeList... nls)
        Provides a NodeList of multiple nodelists