Package net.obvj.confectory.util
Class XMLUtils
- java.lang.Object
-
- net.obvj.confectory.util.XMLUtils
-
public class XMLUtils extends Object
Common methods for working with XML.- Since:
- 2.5.0
- Author:
- oswaldo.bapvic.jr (Oswaldo Junior)
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DocumentBuilderFactorydocumentBuilderFactory()Obtain a new instance of aDocumentBuilderFactorywhich is considered to be secure against XXE (XML External Entity) attacks.static StringtoString(Node node)Returns a string representation of the specified XMLNode.static StringtoString(NodeList nodeList)Returns a string representation of the specified XMLNodeList.static TransformerFactorytransformerFactory()Obtain a new instance of aTransformerFactorywhich is considered to be secure against XXE (XML External Entity) attacks.
-
-
-
Method Detail
-
documentBuilderFactory
public static DocumentBuilderFactory documentBuilderFactory() throws ParserConfigurationException
Obtain a new instance of aDocumentBuilderFactorywhich is considered to be secure against XXE (XML External Entity) attacks.For safety, DOCTYPE declarations are completely disabled.
- Returns:
- a new, secure
DocumentBuilderFactory - Throws:
ParserConfigurationException- if unable to disable DOCTYPE declarations in the new factory
-
transformerFactory
public static TransformerFactory transformerFactory()
Obtain a new instance of aTransformerFactorywhich is considered to be secure against XXE (XML External Entity) attacks.For safety, the use of all protocols by external entities is disabled.
- Returns:
- a new, secure
TransformerFactory
-
toString
public static String toString(NodeList nodeList)
Returns a string representation of the specified XMLNodeList.- Parameters:
nodeList- theNodeListto be converted- Returns:
- the node list as string
- Throws:
ConfigurationException- if unable to convert a document node into string
-
toString
public static String toString(Node node)
Returns a string representation of the specified XMLNode.If the XML node is either an attribute or a text node, the text content will be returned. For all other node types (e.g.: document, or element), the node will be transformed/encoded as string.
- Parameters:
node- theNodeto be converted- Returns:
- the node value as string
- Throws:
ConfigurationException- if unable to convert the document node into string
-
-