public final class XMLUtilities
extends java.lang.Object
TransformerFactory
instances.
(This is based on similar utility methods in ph-commons.)
| 限定符和类型 | 字段和说明 |
|---|---|
static java.lang.String |
SAXON_TRANSFORMER_FACTORY_CLASS_NAME
Explicit name of the SAXON 9.X TransformerFactoryImpl Class, as used by the up-conversion extensions
|
| 构造器和说明 |
|---|
XMLUtilities() |
| 限定符和类型 | 方法和说明 |
|---|---|
static javax.xml.transform.TransformerFactory |
createJAXPTransformerFactory()
Creates an instance of the currently specified JAXP
TransformerFactory, ensuring
that the result supports the DOMSource.FEATURE and DOMResult.FEATURE
features. |
static javax.xml.parsers.DocumentBuilder |
createNSAwareDocumentBuilder()
Creates a (namespace-aware) DOM
DocumentBuilder, throwing a SnuggleRuntimeException
if such a thing cannot be created/configured. |
static javax.xml.transform.TransformerFactory |
createSaxonTransformerFactory()
Explicitly creates a Saxon 9
TransformerFactory, as used by the up-conversion
extensions. |
static java.lang.String |
extractTextElementValue(org.w3c.dom.Element textElement)
Trivial convenience method to extract the value of a (text) Element, coping with the
possibility that text child Nodes may not have been coalesced.
|
static boolean |
isSaxonAvailable() |
static boolean |
isXMLName(java.lang.String string) |
static boolean |
isXMLNCName(java.lang.String string) |
static void |
requireFeature(javax.xml.transform.TransformerFactory transformerFactory,
java.lang.String feature) |
static java.lang.String |
serializeNode(org.w3c.dom.Node node,
SerializationSpecifier serializationOptions)
Serializes the given
Node to a well-formed external parsed entity. |
static java.lang.String |
serializeNode(StylesheetManager stylesheetManager,
org.w3c.dom.Node node,
SerializationSpecifier serializationOptions)
Serializes the given
Node to a well-formed external parsed entity. |
static java.lang.String |
serializeNodeChildren(StylesheetManager stylesheetManager,
org.w3c.dom.Node node,
SerializationSpecifier serializationOptions)
Serializes the
children of given Node to a well-formed external parsed entity. |
static void |
setIndentation(javax.xml.transform.Transformer transformer,
int indent)
Helper to turn on indentation for a
Transformer that works correctly for
both Saxon and Xalan. |
static boolean |
supportsXSLT20(javax.xml.transform.Transformer tranformer) |
static boolean |
supportsXSLT20(javax.xml.transform.TransformerFactory tranformerFactory)
Tests whether the given
TransformerFactory is known to support XSLT 2.0. |
public static final java.lang.String SAXON_TRANSFORMER_FACTORY_CLASS_NAME
public static javax.xml.transform.TransformerFactory createJAXPTransformerFactory()
TransformerFactory, ensuring
that the result supports the DOMSource.FEATURE and DOMResult.FEATURE
features.public static void requireFeature(javax.xml.transform.TransformerFactory transformerFactory,
java.lang.String feature)
public static boolean isSaxonAvailable()
public static javax.xml.transform.TransformerFactory createSaxonTransformerFactory()
TransformerFactory, as used by the up-conversion
extensions.public static boolean supportsXSLT20(javax.xml.transform.TransformerFactory tranformerFactory)
TransformerFactory is known to support XSLT 2.0.
(Currently, this involves checking for a suitable version of Saxon; this will change once more processors become available.)
public static boolean supportsXSLT20(javax.xml.transform.Transformer tranformer)
public static void setIndentation(javax.xml.transform.Transformer transformer,
int indent)
Transformer that works correctly for
both Saxon and Xalan.transformer - Transformer to configureindent - required indentation, where 0 or more provides indentation and negative
numbers turns indentation off.public static javax.xml.parsers.DocumentBuilder createNSAwareDocumentBuilder()
DocumentBuilder, throwing a SnuggleRuntimeException
if such a thing cannot be created/configured.public static java.lang.String extractTextElementValue(org.w3c.dom.Element textElement)
textElement - public static java.lang.String serializeNode(org.w3c.dom.Node node,
SerializationSpecifier serializationOptions)
Node to a well-formed external parsed entity.
(If the given Node is an Element or a Document then the result
will be a well-formed XML String.)node - DOM Node to serialize.serializationOptions - XML serialization optionspublic static java.lang.String serializeNode(StylesheetManager stylesheetManager, org.w3c.dom.Node node, SerializationSpecifier serializationOptions)
Node to a well-formed external parsed entity.
(If the given Node is an Element or a Document then the result
will be a well-formed XML String.)
(This may use an XSLT 2.0 stylesheet to help with named entities, hence the requirement for a
StylesheetManager).
stylesheetManager - used to help compile and cache stylesheets used in this process.node - DOM Node to serialize.serializationOptions - XML serialization optionspublic static java.lang.String serializeNodeChildren(StylesheetManager stylesheetManager, org.w3c.dom.Node node, SerializationSpecifier serializationOptions)
children of given Node to a well-formed external parsed entity.
(This uses a little XSLT stylesheet to help, hence the requirement for a StylesheetManager).
stylesheetManager - used to help compile and cache stylesheets used in this process.node - DOM Node to serialize.serializationOptions - XML serialization optionspublic static boolean isXMLName(java.lang.String string)
public static boolean isXMLNCName(java.lang.String string)