1 17 package org.apache.servicemix.jbi.jaxp; 18 19 import javax.xml.namespace.NamespaceContext ; 20 import javax.xml.namespace.QName ; 21 22 25 public class QNameHelper { 26 27 public static String getQualifiedName(QName qname) { 28 String prefix = qname.getPrefix(); 29 String localPart = qname.getLocalPart(); 30 if (prefix != null && prefix.length() > 0) { 31 return prefix + ":" + localPart; 32 } 33 return localPart; 34 } 35 36 39 public static QName asQName(NamespaceContext context, String text) { 40 int idx = text.indexOf(':'); 41 if (idx >= 0) { 42 String prefix = text.substring(0, idx); 43 String localPart = text.substring(idx + 1); 44 String uri = context.getNamespaceURI(prefix); 45 return new QName (uri, localPart, prefix); 46 } 47 else { 48 return new QName (text); 49 } 50 } 51 } 52 | Popular Tags |