diff options
Diffstat (limited to 'java/sca/modules/common-xml/src')
-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(); |