|
|
|
|
|
*/ |
|
/* |
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
|
* contributor license agreements. See the NOTICE file distributed with |
|
* this work for additional information regarding copyright ownership. |
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
|
* (the "License"); you may not use this file except in compliance with |
|
* the License. You may obtain a copy of the License at |
|
* |
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
* |
|
* Unless required by applicable law or agreed to in writing, software |
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
* See the License for the specific language governing permissions and |
|
* limitations under the License. |
|
*/ |
|
|
|
package com.sun.org.apache.xerces.internal.util; |
|
|
|
import com.sun.org.apache.xerces.internal.dom.AttrImpl; |
|
import com.sun.org.apache.xerces.internal.dom.DocumentImpl; |
|
import com.sun.org.apache.xerces.internal.impl.xs.opti.ElementImpl; |
|
import java.util.Map; |
|
import org.w3c.dom.Attr; |
|
import org.w3c.dom.DOMException; |
|
import org.w3c.dom.Document; |
|
import org.w3c.dom.Element; |
|
import org.w3c.dom.NamedNodeMap; |
|
import org.w3c.dom.Node; |
|
import org.w3c.dom.ls.LSException; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public class DOMUtil { |
|
|
|
// |
|
// Constructors |
|
// |
|
|
|
|
|
protected DOMUtil() {} |
|
|
|
// |
|
// Public static methods |
|
// |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public static void copyInto(Node src, Node dest) throws DOMException { |
|
|
|
|
|
Document factory = dest.getOwnerDocument(); |
|
boolean domimpl = factory instanceof DocumentImpl; |
|
|
|
|
|
Node start = src; |
|
Node parent = src; |
|
Node place = src; |
|
|
|
|
|
while (place != null) { |
|
|
|
|
|
Node node = null; |
|
int type = place.getNodeType(); |
|
switch (type) { |
|
case Node.CDATA_SECTION_NODE: { |
|
node = factory.createCDATASection(place.getNodeValue()); |
|
break; |
|
} |
|
case Node.COMMENT_NODE: { |
|
node = factory.createComment(place.getNodeValue()); |
|
break; |
|
} |
|
case Node.ELEMENT_NODE: { |
|
Element element = factory.createElement(place.getNodeName()); |
|
node = element; |
|
NamedNodeMap attrs = place.getAttributes(); |
|
int attrCount = attrs.getLength(); |
|
for (int i = 0; i < attrCount; i++) { |
|
Attr attr = (Attr)attrs.item(i); |
|
String attrName = attr.getNodeName(); |
|
String attrValue = attr.getNodeValue(); |
|
element.setAttribute(attrName, attrValue); |
|
if (domimpl && !attr.getSpecified()) { |
|
((AttrImpl)element.getAttributeNode(attrName)).setSpecified(false); |
|
} |
|
} |
|
break; |
|
} |
|
case Node.ENTITY_REFERENCE_NODE: { |
|
node = factory.createEntityReference(place.getNodeName()); |
|
break; |
|
} |
|
case Node.PROCESSING_INSTRUCTION_NODE: { |
|
node = factory.createProcessingInstruction(place.getNodeName(), |
|
place.getNodeValue()); |
|
break; |
|
} |
|
case Node.TEXT_NODE: { |
|
node = factory.createTextNode(place.getNodeValue()); |
|
break; |
|
} |
|
default: { |
|
throw new IllegalArgumentException("can't copy node type, "+ |
|
type+" ("+ |
|
place.getNodeName()+')'); |
|
} |
|
} |
|
dest.appendChild(node); |
|
|
|
|
|
if (place.hasChildNodes()) { |
|
parent = place; |
|
place = place.getFirstChild(); |
|
dest = node; |
|
} |
|
|
|
|
|
else { |
|
place = place.getNextSibling(); |
|
while (place == null && parent != start) { |
|
place = parent.getNextSibling(); |
|
parent = parent.getParentNode(); |
|
dest = dest.getParentNode(); |
|
} |
|
} |
|
|
|
} |
|
|
|
} // copyInto(Node,Node) |
|
|
|
|
|
public static Element getFirstChildElement(Node parent) { |
|
|
|
|
|
Node child = parent.getFirstChild(); |
|
while (child != null) { |
|
if (child.getNodeType() == Node.ELEMENT_NODE) { |
|
return (Element)child; |
|
} |
|
child = child.getNextSibling(); |
|
} |
|
|
|
|
|
return null; |
|
|
|
} // getFirstChildElement(Node):Element |
|
|
|
|
|
public static Element getFirstVisibleChildElement(Node parent) { |
|
|
|
|
|
Node child = parent.getFirstChild(); |
|
while (child != null) { |
|
if (child.getNodeType() == Node.ELEMENT_NODE && |
|
!isHidden(child)) { |
|
return (Element)child; |
|
} |
|
child = child.getNextSibling(); |
|
} |
|
|
|
|
|
return null; |
|
|
|
} // getFirstChildElement(Node):Element |
|
|
|
|
|
public static Element getFirstVisibleChildElement(Node parent, Map<Node, String> hiddenNodes) { |
|
|
|
|
|
Node child = parent.getFirstChild(); |
|
while (child != null) { |
|
if (child.getNodeType() == Node.ELEMENT_NODE && |
|
!isHidden(child, hiddenNodes)) { |
|
return (Element)child; |
|
} |
|
child = child.getNextSibling(); |
|
} |
|
|
|
|
|
return null; |
|
|
|
} // getFirstChildElement(Node):Element |
|
|
|
|
|
|
|
*/ |
|
public static Element getLastChildElement(Node parent) { |
|
|
|
|
|
Node child = parent.getLastChild(); |
|
while (child != null) { |
|
if (child.getNodeType() == Node.ELEMENT_NODE) { |
|
return (Element)child; |
|
} |
|
child = child.getPreviousSibling(); |
|
} |
|
|
|
|
|
return null; |
|
|
|
} // getLastChildElement(Node):Element |
|
|
|
|
|
public static Element getLastVisibleChildElement(Node parent) { |
|
|
|
|
|
Node child = parent.getLastChild(); |
|
while (child != null) { |
|
if (child.getNodeType() == Node.ELEMENT_NODE && |
|
!isHidden(child)) { |
|
return (Element)child; |
|
} |
|
child = child.getPreviousSibling(); |
|
} |
|
|
|
|
|
return null; |
|
|
|
} // getLastChildElement(Node):Element |
|
|
|
|
|
|
|
*/ |
|
public static Element getLastVisibleChildElement(Node parent, Map<Node, String> hiddenNodes) { |
|
|
|
|
|
Node child = parent.getLastChild(); |
|
while (child != null) { |
|
if (child.getNodeType() == Node.ELEMENT_NODE && |
|
!isHidden(child, hiddenNodes)) { |
|
return (Element)child; |
|
} |
|
child = child.getPreviousSibling(); |
|
} |
|
|
|
|
|
return null; |
|
|
|
} // getLastChildElement(Node):Element |
|
|
|
public static Element getNextSiblingElement(Node node) { |
|
|
|
|
|
Node sibling = node.getNextSibling(); |
|
while (sibling != null) { |
|
if (sibling.getNodeType() == Node.ELEMENT_NODE) { |
|
return (Element)sibling; |
|
} |
|
sibling = sibling.getNextSibling(); |
|
} |
|
|
|
|
|
return null; |
|
|
|
} // getNextSiblingElement(Node):Element |
|
|
|
|
|
public static Element getNextVisibleSiblingElement(Node node) { |
|
|
|
|
|
Node sibling = node.getNextSibling(); |
|
while (sibling != null) { |
|
if (sibling.getNodeType() == Node.ELEMENT_NODE && |
|
!isHidden(sibling)) { |
|
return (Element)sibling; |
|
} |
|
sibling = sibling.getNextSibling(); |
|
} |
|
|
|
|
|
return null; |
|
|
|
} // getNextSiblingdElement(Node):Element |
|
|
|
|
|
public static Element getNextVisibleSiblingElement(Node node, Map<Node, String> hiddenNodes) { |
|
|
|
|
|
Node sibling = node.getNextSibling(); |
|
while (sibling != null) { |
|
if (sibling.getNodeType() == Node.ELEMENT_NODE && |
|
!isHidden(sibling, hiddenNodes)) { |
|
return (Element)sibling; |
|
} |
|
sibling = sibling.getNextSibling(); |
|
} |
|
|
|
|
|
return null; |
|
|
|
} // getNextSiblingdElement(Node):Element |
|
|
|
|
|
public static void setHidden(Node node) { |
|
if (node instanceof com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl) |
|
((com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl)node).setReadOnly(true, false); |
|
else if (node instanceof com.sun.org.apache.xerces.internal.dom.NodeImpl) |
|
((com.sun.org.apache.xerces.internal.dom.NodeImpl)node).setReadOnly(true, false); |
|
} // setHidden(node):void |
|
|
|
|
|
public static void setHidden(Node node, Map<Node, String> hiddenNodes) { |
|
if (node instanceof com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl) { |
|
((com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl)node).setReadOnly(true, false); |
|
} |
|
else { |
|
hiddenNodes.put(node, ""); |
|
} |
|
} // setHidden(node):void |
|
|
|
|
|
public static void setVisible(Node node) { |
|
if (node instanceof com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl) |
|
((com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl)node).setReadOnly(false, false); |
|
else if (node instanceof com.sun.org.apache.xerces.internal.dom.NodeImpl) |
|
((com.sun.org.apache.xerces.internal.dom.NodeImpl)node).setReadOnly(false, false); |
|
} // setVisible(node):void |
|
|
|
|
|
public static void setVisible(Node node, Map<Node, String> hiddenNodes) { |
|
if (node instanceof com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl) { |
|
((com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl)node).setReadOnly(false, false); |
|
} |
|
else { |
|
hiddenNodes.remove(node); |
|
} |
|
} // setVisible(node):void |
|
|
|
|
|
public static boolean isHidden(Node node) { |
|
if (node instanceof com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl) |
|
return ((com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl)node).getReadOnly(); |
|
else if (node instanceof com.sun.org.apache.xerces.internal.dom.NodeImpl) |
|
return ((com.sun.org.apache.xerces.internal.dom.NodeImpl)node).getReadOnly(); |
|
return false; |
|
} // isHidden(Node):boolean |
|
|
|
|
|
public static boolean isHidden(Node node, Map<Node, String> hiddenNodes) { |
|
if (node instanceof com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl) { |
|
return ((com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl)node).getReadOnly(); |
|
} |
|
else { |
|
return hiddenNodes.containsKey(node); |
|
} |
|
} // isHidden(Node):boolean |
|
|
|
|
|
public static Element getFirstChildElement(Node parent, String elemName) { |
|
|
|
|
|
Node child = parent.getFirstChild(); |
|
while (child != null) { |
|
if (child.getNodeType() == Node.ELEMENT_NODE) { |
|
if (child.getNodeName().equals(elemName)) { |
|
return (Element)child; |
|
} |
|
} |
|
child = child.getNextSibling(); |
|
} |
|
|
|
|
|
return null; |
|
|
|
} // getFirstChildElement(Node,String):Element |
|
|
|
|
|
public static Element getLastChildElement(Node parent, String elemName) { |
|
|
|
|
|
Node child = parent.getLastChild(); |
|
while (child != null) { |
|
if (child.getNodeType() == Node.ELEMENT_NODE) { |
|
if (child.getNodeName().equals(elemName)) { |
|
return (Element)child; |
|
} |
|
} |
|
child = child.getPreviousSibling(); |
|
} |
|
|
|
|
|
return null; |
|
|
|
} // getLastChildElement(Node,String):Element |
|
|
|
|
|
public static Element getNextSiblingElement(Node node, String elemName) { |
|
|
|
|
|
Node sibling = node.getNextSibling(); |
|
while (sibling != null) { |
|
if (sibling.getNodeType() == Node.ELEMENT_NODE) { |
|
if (sibling.getNodeName().equals(elemName)) { |
|
return (Element)sibling; |
|
} |
|
} |
|
sibling = sibling.getNextSibling(); |
|
} |
|
|
|
|
|
return null; |
|
|
|
} // getNextSiblingdElement(Node,String):Element |
|
|
|
|
|
public static Element getFirstChildElementNS(Node parent, |
|
String uri, String localpart) { |
|
|
|
|
|
Node child = parent.getFirstChild(); |
|
while (child != null) { |
|
if (child.getNodeType() == Node.ELEMENT_NODE) { |
|
String childURI = child.getNamespaceURI(); |
|
if (childURI != null && childURI.equals(uri) && |
|
child.getLocalName().equals(localpart)) { |
|
return (Element)child; |
|
} |
|
} |
|
child = child.getNextSibling(); |
|
} |
|
|
|
|
|
return null; |
|
|
|
} // getFirstChildElementNS(Node,String,String):Element |
|
|
|
|
|
public static Element getLastChildElementNS(Node parent, |
|
String uri, String localpart) { |
|
|
|
|
|
Node child = parent.getLastChild(); |
|
while (child != null) { |
|
if (child.getNodeType() == Node.ELEMENT_NODE) { |
|
String childURI = child.getNamespaceURI(); |
|
if (childURI != null && childURI.equals(uri) && |
|
child.getLocalName().equals(localpart)) { |
|
return (Element)child; |
|
} |
|
} |
|
child = child.getPreviousSibling(); |
|
} |
|
|
|
|
|
return null; |
|
|
|
} // getLastChildElementNS(Node,String,String):Element |
|
|
|
|
|
public static Element getNextSiblingElementNS(Node node, |
|
String uri, String localpart) { |
|
|
|
|
|
Node sibling = node.getNextSibling(); |
|
while (sibling != null) { |
|
if (sibling.getNodeType() == Node.ELEMENT_NODE) { |
|
String siblingURI = sibling.getNamespaceURI(); |
|
if (siblingURI != null && siblingURI.equals(uri) && |
|
sibling.getLocalName().equals(localpart)) { |
|
return (Element)sibling; |
|
} |
|
} |
|
sibling = sibling.getNextSibling(); |
|
} |
|
|
|
|
|
return null; |
|
|
|
} // getNextSiblingdElementNS(Node,String,String):Element |
|
|
|
|
|
public static Element getFirstChildElement(Node parent, String elemNames[]) { |
|
|
|
|
|
Node child = parent.getFirstChild(); |
|
while (child != null) { |
|
if (child.getNodeType() == Node.ELEMENT_NODE) { |
|
for (int i = 0; i < elemNames.length; i++) { |
|
if (child.getNodeName().equals(elemNames[i])) { |
|
return (Element)child; |
|
} |
|
} |
|
} |
|
child = child.getNextSibling(); |
|
} |
|
|
|
|
|
return null; |
|
|
|
} // getFirstChildElement(Node,String[]):Element |
|
|
|
|
|
public static Element getLastChildElement(Node parent, String elemNames[]) { |
|
|
|
|
|
Node child = parent.getLastChild(); |
|
while (child != null) { |
|
if (child.getNodeType() == Node.ELEMENT_NODE) { |
|
for (int i = 0; i < elemNames.length; i++) { |
|
if (child.getNodeName().equals(elemNames[i])) { |
|
return (Element)child; |
|
} |
|
} |
|
} |
|
child = child.getPreviousSibling(); |
|
} |
|
|
|
|
|
return null; |
|
|
|
} // getLastChildElement(Node,String[]):Element |
|
|
|
|
|
public static Element getNextSiblingElement(Node node, String elemNames[]) { |
|
|
|
|
|
Node sibling = node.getNextSibling(); |
|
while (sibling != null) { |
|
if (sibling.getNodeType() == Node.ELEMENT_NODE) { |
|
for (int i = 0; i < elemNames.length; i++) { |
|
if (sibling.getNodeName().equals(elemNames[i])) { |
|
return (Element)sibling; |
|
} |
|
} |
|
} |
|
sibling = sibling.getNextSibling(); |
|
} |
|
|
|
|
|
return null; |
|
|
|
} // getNextSiblingdElement(Node,String[]):Element |
|
|
|
|
|
public static Element getFirstChildElementNS(Node parent, |
|
String[][] elemNames) { |
|
|
|
|
|
Node child = parent.getFirstChild(); |
|
while (child != null) { |
|
if (child.getNodeType() == Node.ELEMENT_NODE) { |
|
for (int i = 0; i < elemNames.length; i++) { |
|
String uri = child.getNamespaceURI(); |
|
if (uri != null && uri.equals(elemNames[i][0]) && |
|
child.getLocalName().equals(elemNames[i][1])) { |
|
return (Element)child; |
|
} |
|
} |
|
} |
|
child = child.getNextSibling(); |
|
} |
|
|
|
|
|
return null; |
|
|
|
} // getFirstChildElementNS(Node,String[][]):Element |
|
|
|
|
|
public static Element getLastChildElementNS(Node parent, |
|
String[][] elemNames) { |
|
|
|
|
|
Node child = parent.getLastChild(); |
|
while (child != null) { |
|
if (child.getNodeType() == Node.ELEMENT_NODE) { |
|
for (int i = 0; i < elemNames.length; i++) { |
|
String uri = child.getNamespaceURI(); |
|
if (uri != null && uri.equals(elemNames[i][0]) && |
|
child.getLocalName().equals(elemNames[i][1])) { |
|
return (Element)child; |
|
} |
|
} |
|
} |
|
child = child.getPreviousSibling(); |
|
} |
|
|
|
|
|
return null; |
|
|
|
} // getLastChildElementNS(Node,String[][]):Element |
|
|
|
|
|
public static Element getNextSiblingElementNS(Node node, |
|
String[][] elemNames) { |
|
|
|
|
|
Node sibling = node.getNextSibling(); |
|
while (sibling != null) { |
|
if (sibling.getNodeType() == Node.ELEMENT_NODE) { |
|
for (int i = 0; i < elemNames.length; i++) { |
|
String uri = sibling.getNamespaceURI(); |
|
if (uri != null && uri.equals(elemNames[i][0]) && |
|
sibling.getLocalName().equals(elemNames[i][1])) { |
|
return (Element)sibling; |
|
} |
|
} |
|
} |
|
sibling = sibling.getNextSibling(); |
|
} |
|
|
|
|
|
return null; |
|
|
|
} // getNextSiblingdElementNS(Node,String[][]):Element |
|
|
|
|
|
|
|
|
|
*/ |
|
public static Element getFirstChildElement(Node parent, |
|
String elemName, |
|
String attrName, |
|
String attrValue) { |
|
|
|
|
|
Node child = parent.getFirstChild(); |
|
while (child != null) { |
|
if (child.getNodeType() == Node.ELEMENT_NODE) { |
|
Element element = (Element)child; |
|
if (element.getNodeName().equals(elemName) && |
|
element.getAttribute(attrName).equals(attrValue)) { |
|
return element; |
|
} |
|
} |
|
child = child.getNextSibling(); |
|
} |
|
|
|
|
|
return null; |
|
|
|
} // getFirstChildElement(Node,String,String,String):Element |
|
|
|
|
|
|
|
|
|
*/ |
|
public static Element getLastChildElement(Node parent, |
|
String elemName, |
|
String attrName, |
|
String attrValue) { |
|
|
|
|
|
Node child = parent.getLastChild(); |
|
while (child != null) { |
|
if (child.getNodeType() == Node.ELEMENT_NODE) { |
|
Element element = (Element)child; |
|
if (element.getNodeName().equals(elemName) && |
|
element.getAttribute(attrName).equals(attrValue)) { |
|
return element; |
|
} |
|
} |
|
child = child.getPreviousSibling(); |
|
} |
|
|
|
|
|
return null; |
|
|
|
} // getLastChildElement(Node,String,String,String):Element |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public static Element getNextSiblingElement(Node node, |
|
String elemName, |
|
String attrName, |
|
String attrValue) { |
|
|
|
|
|
Node sibling = node.getNextSibling(); |
|
while (sibling != null) { |
|
if (sibling.getNodeType() == Node.ELEMENT_NODE) { |
|
Element element = (Element)sibling; |
|
if (element.getNodeName().equals(elemName) && |
|
element.getAttribute(attrName).equals(attrValue)) { |
|
return element; |
|
} |
|
} |
|
sibling = sibling.getNextSibling(); |
|
} |
|
|
|
|
|
return null; |
|
|
|
} // getNextSiblingElement(Node,String,String,String):Element |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public static String getChildText(Node node) { |
|
|
|
|
|
if (node == null) { |
|
return null; |
|
} |
|
|
|
|
|
StringBuffer str = new StringBuffer(); |
|
Node child = node.getFirstChild(); |
|
while (child != null) { |
|
short type = child.getNodeType(); |
|
if (type == Node.TEXT_NODE) { |
|
str.append(child.getNodeValue()); |
|
} |
|
else if (type == Node.CDATA_SECTION_NODE) { |
|
str.append(getChildText(child)); |
|
} |
|
child = child.getNextSibling(); |
|
} |
|
|
|
|
|
return str.toString(); |
|
|
|
} // getChildText(Node):String |
|
|
|
|
|
public static String getName(Node node) { |
|
return node.getNodeName(); |
|
} // getLocalName(Element): String |
|
|
|
|
|
|
|
*/ |
|
public static String getLocalName(Node node) { |
|
String name = node.getLocalName(); |
|
return (name!=null)? name:node.getNodeName(); |
|
} // getLocalName(Element): String |
|
|
|
public static Element getParent(Element elem) { |
|
Node parent = elem.getParentNode(); |
|
if (parent instanceof Element) |
|
return (Element)parent; |
|
return null; |
|
} // getParent(Element):Element |
|
|
|
|
|
public static Document getDocument(Node node) { |
|
return node.getOwnerDocument(); |
|
} // getDocument(Node):Document |
|
|
|
|
|
public static Element getRoot(Document doc) { |
|
return doc.getDocumentElement(); |
|
} // getRoot(Document(: Element |
|
|
|
// some methods for handling attributes: |
|
|
|
|
|
public static Attr getAttr(Element elem, String name) { |
|
return elem.getAttributeNode(name); |
|
} // getAttr(Element, String):Attr |
|
|
|
|
|
public static Attr getAttrNS(Element elem, String nsUri, |
|
String localName) { |
|
return elem.getAttributeNodeNS(nsUri, localName); |
|
} // getAttrNS(Element, String):Attr |
|
|
|
|
|
public static Attr[] getAttrs(Element elem) { |
|
NamedNodeMap attrMap = elem.getAttributes(); |
|
Attr [] attrArray = new Attr[attrMap.getLength()]; |
|
for (int i=0; i<attrMap.getLength(); i++) |
|
attrArray[i] = (Attr)attrMap.item(i); |
|
return attrArray; |
|
} // getAttrs(Element): Attr[] |
|
|
|
|
|
public static String getValue(Attr attribute) { |
|
return attribute.getValue(); |
|
} // getValue(Attr):String |
|
|
|
// It is noteworthy that, because of the way the DOM specs |
|
// work, the next two methods return the empty string (not |
|
// null!) when the attribute with the specified name does not |
|
// exist on an element. Beware! |
|
|
|
// return the value of the attribute of the given element |
|
|
|
public static String getAttrValue(Element elem, String name) { |
|
return elem.getAttribute(name); |
|
} // getAttr(Element, String):Attr |
|
|
|
// return the value of the attribute of the given element |
|
|
|
public static String getAttrValueNS(Element elem, String nsUri, |
|
String localName) { |
|
return elem.getAttributeNS(nsUri, localName); |
|
} // getAttrValueNS(Element, String):Attr |
|
|
|
|
|
public static String getPrefix(Node node) { |
|
return node.getPrefix(); |
|
} |
|
|
|
|
|
public static String getNamespaceURI(Node node) { |
|
return node.getNamespaceURI(); |
|
} |
|
|
|
|
|
public static String getAnnotation(Node node) { |
|
if (node instanceof ElementImpl) { |
|
return ((ElementImpl)node).getAnnotation(); |
|
} |
|
return null; |
|
} |
|
|
|
|
|
public static String getSyntheticAnnotation(Node node) { |
|
if (node instanceof ElementImpl) { |
|
return ((ElementImpl)node).getSyntheticAnnotation(); |
|
} |
|
return null; |
|
} |
|
|
|
|
|
|
|
*/ |
|
public static DOMException createDOMException(short code, Throwable cause) { |
|
DOMException de = new DOMException(code, cause != null ? cause.getMessage() : null); |
|
if (cause != null) de.initCause(cause); |
|
return de; |
|
} |
|
|
|
|
|
|
|
*/ |
|
public static LSException createLSException(short code, Throwable cause) { |
|
LSException lse = new LSException(code, cause != null ? cause.getMessage() : null); |
|
if (cause != null) lse.initCause(cause); |
|
return lse; |
|
} |
|
|
|
} // class DOMUtil |