java.lang.Object
org.jhotdraw8.xml.XmlUtil
XmlUtil.
- Author:
- Werner Randelshofer
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic DocumentcreateDocument(@Nullable String nsURI, @Nullable String nsQualifier, String docElemName) Creates a namespace aware document.static @Nullable LocatorgetLocator(Node node) static Documentread(InputStream in, boolean namespaceAware) static Documentstatic Documentstatic Documentread(InputSource inputSource, boolean namespaceAware) static @Nullable StringreadNamespaceUri(URI file) static @Nullable StringreadNamespaceUri(Source source) static DocumentreadWithLocations(Path in, boolean namespaceAware) static DocumentreadWithLocations(InputSource inputSource, boolean namespaceAware) Reads the specified input into a document.static XMLStreamReaderstreamReader(Source file) Creates an XMLStreamReader that only reads data from the specified file.static XMLStreamWriterstreamWriter(Result file, @Nullable Properties outputProperties) Creates an XMLStreamWriter that only writes data to the specified file.static voidstatic voidstatic voidstatic voidstatic voidstatic voidwrite(OutputStream out, Document doc) static voidstatic voidstatic voidwrite(Path out, Document doc, Properties outputProperties) static voidstatic voidwrite(Result result, Document doc, @Nullable Properties outputProperties)
-
Field Details
-
LOCATION_ATTRIBUTE
- See Also:
-
LOCATION_NAMESPACE
- See Also:
-
HTTP_XML_APACHE_ORG_XALAN_LINE_SEPARATOR
- See Also:
-
HTTP_XML_APACHE_ORG_XSLT_INDENT_AMOUNT
- See Also:
-
CANONICAL_LINE_SEPARATOR
- See Also:
-
-
Method Details
-
createDocument
public static Document createDocument(@Nullable String nsURI, @Nullable String nsQualifier, String docElemName) throws IOException Creates a namespace aware document.- Parameters:
nsURI- nullable namespace URInsQualifier- nullable namespace qualifierdocElemName- notnull name of the document element- Returns:
- a new Document
- Throws:
IOException- if the parser configuration fails
-
read
- Throws:
IOException
-
read
- Throws:
IOException
-
read
- Throws:
IOException
-
readWithLocations
- Throws:
IOException
-
read
- Throws:
IOException
-
readWithLocations
public static Document readWithLocations(InputSource inputSource, boolean namespaceAware) throws IOException Reads the specified input into a document. Adds a "location" attribute to each node, specifying the file, the line number and the column number of the node.References:
- Stackoverflow, Is there a way to parse XML via SAX/DOM with line numbers available per node, Copyright Reg Whitton, CC BY-SA 4.0 license
- stackoverflow.com.
- Parameters:
inputSource- the input sourcenamespaceAware- whether to be name space aware- Returns:
- the document
- Throws:
IOException- in case of failure
-
getLocator
-
validate
- Throws:
IOException
-
validate
- Throws:
IOException
-
validate
- Throws:
IOException
-
validate
- Throws:
IOException
-
validate
- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Throws:
IOException
-
write
public static void write(Result result, Document doc, @Nullable Properties outputProperties) throws IOException - Throws:
IOException
-
streamWriter
Creates an XMLStreamWriter that only writes data to the specified file. That is, it does not create socket connections.- Parameters:
file- a file- Returns:
- an XMLStreamWriter
-
streamReader
Creates an XMLStreamReader that only reads data from the specified file. That is, it does not create socket connections.- Parameters:
file- a file- Returns:
- an XMLStreamReader
- Throws:
XMLStreamException- when the XMLStreamReader could not be created
-
readNamespaceUri
- Throws:
IOException
-
readNamespaceUri
- Throws:
IOException
-