diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-09-15 20:37:43 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-09-15 20:37:43 +0000 |
commit | ea993d0e259bf29c71a1307492bccfccf180293d (patch) | |
tree | 1802095b138b29b34d84b59349480592feccef87 | |
parent | 9d483666f17e13515e55e26a43d8e875c77569ae (diff) |
Add methods to DOMHelper to deal with namespace/prefix lookups
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@815472 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | java/sca/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/dom/DOMHelper.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/java/sca/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/dom/DOMHelper.java b/java/sca/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/dom/DOMHelper.java index 3c3a2f2097..f2f63e80c6 100644 --- a/java/sca/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/dom/DOMHelper.java +++ b/java/sca/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/dom/DOMHelper.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; +import javax.xml.XMLConstants; import javax.xml.namespace.QName; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -207,6 +208,20 @@ public class DOMHelper { } return doc; } + + public static String getPrefix(Element element, String namespace) { + if (element.isDefaultNamespace(namespace)) { + return XMLConstants.DEFAULT_NS_PREFIX; + } + return element.lookupPrefix(namespace); + } + + public static String getNamespaceURI(Element element, String prefix) { + if (XMLConstants.DEFAULT_NS_PREFIX.equals(prefix)) { + prefix = null; + } + return element.lookupNamespaceURI(prefix); + } public static interface NodeContentHandler extends ContentHandler, LexicalHandler { Node getNode(); |