/** * DOCUMENTME * * @param el DOCUMENTME * @param attrName DOCUMENTME * * @return DOCUMENTME * * @throws IllegalArgumentException DOCUMENTME */ public static QName getQualifiedAttributeValue(Element el, String attrName) throws IllegalArgumentException { String attrValue = DOMUtils.getAttribute(el, attrName); if (attrValue != null) { int index = attrValue.indexOf(':'); String attrValuePrefix = (index != -1) ? attrValue.substring(0, index) : null; String attrValueLocalPart = attrValue.substring(index + 1); String attrValueNamespaceURI = DOMUtils.getNamespaceURIFromPrefix(el, attrValuePrefix); if (attrValueNamespaceURI != null) { return new QName(attrValueNamespaceURI, attrValueLocalPart); } throw new IllegalArgumentException("Unable to determine " + "namespace of '" + ((attrValuePrefix != null) ? (attrValuePrefix + ":") : "") + attrValueLocalPart + "'."); } return null; }
/** * Dereference a qualified name given in the "ns:name" form using the namespace * context of a given element. * * @param prefixedQNameStr qualified name, represented as a prefixed string * @param context context element * @return a resolved {@link QName} * @throws javax.wsdl.WSDLException in case of resolution error (e.g. undefined prefix) */ protected static QName derefQName(String prefixedQNameStr, Element context) throws WSDLException { int idx = prefixedQNameStr.indexOf(":"); String uri; if (idx == -1) { uri = DOMUtils.getNamespaceURIFromPrefix(context, null); } else { if (idx >= prefixedQNameStr.length() || idx == 0) { String msg = __msgs.msgMalformedQName(prefixedQNameStr); throw new WSDLException(WSDLException.INVALID_WSDL, msg); } // Look up the prefix from the namespaces defined *at the element*. String prefix = prefixedQNameStr.substring(0, idx); uri = DOMUtils.getMyNSContext(context).getNamespaceURI(prefix); if (uri == null) { String msg = __msgs.msgInvalidNamespacePrefix(prefix); throw new WSDLException(WSDLException.INVALID_WSDL, msg); } } return new QName(uri, prefixedQNameStr.substring(idx + 1, prefixedQNameStr.length())); }