java.lang.Object
org.jhotdraw8.xml.XmlUtil
XmlUtil.
- Author:
- Werner Randelshofer
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic DocumentCreates a namespace aware document.getLocator(@NonNull Node node) static Documentread(InputStream in, boolean namespaceAware) static Documentstatic Documentstatic Documentread(InputSource inputSource, boolean namespaceAware) readNamespaceUri(@NonNull URI file) readNamespaceUri(@NonNull Source source) readWithLocations(@NonNull Path in, boolean namespaceAware) readWithLocations(InputSource inputSource, boolean namespaceAware) Reads the specified input into a document.static XMLStreamReaderstreamReader(@NonNull Source file) Creates an XMLStreamReader that only reads data from the specified file.static XMLStreamWriterstreamWriter(@NonNull 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(@NonNull Path out, Document doc, Properties outputProperties) static voidstatic void
-
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
public static @NonNull Document readWithLocations(@NonNull Path in, boolean namespaceAware) throws IOException - Throws:
IOException
-
read
- Throws:
IOException
-
readWithLocations
public static @NonNull 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
public static void validate(@NonNull Source docSource, @NonNull Source schemaSource) throws IOException - Throws:
IOException
-
validate
- Throws:
IOException
-
validate
- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Throws:
IOException
-
write
public static void write(@NonNull Path out, Document doc, Properties outputProperties) throws IOException - Throws:
IOException
-
write
- Throws:
IOException
-
write
public static void write(@NonNull Result result, @NonNull Document doc, @Nullable Properties outputProperties) throws IOException - Throws:
IOException
-
streamWriter
public static XMLStreamWriter streamWriter(@NonNull Result file, @Nullable Properties outputProperties) 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
-