public class DOMUtilities extends XMLUtilities implements XMLConstants
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String[] |
LOCK_STRINGS
String constants representing DOM modifier strings for various all
key lock combinations.
|
protected static java.lang.String[] |
MODIFIER_STRINGS
String constants representing DOM modifier strings for various all
shift modifier combinations.
|
IS_XML_10_NAME, IS_XML_10_QNAME
ALPHABETIC_CHARACTER, NAME_CHARACTER, NAME_FIRST_CHARACTER, NAME11_CHARACTER, NAME11_FIRST_CHARACTER, PUBLIC_ID_CHARACTER, VERSION_CHARACTER, XML_CHARACTER
XLINK_HREF_ATTRIBUTE, XLINK_HREF_QNAME, XLINK_NAMESPACE_URI, XLINK_PREFIX, XML_BASE_ATTRIBUTE, XML_BASE_QNAME, XML_CDATA_END, XML_CHAR_AMP, XML_CHAR_APOS, XML_CHAR_GT, XML_CHAR_LT, XML_CHAR_QUOT, XML_CHAR_REF_PREFIX, XML_CHAR_REF_SUFFIX, XML_CLOSE_TAG_END, XML_CLOSE_TAG_START, XML_DEFAULT_VALUE, XML_DOUBLE_DASH, XML_DOUBLE_QUOTE, XML_ENTITY_AMP, XML_ENTITY_APOS, XML_ENTITY_GT, XML_ENTITY_LT, XML_ENTITY_QUOT, XML_EQUAL_QUOT, XML_EQUAL_SIGN, XML_EVENTS_EVENT_ATTRIBUTE, XML_EVENTS_NAMESPACE_URI, XML_ID_ATTRIBUTE, XML_ID_QNAME, XML_LANG_ATTRIBUTE, XML_LANG_QNAME, XML_NAMESPACE_URI, XML_OPEN_TAG_END_CHILDREN, XML_OPEN_TAG_END_NO_CHILDREN, XML_OPEN_TAG_START, XML_PREFIX, XML_PRESERVE_VALUE, XML_PROCESSING_INSTRUCTION_END, XML_SPACE, XML_SPACE_ATTRIBUTE, XML_SPACE_QNAME, XML_TAB, XML_VERSION_10, XML_VERSION_11, XMLNS_NAMESPACE_URI, XMLNS_PREFIX
Modifier | Constructor and Description |
---|---|
protected |
DOMUtilities()
Does not need to be instantiated.
|
Modifier and Type | Method and Description |
---|---|
protected static java.lang.String |
assertValidCharacters(java.lang.String s,
boolean isXML11) |
static boolean |
canAppend(Node node,
Node parentNode)
Checks if the node can be appended on the given parent node
|
static boolean |
canAppendAny(java.util.ArrayList children,
Node parentNode)
Checks whether any of the nodes from the list can be appended to a given
parentNode.
|
static boolean |
canHaveChildren(Node parentNode)
Returns whether the given Node can have children.
|
static java.lang.String |
contentToString(java.lang.String s,
boolean isXML11)
Returns the given content value transformed to replace invalid
characters with entities.
|
static Document |
deepCloneDocument(Document doc,
DOMImplementation impl)
Deep clones a document using the given DOM implementation.
|
static int |
getChildIndex(Node child)
Finds and returns the index of child node in its parent's children array
|
static int |
getChildIndex(Node child,
Node parent)
Finds and returns the index of child node in the given parent's children
array
|
static java.lang.String |
getLocalName(java.lang.String s)
Gets the local name from the given qualified name.
|
static java.lang.String |
getModifiersList(int lockState,
int modifiersEx)
Gets a DOM 3 modifiers string from the given lock and
shift bitmasks.
|
static java.lang.String |
getPrefix(java.lang.String s)
Gets the prefix from the given qualified name.
|
static java.lang.String |
getXML(Node n)
Serializes the given DOM node using
writeNode(Node,Writer)
and returns the XML as a String. |
static boolean |
isAncestorOf(Node node,
Node descendant)
Checks whether a node is ancestor of another node.
|
static boolean |
isAnyNodeAncestorOf(java.util.ArrayList ancestorNodes,
Node node)
Checks if any of from the given list of nodes is an ancestor to another
node
|
static boolean |
isAttributeSpecifiedNS(Element e,
java.lang.String namespaceURI,
java.lang.String localName)
Returns whether the given element has a particular attribute and that
it exists due to being specified explicitly, rather than being defaulted
from a DTD.
|
static boolean |
isParentOf(Node node,
Node parentNode)
Tests whether the given node is a child of the given parent node.
|
static boolean |
isValidName(java.lang.String s)
Tests whether the given string is a valid name.
|
static boolean |
isValidName11(java.lang.String s)
Tests whether the given string is a valid XML 1.1 name.
|
static boolean |
isValidPrefix(java.lang.String s)
Tests whether the given string is a valid prefix.
|
static void |
parseStyleSheetPIData(java.lang.String data,
java.util.HashMap<java.lang.String,java.lang.String> table)
Parses a 'xml-stylesheet' processing instruction data section and
puts the pseudo attributes in the given table.
|
static Node |
parseXML(java.lang.String text,
Document doc,
java.lang.String uri,
java.util.Map prefixes,
java.lang.String wrapperElementName,
SAXDocumentFactory documentFactory)
Parses the given XML string into a DocumentFragment of the given document
or a new document if 'doc' is null.
|
static void |
writeDocument(Document doc,
java.io.Writer w)
Serializes the specified
Document , writing it to the given
Writer . |
static void |
writeNode(Node n,
java.io.Writer w)
Writes a node using the given writer.
|
protected static void |
writeNode(Node n,
java.io.Writer w,
org.apache.batik.dom.util.DOMUtilities.NSMap m,
boolean isXML11) |
createXMLDeclarationReader, createXMLDocumentReader, encodingToJavaEncoding, getXMLDeclarationEncoding, isXML11Character, isXML11NameCharacter, isXML11NameFirstCharacter, isXMLAlphabeticCharacter, isXMLCharacter, isXMLNameCharacter, isXMLNameFirstCharacter, isXMLPublicIdCharacter, isXMLSpace, isXMLVersionCharacter, testXMLQName
protected static final java.lang.String[] LOCK_STRINGS
protected static final java.lang.String[] MODIFIER_STRINGS
public static void writeDocument(Document doc, java.io.Writer w) throws java.io.IOException
Document
, writing it to the given
Writer
.java.io.IOException
protected static void writeNode(Node n, java.io.Writer w, org.apache.batik.dom.util.DOMUtilities.NSMap m, boolean isXML11) throws java.io.IOException
java.io.IOException
public static void writeNode(Node n, java.io.Writer w) throws java.io.IOException
java.io.IOException
public static java.lang.String getXML(Node n)
writeNode(Node,Writer)
and returns the XML as a String.n
- The Node to serialize.protected static java.lang.String assertValidCharacters(java.lang.String s, boolean isXML11) throws java.io.IOException
java.io.IOException
public static java.lang.String contentToString(java.lang.String s, boolean isXML11) throws java.io.IOException
java.io.IOException
public static int getChildIndex(Node child, Node parent)
child
- The child nodeparent
- The parent nodepublic static int getChildIndex(Node child)
child
- The child nodepublic static boolean isAnyNodeAncestorOf(java.util.ArrayList ancestorNodes, Node node)
ancestorNodes
- The potential ancestor nodesnode
- The potential descendant nodepublic static boolean isAncestorOf(Node node, Node descendant)
node
- The potential ancestor nodedescendant
- The potential descendant nodepublic static boolean isParentOf(Node node, Node parentNode)
node
- The potential child nodeparentNode
- Parent nodepublic static boolean canAppend(Node node, Node parentNode)
node
- The given nodeparentNode
- The given parent nodepublic static boolean canAppendAny(java.util.ArrayList children, Node parentNode)
children
- The given node listparentNode
- The potential parent nodepublic static boolean canHaveChildren(Node parentNode)
parentNode
- The Node to testtrue
if the node can have children,
false
otherwisepublic static Node parseXML(java.lang.String text, Document doc, java.lang.String uri, java.util.Map prefixes, java.lang.String wrapperElementName, SAXDocumentFactory documentFactory)
text
- The given XML stringdoc
- The given documenturi
- The document URIprefixes
- The prefixes map with (prefix, namespaceURI) pairswrapperElementName
- null: Ignore the wrapper element and prefixes map and try to
parse the text as a whole document otherwise: Wrap the given
text with the wrapper element with prefixes specified from the
prefixes mapdocumentFactory
- What document factory to use when parsing the textpublic static Document deepCloneDocument(Document doc, DOMImplementation impl)
public static boolean isValidName(java.lang.String s)
public static boolean isValidName11(java.lang.String s)
public static boolean isValidPrefix(java.lang.String s)
public static java.lang.String getPrefix(java.lang.String s)
public static java.lang.String getLocalName(java.lang.String s)
public static void parseStyleSheetPIData(java.lang.String data, java.util.HashMap<java.lang.String,java.lang.String> table)
public static java.lang.String getModifiersList(int lockState, int modifiersEx)
public static boolean isAttributeSpecifiedNS(Element e, java.lang.String namespaceURI, java.lang.String localName)
Copyright © 2022 Apache Software Foundation. All Rights Reserved.