本文整理汇总了Java中org.w3c.dom.Element.lookupNamespaceURI方法的典型用法代码示例。如果您正苦于以下问题:Java Element.lookupNamespaceURI方法的具体用法?Java Element.lookupNamespaceURI怎么用?Java Element.lookupNamespaceURI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.w3c.dom.Element
的用法示例。
在下文中一共展示了Element.lookupNamespaceURI方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseParameter
import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
* @param context
* @param jaxwsBinding
* @param e
*/
private void parseParameter(com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext context, JAXWSBinding jaxwsBinding, Element e) {
String part = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.PART_ATTR);
Element msgPartElm = evaluateXPathNode(e.getOwnerDocument(), part, new NamespaceContextImpl(e));
Node msgElm = msgPartElm.getParentNode();
//MessagePart msgPart = new MessagePart();
String partName = XmlUtil.getAttributeOrNull(msgPartElm, "name");
String msgName = XmlUtil.getAttributeOrNull((Element)msgElm, "name");
if ((partName == null) || (msgName == null)) {
return;
}
String element = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.ELEMENT_ATTR);
String name = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.NAME_ATTR);
QName elementName = null;
if(element != null){
String uri = e.lookupNamespaceURI(XmlUtil.getPrefix(element));
elementName = (uri == null)?null:new QName(uri, XmlUtil.getLocalPart(element));
}
jaxwsBinding.addParameter(new Parameter(msgName, partName, elementName, name));
}
示例2: lookupPrefix
import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
* Looks up the namespace prefix associated with the given URI starting at the given element. This method differs
* from the {@link Node#lookupPrefix(java.lang.String)} in that it only those namespaces declared by an xmlns
* attribute are inspected. The Node method also checks the namespace a particular node was created in by way of a
* call like {@link Document#createElementNS(java.lang.String, java.lang.String)} even if the resulting element
* doesn't have an namespace delcaration attribute.
*
* @param startingElement the starting element
* @param stopingElement the ancestor of the starting element that serves as the upper-bound, inclusive, for the
* search
* @param namespaceURI the uri to look up
*
* @return the prefix for the given namespace URI
*/
public static String lookupPrefix(Element startingElement, Element stopingElement, String namespaceURI) {
String namespace;
// This code is a modified version of the lookup code within Xerces
if (startingElement.hasAttributes()) {
NamedNodeMap map = startingElement.getAttributes();
int length = map.getLength();
for (int i = 0; i < length; i++) {
Node attr = map.item(i);
String attrPrefix = attr.getPrefix();
String value = attr.getNodeValue();
namespace = attr.getNamespaceURI();
if (namespace != null && namespace.equals(XMLConstants.XMLNS_NS)) {
// DOM Level 2 nodes
if (attr.getNodeName().equals(XMLConstants.XMLNS_PREFIX)
|| (attrPrefix != null && attrPrefix.equals(XMLConstants.XMLNS_PREFIX))
&& value.equals(namespaceURI)) {
String localname = attr.getLocalName();
String foundNamespace = startingElement.lookupNamespaceURI(localname);
if (foundNamespace != null && foundNamespace.equals(namespaceURI)) {
return localname;
}
}
}
}
}
if (startingElement != stopingElement) {
Element ancestor = getElementAncestor(startingElement);
if (ancestor != null) {
return lookupPrefix(ancestor, stopingElement, namespaceURI);
}
}
return null;
}