public class XmlUtils
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
TRANSFORMER_FACTORY_PROCESSOR_XALAN |
| Constructor and Description |
|---|
XmlUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
appendXmlFragment(org.w3c.dom.Document document,
org.w3c.dom.Node parent,
java.lang.String fragment) |
static <T> T |
deepCopy(T value)
Clone this JAXB object, using default JAXBContext.
|
static <T> T |
deepCopy(T value,
javax.xml.bind.JAXBContext jc)
Clone this JAXB object
|
static javax.xml.parsers.DocumentBuilderFactory |
getDocumentBuilderFactory()
Deprecated.
|
static java.util.List<JAXBAssociation> |
getJAXBAssociationsForXPath(javax.xml.bind.Binder<org.w3c.dom.Node> binder,
java.lang.Object jaxbElement,
java.lang.String xpathExpr,
boolean refreshXmlFirst)
Fetch DOM node / JAXB object pairs matching an XPath (for example "//w:p").
|
static java.util.List<java.lang.Object> |
getJAXBNodesViaXPath(javax.xml.bind.Binder<org.w3c.dom.Node> binder,
java.lang.Object jaxbElement,
java.lang.String xpathExpr,
boolean refreshXmlFirst)
Fetch JAXB Nodes matching an XPath (for example "//w:p").
|
static javax.xml.bind.JAXBElement<?> |
getListItemByQName(java.util.List<javax.xml.bind.JAXBElement<?>> list,
javax.xml.namespace.QName name) |
static javax.xml.parsers.DocumentBuilder |
getNewDocumentBuilder()
Use the suitably configured DocumentBuilderFactory to provide
a new instance of DocumentBuilder.
|
static javax.xml.transform.TransformerFactory |
getTransformerFactory() |
static javax.xml.transform.Templates |
getTransformerTemplate(javax.xml.transform.Source xsltSource) |
static java.lang.Object |
handleUnmarshalException(javax.xml.bind.JAXBContext jc,
JaxbValidationEventHandler eventHandler,
org.w3c.dom.Document document,
java.lang.Exception ue) |
static java.lang.String |
JAXBElementDebug(javax.xml.bind.JAXBElement o) |
static java.io.InputStream |
marshaltoInputStream(java.lang.Object o,
boolean suppressDeclaration,
javax.xml.bind.JAXBContext jc)
marshaltoInputStream, declaring mcChoiceNamespace
|
static java.io.InputStream |
marshaltoInputStream(java.lang.Object o,
boolean suppressDeclaration,
javax.xml.bind.JAXBContext jc,
java.lang.String mcChoiceNamespace)
marshaltoInputStream, declaring mcChoiceNamespace
|
static java.lang.String |
marshaltoString(java.lang.Object o)
Marshal this object to a String, pretty printed, and without an XML declaration.
|
static java.lang.String |
marshaltoString(java.lang.Object o,
boolean suppressDeclaration)
Deprecated.
|
static java.lang.String |
marshaltoString(java.lang.Object o,
boolean suppressDeclaration,
boolean prettyprint)
Marshal to a String
|
static java.lang.String |
marshaltoString(java.lang.Object o,
boolean suppressDeclaration,
boolean prettyprint,
javax.xml.bind.JAXBContext jc)
Marshal to a String
|
static java.lang.String |
marshaltoString(java.lang.Object o,
boolean suppressDeclaration,
boolean prettyprint,
javax.xml.bind.JAXBContext jc,
java.lang.String mcChoiceNamespace)
Marshal to a String, declaring mcChoiceNamespace
|
static java.lang.String |
marshaltoString(java.lang.Object o,
boolean suppressDeclaration,
boolean prettyprint,
javax.xml.bind.JAXBContext jc,
java.lang.String uri,
java.lang.String local,
java.lang.Class declaredType)
Marshal to a String, for object
missing an @XmlRootElement annotation
|
static java.lang.String |
marshaltoString(java.lang.Object o,
boolean suppressDeclaration,
boolean prettyprint,
javax.xml.bind.JAXBContext jc,
java.lang.String uri,
java.lang.String local,
java.lang.Class declaredType,
java.lang.String mcChoiceNamespace)
Marshal to a String, for object
missing an @XmlRootElement annotation, declaring mcChoiceNamespace
|
static java.lang.String |
marshaltoString(java.lang.Object o,
boolean suppressDeclaration,
javax.xml.bind.JAXBContext jc)
Deprecated.
|
static java.lang.String |
marshaltoString(java.lang.Object o,
javax.xml.bind.JAXBContext jc)
Use the specified JAXBContext to marshal this object to a String, pretty printed, and without an XML declaration.
|
static org.w3c.dom.Document |
marshaltoW3CDomDocument(java.lang.Object o)
Marshal to a W3C document
|
static org.w3c.dom.Document |
marshaltoW3CDomDocument(java.lang.Object o,
javax.xml.bind.JAXBContext jc)
Marshal to a W3C document, declaring mcChoiceNamespace
|
static org.w3c.dom.Document |
marshaltoW3CDomDocument(java.lang.Object o,
javax.xml.bind.JAXBContext jc,
java.lang.String mcChoiceNamespace)
Marshal to a W3C document, declaring mcChoiceNamespace
|
static org.w3c.dom.Document |
marshaltoW3CDomDocument(java.lang.Object o,
javax.xml.bind.JAXBContext jc,
java.lang.String uri,
java.lang.String local,
java.lang.Class declaredType)
Marshal to a W3C document, for object
missing an @XmlRootElement annotation.
|
static org.w3c.dom.Document |
marshaltoW3CDomDocument(java.lang.Object o,
javax.xml.bind.JAXBContext jc,
java.lang.String uri,
java.lang.String local,
java.lang.Class declaredType,
java.lang.String mcChoiceNamespace)
Marshal to a W3C document, for object
missing an @XmlRootElement annotation, declaring mcChoiceNamespace
|
static org.w3c.dom.Document |
neww3cDomDocument()
Use DocumentBuilderFactory to create and return a new w3c dom Document.
|
static javax.xml.bind.util.JAXBResult |
prepareJAXBResult(javax.xml.bind.JAXBContext context)
Prepare a JAXB transformation result for some given context.
|
static void |
transform(org.w3c.dom.Document doc,
javax.xml.transform.Templates template,
java.util.Map<java.lang.String,java.lang.Object> transformParameters,
javax.xml.transform.Result result) |
static void |
transform(javax.xml.transform.Source source,
javax.xml.transform.Templates template,
java.util.Map<java.lang.String,java.lang.Object> transformParameters,
javax.xml.transform.Result result)
Transform an input document using XSLT
|
static void |
treeCopy(org.w3c.dom.NodeList sourceNodes,
org.w3c.dom.Node destParent) |
static void |
treeCopy(org.w3c.dom.Node sourceNode,
org.w3c.dom.Node destParent)
Copy a node from one DOM document to another.
|
static byte[] |
trimNamespaces(org.w3c.dom.Document doc,
java.lang.String ignorables)
Removes superflouous namespaces.
|
static java.lang.Object |
unmarshal(java.io.InputStream is)
Unmarshal an InputStream as an object in the package org.docx4j.jaxb.document.
|
static java.lang.Object |
unmarshal(java.io.InputStream is,
javax.xml.bind.JAXBContext jc) |
static java.lang.Object |
unmarshal(org.w3c.dom.Node n)
Unmarshal a node using Context.jc, WITHOUT fallback to pre-processing in case of failure.
|
static java.lang.Object |
unmarshal(org.w3c.dom.Node n,
javax.xml.bind.JAXBContext jc,
java.lang.Class declaredType) |
static java.lang.Object |
unmarshallFromTemplate(java.lang.String wmlTemplateString,
java.util.Map<java.lang.String,?> mappings)
Give a string of wml containing ${key1}, ${key2}, return a suitable
object.
|
static java.lang.Object |
unmarshallFromTemplate(java.lang.String wmlTemplateString,
java.util.Map<java.lang.String,?> mappings,
javax.xml.bind.JAXBContext jc) |
static java.lang.Object |
unmarshallFromTemplate(java.lang.String wmlTemplateString,
java.util.Map<java.lang.String,?> mappings,
javax.xml.bind.JAXBContext jc,
java.lang.Class<?> declaredType) |
static java.lang.Object |
unmarshalString(java.lang.String str)
Unmarshal a String as an object in the package org.docx4j.jaxb.document.
|
static java.lang.Object |
unmarshalString(java.lang.String str,
javax.xml.bind.JAXBContext jc) |
static java.lang.Object |
unmarshalString(java.lang.String str,
javax.xml.bind.JAXBContext jc,
java.lang.Class declaredType) |
static java.lang.Object |
unwrap(java.lang.Object o)
If an object is wrapped in a JAXBElement, return the object.
|
static void |
w3CDomNodeToOutputStream(org.w3c.dom.Node n,
java.io.OutputStream os) |
static java.lang.String |
w3CDomNodeToString(org.w3c.dom.Node n) |
static java.util.List<org.w3c.dom.Node> |
xpath(org.w3c.dom.Node node,
java.lang.String xpathExpression) |
static java.util.List<org.w3c.dom.Node> |
xpath(org.w3c.dom.Node node,
java.lang.String xpathExpression,
javax.xml.namespace.NamespaceContext nsContext) |
public static java.lang.String TRANSFORMER_FACTORY_PROCESSOR_XALAN
public static javax.xml.transform.TransformerFactory getTransformerFactory()
@Deprecated public static javax.xml.parsers.DocumentBuilderFactory getDocumentBuilderFactory()
public static javax.xml.parsers.DocumentBuilder getNewDocumentBuilder()
public static java.lang.Object unwrap(java.lang.Object o)
o - public static java.lang.String JAXBElementDebug(javax.xml.bind.JAXBElement o)
public static javax.xml.bind.JAXBElement<?> getListItemByQName(java.util.List<javax.xml.bind.JAXBElement<?>> list,
javax.xml.namespace.QName name)
list - name - public static java.lang.Object unmarshal(java.io.InputStream is)
throws javax.xml.bind.JAXBException
javax.xml.bind.JAXBExceptionpublic static java.lang.Object unmarshal(java.io.InputStream is,
javax.xml.bind.JAXBContext jc)
throws javax.xml.bind.JAXBException
javax.xml.bind.JAXBExceptionpublic static java.lang.Object unmarshalString(java.lang.String str)
throws javax.xml.bind.JAXBException
javax.xml.bind.JAXBExceptionpublic static java.lang.Object unmarshalString(java.lang.String str,
javax.xml.bind.JAXBContext jc,
java.lang.Class declaredType)
throws javax.xml.bind.JAXBException
javax.xml.bind.JAXBExceptionpublic static java.lang.Object unmarshalString(java.lang.String str,
javax.xml.bind.JAXBContext jc)
throws javax.xml.bind.JAXBException
javax.xml.bind.JAXBExceptionpublic static java.lang.Object handleUnmarshalException(javax.xml.bind.JAXBContext jc,
JaxbValidationEventHandler eventHandler,
org.w3c.dom.Document document,
java.lang.Exception ue)
throws javax.xml.bind.UnmarshalException,
javax.xml.bind.JAXBException
javax.xml.bind.UnmarshalExceptionjavax.xml.bind.JAXBExceptionpublic static java.lang.Object unmarshal(org.w3c.dom.Node n)
throws javax.xml.bind.JAXBException
n - javax.xml.bind.JAXBExceptionpublic static java.lang.Object unmarshal(org.w3c.dom.Node n,
javax.xml.bind.JAXBContext jc,
java.lang.Class declaredType)
throws javax.xml.bind.JAXBException
javax.xml.bind.JAXBExceptionpublic static java.lang.Object unmarshallFromTemplate(java.lang.String wmlTemplateString,
java.util.Map<java.lang.String,?> mappings)
throws javax.xml.bind.JAXBException
wmlTemplateString - mappings - javax.xml.bind.JAXBExceptionwhich can invoke this more efficientlypublic static java.lang.Object unmarshallFromTemplate(java.lang.String wmlTemplateString,
java.util.Map<java.lang.String,?> mappings,
javax.xml.bind.JAXBContext jc)
throws javax.xml.bind.JAXBException
javax.xml.bind.JAXBExceptionpublic static java.lang.Object unmarshallFromTemplate(java.lang.String wmlTemplateString,
java.util.Map<java.lang.String,?> mappings,
javax.xml.bind.JAXBContext jc,
java.lang.Class<?> declaredType)
throws javax.xml.bind.JAXBException
javax.xml.bind.JAXBExceptionpublic static java.lang.String marshaltoString(java.lang.Object o)
o - public static java.lang.String marshaltoString(java.lang.Object o,
javax.xml.bind.JAXBContext jc)
o - @Deprecated
public static java.lang.String marshaltoString(java.lang.Object o,
boolean suppressDeclaration)
@Deprecated
public static java.lang.String marshaltoString(java.lang.Object o,
boolean suppressDeclaration,
javax.xml.bind.JAXBContext jc)
public static java.lang.String marshaltoString(java.lang.Object o,
boolean suppressDeclaration,
boolean prettyprint)
public static byte[] trimNamespaces(org.w3c.dom.Document doc,
java.lang.String ignorables)
throws InvalidCanonicalizerException,
CanonicalizationException
public static java.lang.String marshaltoString(java.lang.Object o,
boolean suppressDeclaration,
boolean prettyprint,
javax.xml.bind.JAXBContext jc)
public static java.lang.String marshaltoString(java.lang.Object o,
boolean suppressDeclaration,
boolean prettyprint,
javax.xml.bind.JAXBContext jc,
java.lang.String mcChoiceNamespace)
public static java.lang.String marshaltoString(java.lang.Object o,
boolean suppressDeclaration,
boolean prettyprint,
javax.xml.bind.JAXBContext jc,
java.lang.String uri,
java.lang.String local,
java.lang.Class declaredType)
public static java.lang.String marshaltoString(java.lang.Object o,
boolean suppressDeclaration,
boolean prettyprint,
javax.xml.bind.JAXBContext jc,
java.lang.String uri,
java.lang.String local,
java.lang.Class declaredType,
java.lang.String mcChoiceNamespace)
public static java.io.InputStream marshaltoInputStream(java.lang.Object o,
boolean suppressDeclaration,
javax.xml.bind.JAXBContext jc)
public static java.io.InputStream marshaltoInputStream(java.lang.Object o,
boolean suppressDeclaration,
javax.xml.bind.JAXBContext jc,
java.lang.String mcChoiceNamespace)
public static org.w3c.dom.Document marshaltoW3CDomDocument(java.lang.Object o)
public static org.w3c.dom.Document marshaltoW3CDomDocument(java.lang.Object o,
javax.xml.bind.JAXBContext jc)
public static org.w3c.dom.Document marshaltoW3CDomDocument(java.lang.Object o,
javax.xml.bind.JAXBContext jc,
java.lang.String mcChoiceNamespace)
public static org.w3c.dom.Document marshaltoW3CDomDocument(java.lang.Object o,
javax.xml.bind.JAXBContext jc,
java.lang.String uri,
java.lang.String local,
java.lang.Class declaredType)
public static org.w3c.dom.Document marshaltoW3CDomDocument(java.lang.Object o,
javax.xml.bind.JAXBContext jc,
java.lang.String uri,
java.lang.String local,
java.lang.Class declaredType,
java.lang.String mcChoiceNamespace)
public static <T> T deepCopy(T value)
public static <T> T deepCopy(T value,
javax.xml.bind.JAXBContext jc)
value - jc - public static java.lang.String w3CDomNodeToString(org.w3c.dom.Node n)
public static void w3CDomNodeToOutputStream(org.w3c.dom.Node n,
java.io.OutputStream os)
throws Docx4JException
n - os - Docx4JExceptionpublic static org.w3c.dom.Document neww3cDomDocument()
public static void appendXmlFragment(org.w3c.dom.Document document,
org.w3c.dom.Node parent,
java.lang.String fragment)
throws java.io.IOException,
org.xml.sax.SAXException,
javax.xml.parsers.ParserConfigurationException
docBuilder - the parserparent - node to add fragment tofragment - a well formed XML fragmentjavax.xml.parsers.ParserConfigurationExceptionjava.io.IOExceptionorg.xml.sax.SAXExceptionpublic static javax.xml.bind.util.JAXBResult prepareJAXBResult(javax.xml.bind.JAXBContext context)
throws Docx4JException
context - The JAXB context.Docx4JException - In case of configuration errors.public static void transform(org.w3c.dom.Document doc,
javax.xml.transform.Templates template,
java.util.Map<java.lang.String,java.lang.Object> transformParameters,
javax.xml.transform.Result result)
throws Docx4JException
Docx4JExceptionpublic static javax.xml.transform.Templates getTransformerTemplate(javax.xml.transform.Source xsltSource)
throws javax.xml.transform.TransformerConfigurationException
javax.xml.transform.TransformerConfigurationExceptionpublic static void transform(javax.xml.transform.Source source,
javax.xml.transform.Templates template,
java.util.Map<java.lang.String,java.lang.Object> transformParameters,
javax.xml.transform.Result result)
throws Docx4JException
doc - xslt - transformParameters - result - Docx4JException - In case serious transformation errors occurpublic static java.util.List<java.lang.Object> getJAXBNodesViaXPath(javax.xml.bind.Binder<org.w3c.dom.Node> binder,
java.lang.Object jaxbElement,
java.lang.String xpathExpr,
boolean refreshXmlFirst)
throws javax.xml.bind.JAXBException,
XPathBinderAssociationIsPartialException
binder - jaxbElement - refreshXmlFirst - xpathExpr - javax.xml.bind.JAXBExceptionXPathBinderAssociationIsPartialExceptionpublic static java.util.List<JAXBAssociation> getJAXBAssociationsForXPath(javax.xml.bind.Binder<org.w3c.dom.Node> binder, java.lang.Object jaxbElement, java.lang.String xpathExpr, boolean refreshXmlFirst) throws javax.xml.bind.JAXBException, XPathBinderAssociationIsPartialException
binder - jaxbElement - xpathExpr - refreshXmlFirst - javax.xml.bind.JAXBExceptionXPathBinderAssociationIsPartialExceptionpublic static java.util.List<org.w3c.dom.Node> xpath(org.w3c.dom.Node node,
java.lang.String xpathExpression)
public static java.util.List<org.w3c.dom.Node> xpath(org.w3c.dom.Node node,
java.lang.String xpathExpression,
javax.xml.namespace.NamespaceContext nsContext)
public static void treeCopy(org.w3c.dom.NodeList sourceNodes,
org.w3c.dom.Node destParent)
public static void treeCopy(org.w3c.dom.Node sourceNode,
org.w3c.dom.Node destParent)
sourceNode - destParent - Copyright © 2007–2023. All rights reserved.