public final class DocumentHelper
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static void |
addNamespaceDeclaration(org.w3c.dom.Element element, javax.xml.stream.events.Namespace namespace)
Adds a namespace declaration attribute to the given element.
(将命名空间声明属性添加到给定元素。)
|
static void |
addNamespaceDeclaration(org.w3c.dom.Element element, java.lang.String namespacePrefix, java.lang.String namespaceURI)
Adds a namespace declaration attribute to the given element.
(将命名空间声明属性添加到给定元素。)
|
static org.w3c.dom.Document |
createDocument()
Creates a new DOM Document
(创建一个新的 DOM 文档)
|
static javax.xml.parsers.DocumentBuilder |
newDocumentBuilder()
Creates a new document builder, with sensible defaults
(创建一个新的文档构建器,具有合理的默认值)
|
static org.w3c.dom.Document |
readDocument(org.xml.sax.InputSource inp)
Parses the given stream via the default (sensible) DocumentBuilder
(通过默认的(合理的)DocumentBuilder 解析给定的流)
|
static org.w3c.dom.Document |
readDocument(java.io.InputStream inp)
Parses the given stream via the default (sensible) DocumentBuilder
(通过默认的(合理的)DocumentBuilder 解析给定的流)
|
public static javax.xml.parsers.DocumentBuilder newDocumentBuilder()
java.lang.IllegalStateException
- If creating the DocumentBuilder fails, e.g. due to
ParserConfigurationException
.
(java.lang.IllegalStateException - 如果创建 DocumentBuilder 失败,例如由于 ParserConfigurationException。)
public static org.w3c.dom.Document readDocument(java.io.InputStream inp) throws java.io.IOException, org.xml.sax.SAXException
inp
- Stream to read the XML data from
(inp - 从中读取 XML 数据的流)
java.io.IOException
(java.io.IOException)
org.xml.sax.SAXException
(org.xml.sax.SAXException)
public static org.w3c.dom.Document readDocument(org.xml.sax.InputSource inp) throws java.io.IOException, org.xml.sax.SAXException
inp
- sax source to read the XML data from
(inp - 用于从中读取 XML 数据的 sax 源)
java.io.IOException
(java.io.IOException)
org.xml.sax.SAXException
(org.xml.sax.SAXException)
public static org.w3c.dom.Document createDocument()
public static void addNamespaceDeclaration(org.w3c.dom.Element element, java.lang.String namespacePrefix, java.lang.String namespaceURI)
public static void addNamespaceDeclaration(org.w3c.dom.Element element, javax.xml.stream.events.Namespace namespace)
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.