Skip navigation links
Thingworx Platform API
8.5.0
com.thingworx.common.utils

Class XMLUtilities

  • java.lang.Object
    • com.thingworx.common.utils.XMLUtilities
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static boolean ENABLE_XXE 
    • Constructor Summary

      Constructors 
      Constructor and Description
      XMLUtilities() 
    • Field Detail

      • ENABLE_XXE

        public static boolean ENABLE_XXE
    • Constructor Detail

      • XMLUtilities

        public XMLUtilities()
    • Method Detail

      • createDocumentBuilderFactory

        @ThingworxExtensionApiMethod(since={6,6})
        public static javax.xml.parsers.DocumentBuilderFactory createDocumentBuilderFactory()
                                                                                                                               throws javax.xml.parsers.ParserConfigurationException
        Throws:
        javax.xml.parsers.ParserConfigurationException - If an error occurs
      • createDocumentFromStream

        @ThingworxExtensionApiMethod(since={6,6})
        public static org.w3c.dom.Document createDocumentFromStream(java.io.InputStream is)
                                                                                                       throws java.lang.Exception
        Throws:
        java.lang.Exception - If an error occurs

        Used for importing Entity from file and attachments
      • createDocument

        @ThingworxExtensionApiMethod(since={6,6})
        public static org.w3c.dom.Document createDocument(java.lang.String contentStr)
                                                                                             throws java.lang.Exception
        Throws:
        java.lang.Exception - If an error occurs

        Currently used for service requests
      • getDocument

        @ThingworxExtensionApiMethod(since={6,6})
        public static org.w3c.dom.Document getDocument(java.io.InputStream in)
                                                                                          throws java.lang.Exception
        Throws:
        java.lang.Exception - If an error occurs

        Currently used for importing default entities for High Availability (HA) and getDocument(File).
      • getDocument

        @ThingworxExtensionApiMethod(since={6,6})
        public static org.w3c.dom.Document getDocument(java.io.Reader in)
                                                                                          throws java.lang.Exception
        Throws:
        java.lang.Exception - If an error occurs

        Currently used for converting to Primitive and storing data.
      • outputXMLDoc

        @ThingworxExtensionApiMethod(since={6,6})
        public static void outputXMLDoc(org.w3c.dom.Document doc,
                                                                                  java.io.OutputStream output)
                                                                           throws java.lang.Exception
        Throws:
        java.lang.Exception - If an error occurs

        Used for generating unformatted XML.
      • outputXMLDoc

        @ThingworxExtensionApiMethod(since={6,6})
        public static void outputXMLDoc(org.w3c.dom.Document doc,
                                                                                  java.io.Writer output)
                                                                           throws java.lang.Exception
        Throws:
        java.lang.Exception - If an error occurs

        Used for generating unformatted XML.
      • outputXMLDocFormatted

        @ThingworxExtensionApiMethod(since={8,1})
        public static void outputXMLDocFormatted(org.w3c.dom.Document doc,
                                                                                           java.io.Writer output)
                                                                                    throws java.lang.Exception
        Throws:
        java.lang.Exception - If an error occurs

        Used for generating formatted XML for Source Export operations. The XML will be indented using four spaces, line feed for new line, expand empty elements, add new lines for element attributes, format CDATA.
      • getElementValueByTagName

        @ThingworxExtensionApiMethod(since={6,6})
        public static java.lang.String getElementValueByTagName(org.w3c.dom.Element node,
                                                                                                          java.lang.String element)
      • getChildElementByTagName

        @ThingworxExtensionApiMethod(since={6,6})
        public static org.w3c.dom.Element getChildElementByTagName(org.w3c.dom.Element node,
                                                                                                             java.lang.String element)
      • getChildElementsByTagName

        @ThingworxExtensionApiMethod(since={6,6})
        public static java.util.ArrayList<org.w3c.dom.Element> getChildElementsByTagName(org.w3c.dom.Element node,
                                                                                                                                   java.lang.String element)
      • getChildElementValueByTagNameWithNull

        @ThingworxExtensionApiMethod(since={6,6})
        public static java.lang.String getChildElementValueByTagNameWithNull(org.w3c.dom.Element node,
                                                                                                                       java.lang.String element)
      • getChildElementValueByTagName

        @ThingworxExtensionApiMethod(since={6,6})
        public static java.lang.String getChildElementValueByTagName(org.w3c.dom.Element node,
                                                                                                               java.lang.String element)
      • getElementByTagName

        @ThingworxExtensionApiMethod(since={6,6})
        public static org.w3c.dom.Element getElementByTagName(org.w3c.dom.Element node,
                                                                                                        java.lang.String element)
      • getNodeValue

        @ThingworxExtensionApiMethod(since={6,6})
        public static java.lang.String getNodeValue(org.w3c.dom.Node node)


        Will return the String value of the given node. This method accepts Node's of type Node.ELEMENT_NODE, Node.ATTRIBUTE_NODE, Node.TEXT_NODE and Node.CDATA_SECTION_NODE. All other Node types will return an empty string.

        Note: As of 7.2.0, if an Node.ELEMENT_NODE node has child Node.TEXT_NODE nodes containing only whitespace characters (like newlines or tabs) the node will be treated as an empty string. For example, if Node.TEXT_NODE node only contains "\n\t\t\t", the value will be "".

        Parameters:
        node - The DOM node that you want to retrieve the text value from
        Returns:
        The value of the given DOM node