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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Documentstatic DocumentcreateDocument(String contentStr) Currently used for service requestsstatic DocumentBuilderFactorystatic DocumentUsed for importing Entity from file and attachmentsstatic ElementgetChildElementByTagName(Element node, String element) getChildElements(Element node) getChildElementsByTagName(Element node, String element) static StringgetChildElementValueByTagName(Element node, String element) static StringgetChildElementValueByTagNameWithNull(Element node, String element) static DocumentCurrently used for importing default entities for High Availability (HA) and getDocument(File).static DocumentgetDocument(Reader in) Currently used for converting to Primitive and storing data.static ElementgetElementByTagName(Element node, String element) static StringgetElementValueByTagName(Element node, String element) static StringgetNodeValue(Node node) Will return the String value of the given node.static StringgetTextContent(Node node) static StringoutputXMLDoc(Document doc) Used for XML POST and PUTstatic voidoutputXMLDoc(Document doc, OutputStream output) Used for generating unformatted XML.static voidoutputXMLDoc(Document doc, Writer output) Used for generating unformatted XML.static Stringstatic voidoutputXMLDocFormatted(Document doc, OutputStream output) Used for exporting source as zipstatic voidoutputXMLDocFormatted(Document doc, OutputStream output, Integer indent) Deprecated.indent is no longer supportedstatic voidoutputXMLDocFormatted(Document doc, Writer output) Used for generating formatted XML for Source Export operations.static StringoutputXMLDocFormatted(Document doc, Integer indent) Deprecated.indent is no longer supportedstatic voidoutputXMLDocFormatted(Document outdoc, String filepath) Used for exporting source control entitiesstatic voidsetNodeValue(Node nodeTarget, String value)
-
Field Details
-
ENABLE_XXE
public static boolean ENABLE_XXE
-
-
Constructor Details
-
XMLUtilities
public XMLUtilities()Initializes this instace with default values.
-
-
Method Details
-
createDocumentBuilderFactory
@ThingworxExtensionApiMethod(since={6,6}) public static DocumentBuilderFactory createDocumentBuilderFactory() throws ParserConfigurationException- Throws:
ParserConfigurationException
-
createDocumentFromStream
@ThingworxExtensionApiMethod(since={6,6}) public static Document createDocumentFromStream(InputStream is) throws Exception Used for importing Entity from file and attachments- Throws:
Exception
-
createDocument
-
createDocument
@ThingworxExtensionApiMethod(since={6,6}) public static Document createDocument(String contentStr) throws Exception Currently used for service requests- Throws:
Exception
-
getDocument
@ThingworxExtensionApiMethod(since={6,6}) public static Document getDocument(InputStream in) throws Exception Currently used for importing default entities for High Availability (HA) and getDocument(File).- Throws:
Exception
-
getDocument
@ThingworxExtensionApiMethod(since={6,6}) public static Document getDocument(Reader in) throws Exception Currently used for converting to Primitive and storing data.- Throws:
Exception
-
outputXMLDoc
@ThingworxExtensionApiMethod(since={6,6}) public static void outputXMLDoc(Document doc, OutputStream output) throws Exception Used for generating unformatted XML.- Throws:
Exception
-
outputXMLDoc
@ThingworxExtensionApiMethod(since={6,6}) public static void outputXMLDoc(Document doc, Writer output) throws Exception Used for generating unformatted XML.- Throws:
Exception
-
outputXMLDoc
Used for XML POST and PUT -
outputXMLDocFormatted
@ThingworxExtensionApiMethod(since={8,1}) public static void outputXMLDocFormatted(Document doc, Writer output) throws Exception 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.- Throws:
Exception
-
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- See Also:
-
outputXMLDocFormatted
@ThingworxExtensionApiMethod(since={8,1}) public static void outputXMLDocFormatted(Document doc, OutputStream output) throws Exception Used for exporting source as zip- Throws:
Exception- See Also:
-
outputXMLDocFormatted
@Deprecated @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 Used for exporting source control entities- Throws:
Exception- 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_NODEandNode.CDATA_SECTION_NODE. All other Node types will return an empty string.Note: As of 7.2.0, if an
Node.ELEMENT_NODEnode has childNode.TEXT_NODEnodes containing only whitespace characters (like newlines or tabs) the node will be treated as an empty string. For example, ifNode.TEXT_NODEnode 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)
-