Package com.thingworx.common.utils
Class XMLUtilities
java.lang.Object
com.thingworx.common.utils.XMLUtilities
@ThingworxExtensionApiClass(since={6,6},
canInstantiate=true)
public final class XMLUtilities
extends Object
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Document
static Document
createDocument
(String contentStr) static DocumentBuilderFactory
static Document
static Element
getChildElementByTagName
(Element node, String element) getChildElements
(Element node) getChildElementsByTagName
(Element node, String element) static String
getChildElementValueByTagName
(Element node, String element) static String
getChildElementValueByTagNameWithNull
(Element node, String element) static Document
static Document
getDocument
(Reader in) static Element
getElementByTagName
(Element node, String element) static String
getElementValueByTagName
(Element node, String element) static String
getNodeValue
(Node node)
Will return the String value of the given node.static String
getTextContent
(Node node) static String
outputXMLDoc
(Document doc)
Used for XML POST and PUTstatic void
outputXMLDoc
(Document doc, OutputStream output) static void
outputXMLDoc
(Document doc, Writer output) static String
static void
outputXMLDocFormatted
(Document doc, OutputStream output) static void
outputXMLDocFormatted
(Document doc, OutputStream output, Integer indent) Deprecated.indent is no longer supportedstatic void
outputXMLDocFormatted
(Document doc, Writer output) static String
outputXMLDocFormatted
(Document doc, Integer indent) Deprecated.indent is no longer supportedstatic void
outputXMLDocFormatted
(Document outdoc, String filepath) static void
setNodeValue
(Node nodeTarget, String value)
-
Field Details
-
ENABLE_XXE
public static boolean ENABLE_XXE
-
-
Constructor Details
-
XMLUtilities
public XMLUtilities()
-
-
Method Details
-
createDocumentBuilderFactory
@ThingworxExtensionApiMethod(since={6,6}) public static DocumentBuilderFactory createDocumentBuilderFactory() throws ParserConfigurationException- Throws:
ParserConfigurationException
- If an error occurs
-
createDocumentFromStream
@ThingworxExtensionApiMethod(since={6,6}) public static Document createDocumentFromStream(InputStream is) throws Exception - Throws:
Exception
- If an error occurs
Used for importing Entity from file and attachments
-
createDocument
-
createDocument
@ThingworxExtensionApiMethod(since={6,6}) public static Document createDocument(String contentStr) throws Exception - Throws:
Exception
- If an error occurs
Currently used for service requests
-
getDocument
@ThingworxExtensionApiMethod(since={6,6}) public static Document getDocument(InputStream in) throws Exception - Throws:
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 Document getDocument(Reader in) throws Exception - Throws:
Exception
- If an error occurs
Currently used for converting to Primitive and storing data.
-
outputXMLDoc
@ThingworxExtensionApiMethod(since={6,6}) public static void outputXMLDoc(Document doc, OutputStream output) throws Exception - Throws:
Exception
- If an error occurs
Used for generating unformatted XML.
-
outputXMLDoc
@ThingworxExtensionApiMethod(since={6,6}) public static void outputXMLDoc(Document doc, Writer output) throws Exception - Throws:
Exception
- If an error occurs
Used for generating unformatted XML.
-
outputXMLDoc
Used for XML POST and PUT -
outputXMLDocFormatted
@ThingworxExtensionApiMethod(since={8,1}) public static void outputXMLDocFormatted(Document doc, Writer output) throws Exception - Throws:
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.
-
outputXMLDocFormatted
@ThingworxExtensionApiMethod(since={6,6}, deprecatedSince={8,1}) @Deprecated public static void outputXMLDocFormatted(Document doc, OutputStream output, Integer indent) throws Exception Deprecated.indent is no longer supported- Throws:
Exception
- If an error occurs- See Also:
-
outputXMLDocFormatted
@ThingworxExtensionApiMethod(since={8,1}) public static void outputXMLDocFormatted(Document doc, OutputStream output) throws Exception - Throws:
Exception
- If an error occurs
Used for exporting source as zip- See Also:
-
outputXMLDocFormatted
@ThingworxExtensionApiMethod(since={6,6}, deprecatedSince={8,1}) public static String outputXMLDocFormatted(Document doc, Integer indent) Deprecated.indent is no longer supported- See Also:
-
outputXMLDocFormatted
- See Also:
-
outputXMLDocFormatted
@ThingworxExtensionApiMethod(since={8,1}) public static void outputXMLDocFormatted(Document outdoc, String filepath) throws Exception - Throws:
Exception
- If an error occurs
Used for exporting source control entities- See Also:
-
getTextContent
-
getElementValueByTagName
@ThingworxExtensionApiMethod(since={6,6}) public static String getElementValueByTagName(Element node, String element) -
getChildElementByTagName
@ThingworxExtensionApiMethod(since={6,6}) public static Element getChildElementByTagName(Element node, String element) -
getChildElements
@ThingworxExtensionApiMethod(since={6,6}) public static ArrayList<Element> getChildElements(Element node) -
getChildElementsByTagName
-
getChildElementValueByTagNameWithNull
@ThingworxExtensionApiMethod(since={6,6}) public static String getChildElementValueByTagNameWithNull(Element node, String element) -
getChildElementValueByTagName
@ThingworxExtensionApiMethod(since={6,6}) public static String getChildElementValueByTagName(Element node, String element) -
getElementByTagName
@ThingworxExtensionApiMethod(since={6,6}) public static Element getElementByTagName(Element node, String element) -
getNodeValue
Will return the String value of the given node. This method accepts Node's of typeNode.ELEMENT_NODE
,Node.ATTRIBUTE_NODE
,Node.TEXT_NODE
andNode.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 childNode.TEXT_NODE
nodes containing only whitespace characters (like newlines or tabs) the node will be treated as an empty string. For example, ifNode.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
-
setNodeValue
@ThingworxExtensionApiMethod(since={6,6}) public static void setNodeValue(Node nodeTarget, String value)
-