public class DocumentUtil extends Object
Modifier and Type | Field and Description |
---|---|
static String |
feature_disallow_doctype_decl |
static String |
feature_external_general_entities |
static String |
feature_external_parameter_entities |
Constructor and Description |
---|
DocumentUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
asString(Document doc)
Get the document as a string while ignoring any exceptions
|
static Document |
createDocument()
Create a new document
|
static Document |
createDocumentWithBaseNamespace(String baseNamespace,
String localPart)
Create a document with the root element of the form <someElement xmlns="customNamespace"
|
static Element |
getChildElement(Element doc,
QName elementQName)
Get an child element from the parent element given its
QName |
static Element |
getDirectChildElement(Element parent,
String targetNamespace,
String targetLocalName)
|
static Document |
getDocument(File file)
Get Document from a file
|
static Document |
getDocument(InputStream is)
Get Document from an inputstream
|
static Document |
getDocument(Reader reader)
Parse a document from a reader
|
static Document |
getDocument(String docString)
Parse a document from the string
|
static String |
getDocumentAsString(Document signedDoc)
Marshall a document into a String
|
static DocumentBuilder |
getDocumentBuilder() |
static Element |
getElement(Document doc,
QName elementQName)
Get an element from the document given its
QName |
static InputStream |
getNodeAsStream(Node node)
Stream a DOM Node as an input stream
|
static String |
getNodeAsString(Node node)
Marshall a DOM Node into a String
|
static InputStream |
getSourceAsStream(Source source)
Get the
Source as an InputStream |
static Source |
getXMLSource(Document doc)
|
public static final String feature_external_general_entities
public static final String feature_external_parameter_entities
public static final String feature_disallow_doctype_decl
public static Document createDocument() throws ConfigurationException
ParserConfigurationException
ConfigurationException
public static Document createDocumentWithBaseNamespace(String baseNamespace, String localPart) throws ProcessingException
baseNamespace
- ProcessingException
public static Document getDocument(String docString) throws ConfigurationException, ParsingException, ProcessingException
docString
- IOException
SAXException
ParserConfigurationException
ConfigurationException
ParsingException
ProcessingException
public static Document getDocument(Reader reader) throws ConfigurationException, ProcessingException, ParsingException
reader
- ParsingException
ParserConfigurationException
IOException
SAXException
ConfigurationException
ProcessingException
public static Document getDocument(File file) throws ConfigurationException, ProcessingException, ParsingException
file
- ParserConfigurationException
IOException
SAXException
ConfigurationException
ProcessingException
ParsingException
public static Document getDocument(InputStream is) throws ConfigurationException, ProcessingException, ParsingException
is
- ParserConfigurationException
IOException
SAXException
ConfigurationException
ProcessingException
ParsingException
public static String getDocumentAsString(Document signedDoc) throws ProcessingException, ConfigurationException
signedDoc
- TransformerFactoryConfigurationError
TransformerException
ProcessingException
ConfigurationException
public static String getNodeAsString(Node node) throws ProcessingException, ConfigurationException
node
- ProcessingException
ConfigurationException
public static Element getElement(Document doc, QName elementQName)
Get an element from the document given its QName
First an attempt to get the element based on its namespace is made, failing which an element with the localpart ignoring any namespace is returned.
doc
- elementQName
- public static Element getChildElement(Element doc, QName elementQName)
Get an child element from the parent element given its QName
First an attempt to get the element based on its namespace is made, failing which an element with the localpart ignoring any namespace is returned.
doc
- elementQName
- public static InputStream getNodeAsStream(Node node) throws ConfigurationException, ProcessingException
node
- TransformerFactoryConfigurationError
TransformerException
ConfigurationException
ProcessingException
public static InputStream getSourceAsStream(Source source) throws ConfigurationException, ProcessingException
Source
as an InputStream
source
- ConfigurationException
ProcessingException
public static String asString(Document doc)
doc
- public static DocumentBuilder getDocumentBuilder() throws ParserConfigurationException
ParserConfigurationException
public static Element getDirectChildElement(Element parent, String targetNamespace, String targetLocalName)
parent
- parent elementtargetNamespace
- namespace URItargetLocalName
- local nameCopyright © 2021 JBoss by Red Hat. All rights reserved.