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