Package com.axelor.common
Class XMLUtils
- java.lang.Object
-
- com.axelor.common.XMLUtils
-
-
Constructor Summary
Constructors Constructor Description XMLUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DocumentBuildercreateDocumentBuilder()Returns properly configuredDocumentBuilderwith security features.static DocumentBuilderFactorycreateDocumentBuilderFactory(Boolean namespaceAware)Returns properly configuredDocumentBuilderFactorywith security features and no external DTD and schema access.static SAXParsercreateSAXParser()Returns properly configuredSAXParserwith security features and no external DTD and schema access.static SAXParserFactorycreateSAXParserFactory(Boolean namespaceAware)Returns properly configuredSAXParserFactorywith security features.static TransformerFactorycreateTransformerFactory()Returns properly configuredTransformerFactorywith security features.static XPathcreateXPath()Returns properly configuredXPathwith security featuresstatic XPathFactorycreateXPathFactory()Returns properly configuredXPathFactorywith security features.static Iterator<Node>iterator(NodeList nodes)Create anIteratorfor the given nodes.static Documentparse(File file)Parse the content of the given file as an XML document.static Documentparse(InputStream is)Parse the content of the givenInputStreamas an XML document.static Documentparse(Reader reader)Parse the content of the givenReaderas an XML document.static Documentparse(URI uri)Parse the content of the given URI as an XML document.static Documentparse(InputSource is)Parse the content of the givenInputSourceas an XML document.static Spliterator<Node>spliterator(NodeList nodes)Create aSpliteratorfor the given nodes.static Stream<Node>stream(NodeList nodes)Create aStreamof the nodes.static Stream<Element>stream(Node node, String tagName)Create aStreamof the child elements with the given tag name.static voidtransform(Node node, Writer writer, String encoding)Transform the given node to xml content.
-
-
-
Method Detail
-
createDocumentBuilderFactory
public static DocumentBuilderFactory createDocumentBuilderFactory(Boolean namespaceAware)
Returns properly configuredDocumentBuilderFactorywith security features and no external DTD and schema access.- Parameters:
namespaceAware- whether the returned factory is to provide support for XML namespaces- Returns:
- configured
DocumentBuilderFactory
-
createDocumentBuilder
public static DocumentBuilder createDocumentBuilder() throws ParserConfigurationException
Returns properly configuredDocumentBuilderwith security features.- Returns:
- configured
DocumentBuilder - Throws:
ParserConfigurationException
-
createSAXParserFactory
public static SAXParserFactory createSAXParserFactory(Boolean namespaceAware)
Returns properly configuredSAXParserFactorywith security features.- Parameters:
namespaceAware- whether the returned factory is to provide support for XML namespaces- Returns:
- configured
SAXParserFactory
-
createSAXParser
public static SAXParser createSAXParser() throws ParserConfigurationException, SAXException
Returns properly configuredSAXParserwith security features and no external DTD and schema access.- Returns:
- configured
SAXParser - Throws:
ParserConfigurationExceptionSAXException
-
createXPathFactory
public static XPathFactory createXPathFactory()
Returns properly configuredXPathFactorywith security features.- Returns:
- configured
XPathFactory
-
createXPath
public static XPath createXPath()
Returns properly configuredXPathwith security features- Returns:
- configured
XPath
-
createTransformerFactory
public static TransformerFactory createTransformerFactory()
Returns properly configuredTransformerFactorywith security features.- Returns:
- configured
TransformerFactory
-
parse
public static Document parse(File file) throws ParserConfigurationException, SAXException, IOException
Parse the content of the given file as an XML document.- Parameters:
file- the file to parse- Returns:
- A new DOM Document object.
- Throws:
ParserConfigurationExceptionSAXExceptionIOException- See Also:
DocumentBuilder.parse(File)
-
parse
public static Document parse(InputStream is) throws ParserConfigurationException, SAXException, IOException
Parse the content of the givenInputStreamas an XML document.- Parameters:
is- the InputStream to parse- Returns:
- A new DOM Document object.
- Throws:
ParserConfigurationExceptionSAXExceptionIOException- See Also:
DocumentBuilder.parse(InputStream)
-
parse
public static Document parse(InputSource is) throws ParserConfigurationException, SAXException, IOException
Parse the content of the givenInputSourceas an XML document.- Parameters:
is- the InputSource to parse- Returns:
- A new DOM Document object.
- Throws:
ParserConfigurationExceptionSAXExceptionIOException- See Also:
DocumentBuilder.parse(InputSource)
-
parse
public static Document parse(Reader reader) throws ParserConfigurationException, SAXException, IOException
Parse the content of the givenReaderas an XML document.- Parameters:
reader- the Reader to parse- Returns:
- A new DOM Document object.
- Throws:
ParserConfigurationExceptionSAXExceptionIOException
-
parse
public static Document parse(URI uri) throws ParserConfigurationException, SAXException, IOException
Parse the content of the given URI as an XML document.- Parameters:
uri- the location of the content to be parsed.- Returns:
- A new DOM Document object.
- Throws:
ParserConfigurationExceptionSAXExceptionIOException- See Also:
DocumentBuilder.parse(String)
-
transform
public static void transform(Node node, Writer writer, String encoding) throws TransformerException
Transform the given node to xml content.- Parameters:
node- the node to transformwriter- the writer where to write the contentencoding- encoding to user for xml content- Throws:
TransformerException
-
iterator
public static Iterator<Node> iterator(NodeList nodes)
Create anIteratorfor the given nodes.- Parameters:
nodes- the nodes- Returns:
- an iterator
-
spliterator
public static Spliterator<Node> spliterator(NodeList nodes)
Create aSpliteratorfor the given nodes.- Parameters:
nodes- the nodes- Returns:
- a spliterator
-
stream
public static Stream<Node> stream(NodeList nodes)
Create aStreamof the nodes.- Parameters:
nodes- the nodes- Returns:
- stream of the nodes
-
-