当前位置: 首页>>代码示例>>Java>>正文


Java Node.getNamespaceURI方法代码示例

本文整理汇总了Java中org.w3c.dom.Node.getNamespaceURI方法的典型用法代码示例。如果您正苦于以下问题:Java Node.getNamespaceURI方法的具体用法?Java Node.getNamespaceURI怎么用?Java Node.getNamespaceURI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.w3c.dom.Node的用法示例。


在下文中一共展示了Node.getNamespaceURI方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFirstChildElementNS

import org.w3c.dom.Node; //导入方法依赖的package包/类
/** Finds and returns the first child node with the given qualified name. */
public static Element getFirstChildElementNS(Node parent,
        String uri, String localpart) {

    // search for node
    Node child = parent.getFirstChild();
    while (child != null) {
        if (child.getNodeType() == Node.ELEMENT_NODE) {
            String childURI = child.getNamespaceURI();
            if (childURI != null && childURI.equals(uri) &&
                    child.getLocalName().equals(localpart)) {
                return (Element)child;
            }
        }
        child = child.getNextSibling();
    }

    // not found
    return null;

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:DOMUtil.java

示例2: decorateIfRequired

import org.w3c.dom.Node; //导入方法依赖的package包/类
public static BeanDefinitionHolder decorateIfRequired(Node node, BeanDefinitionHolder originalDef,
		ParserContext parserContext) {

	String namespaceUri = node.getNamespaceURI();
	if (!parserContext.getDelegate().isDefaultNamespace(namespaceUri) && !isRFC124Namespace(namespaceUri)) {
		NamespaceHandler handler =
				parserContext.getReaderContext().getNamespaceHandlerResolver().resolve(namespaceUri);
		if (handler != null) {
			return handler.decorate(node, originalDef, new ParserContext(parserContext.getReaderContext(),
					parserContext.getDelegate()));
		} else if (namespaceUri.startsWith("http://www.springframework.org/")) {
			parserContext.getReaderContext().error(
					"Unable to locate Spring NamespaceHandler for XML schema namespace [" + namespaceUri + "]",
					node);
		} else {
			// A custom namespace, not to be handled by Spring - maybe "xml:...".
		}
	}
	return originalDef;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:21,代码来源:ParsingUtils.java

示例3: getLastChildElementNS

import org.w3c.dom.Node; //导入方法依赖的package包/类
/** Finds and returns the last child node with the given qualified name. */
public static Element getLastChildElementNS(Node parent,
        String uri, String localpart) {

    // search for node
    Node child = parent.getLastChild();
    while (child != null) {
        if (child.getNodeType() == Node.ELEMENT_NODE) {
            String childURI = child.getNamespaceURI();
            if (childURI != null && childURI.equals(uri) &&
                    child.getLocalName().equals(localpart)) {
                return (Element)child;
            }
        }
        child = child.getPreviousSibling();
    }

    // not found
    return null;

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:DOMUtil.java

示例4: parseProjectFiles

import org.w3c.dom.Node; //导入方法依赖的package包/类
private String[] parseProjectFiles(Node projectFilesNode) {
    ArrayList<String> paths = new ArrayList<String>();

    if (projectFilesNode != null) {
        String nsUri = projectFilesNode.getNamespaceURI();
        for(Node child = projectFilesNode.getFirstChild();
                 child != null;
                 child = child.getNextSibling()) {

            if (child.getNodeType() == Node.ELEMENT_NODE &&
                    nsUri.equals(child.getNamespaceURI()) &&
                    RepoConstants.NODE_PATH.equals(child.getLocalName())) {
                String path = child.getTextContent();
                if (path != null) {
                    path = path.trim();
                    if (path.length() > 0) {
                        paths.add(path);
                    }
                }
            }
        }
    }

    return paths.toArray(new String[paths.size()]);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:26,代码来源:ExtraPackage.java

示例5: if

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 *
 * @param listVector
 * @param tempNode
 * @param namespaceURI
 * @param localname
 * @param isNamespaceURIWildCard
 * @param isLocalNameWildCard
 *
 * Private method to be used for recursive iterations to obtain elements by tag name
 * and namespaceURI.
 */
private final void traverseChildren
(
 Vector listVector,
 Node tempNode,
 String namespaceURI,
 String localname,
 boolean isNamespaceURIWildCard,
 boolean isLocalNameWildCard)
 {
  if (tempNode == null)
  {
    return;
  }
  else
  {
    if (tempNode.getNodeType() == DTM.ELEMENT_NODE
            && (isLocalNameWildCard
                    || tempNode.getLocalName().equals(localname)))
    {
      String nsURI = tempNode.getNamespaceURI();
      if ((namespaceURI == null && nsURI == null)
             || isNamespaceURIWildCard
             || (namespaceURI != null && namespaceURI.equals(nsURI)))
      {
        listVector.add(tempNode);
      }
    }
    if(tempNode.hasChildNodes())
    {
      NodeList nl = tempNode.getChildNodes();
      for(int i = 0; i < nl.getLength(); i++)
      {
        traverseChildren(listVector, nl.item(i), namespaceURI, localname,
                         isNamespaceURIWildCard, isLocalNameWildCard);
      }
    }
  }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:51,代码来源:DTMNodeProxy.java

示例6: getIndex

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Look up the index of an attribute by Namespace name.
 *
 * @param uri The Namespace URI, or the empty string if
 *        the name has no Namespace URI.
 * @param localPart The attribute's local name.
 * @return The index of the attribute, or -1 if it does not
 *         appear in the list.
 */
public int getIndex(String uri, String localPart)
{
  for(int i=m_attrs.getLength()-1;i>=0;--i)
  {
    Node a=m_attrs.item(i);
    String u=a.getNamespaceURI();
    if( (u==null ? uri==null : u.equals(uri))
        &&
        a.getLocalName().equals(localPart) )
      return i;
  }
  return -1;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:AttList.java

示例7: spreadNamespaces

import org.w3c.dom.Node; //导入方法依赖的package包/类
public static void spreadNamespaces(Node node, String tns, boolean overwrite) {
	Document doc = node instanceof Document ? (Document) node : node.getOwnerDocument();
	boolean isParent = false;
	while (node != null) {
		Node next = null;
		if (!isParent && node.getNodeType() == Node.ELEMENT_NODE) {
			if (node.getNamespaceURI() == null) {
				node = doc.renameNode(node, tns, node.getNodeName());
			} else {
				if (overwrite) {
					tns = node.getNamespaceURI();
				}
			}
			NamedNodeMap nodeMap = node.getAttributes();
			int nodeMapLengthl = nodeMap.getLength();
			for (int i = 0; i < nodeMapLengthl; i++) {
				Node attr = nodeMap.item(i);
				if (attr.getNamespaceURI() == null) {
					doc.renameNode(attr, tns, attr.getNodeName());
				}
			}
		}
		isParent = (isParent || (next = node.getFirstChild()) == null) && (next = node.getNextSibling()) == null;
		node = isParent ? node.getParentNode() : next;
		if (isParent && node != null) {
			if (overwrite) {
				tns = node.getNamespaceURI();
			}
		}
	}
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:32,代码来源:XMLUtils.java

示例8: selectNode

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * @param sibling
 * @param uri
 * @param nodeName
 * @param number
 * @return nodes with the constrain
 */
public static Element selectNode(Node sibling, String uri, String nodeName, int number) {
    while (sibling != null) {
        if (sibling.getNamespaceURI() != null && sibling.getNamespaceURI().equals(uri)
            && sibling.getLocalName().equals(nodeName)) {
            if (number == 0){
                return (Element)sibling;
            }
            number--;
        }
        sibling = sibling.getNextSibling();
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:XMLUtils.java

示例9: getIndex

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Look up the index of an attribute by Namespace name.
 *
 * @param uri The Namespace URI, or the empty string if
 *        the name has no Namespace URI.
 * @param localPart The attribute's local name.
 * @return The index of the attribute, or -1 if it does not
 *         appear in the list.
 */
public int getIndex(String uri, String localPart)
{
  for(int i=m_attrs.getLength()-1;i>=0;--i)
  {
    Node a=m_attrs.item(i);
    String u=a.getNamespaceURI();
    if( (u==null ? uri==null : u.equals(uri))
    &&
    a.getLocalName().equals(localPart) )
  return i;
  }
  return -1;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:AttList.java

示例10: lookupNamespaceURI

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Looks up the namespace URI associated with the given prefix starting at the given element. This method differs
 * from the {@link Node#lookupNamespaceURI(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 prefix the prefix to look up
 * 
 * @return the namespace URI for the given prefer or null
 */
public static String lookupNamespaceURI(Element startingElement, Element stopingElement, String prefix) {
    String namespaceURI;

    // 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();
            namespaceURI = attr.getNamespaceURI();
            if (namespaceURI != null && namespaceURI.equals(XMLConstants.XMLNS_NS)) {
                // at this point we are dealing with DOM Level 2 nodes only
                if (prefix == null && attr.getNodeName().equals(XMLConstants.XMLNS_PREFIX)) {
                    // default namespace
                    return value;
                } else if (attrPrefix != null && attrPrefix.equals(XMLConstants.XMLNS_PREFIX)
                        && attr.getLocalName().equals(prefix)) {
                    // non default namespace
                    return value;
                }
            }
        }
    }

    if (startingElement != stopingElement) {
        Element ancestor = getElementAncestor(startingElement);
        if (ancestor != null) {
            return lookupNamespaceURI(ancestor, stopingElement, prefix);
        }
    }

    return null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:50,代码来源:XMLHelper.java

示例11: lookupPrefix

import org.w3c.dom.Node; //导入方法依赖的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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:53,代码来源:XMLHelper.java

示例12: updateQName

import org.w3c.dom.Node; //导入方法依赖的package包/类
protected final void updateQName (Node node, QName qname){

        String prefix    = node.getPrefix();
        String namespace = node.getNamespaceURI();
        String localName = node.getLocalName();
        // REVISIT: the symbols are added too often: start/endElement
        //          and in the namespaceFixup. Should reduce number of calls to symbol table.
        qname.prefix = (prefix!=null && prefix.length()!=0)?fSymbolTable.addSymbol(prefix):null;
        qname.localpart = (localName != null)?fSymbolTable.addSymbol(localName):null;
        qname.rawname = fSymbolTable.addSymbol(node.getNodeName());
        qname.uri =  (namespace != null)?fSymbolTable.addSymbol(namespace):null;
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:DOMNormalizer.java

示例13: createException

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * This should be called from the client side to throw an {@link Exception} for a given soap mesage
 */
public Throwable createException(Map<QName, CheckedExceptionImpl> exceptions) throws JAXBException {
    DetailType dt = getDetail();
    Node detail = null;
    if(dt != null)  detail = dt.getDetail(0);

    //return ProtocolException if the detail is not present or there is no checked exception
    if(detail == null || exceptions == null){
        // No soap detail, doesnt look like its a checked exception
        // throw a protocol exception
        return attachServerException(getProtocolException());
    }

    //check if the detail is a checked exception, if not throw a ProtocolException
    QName detailName = new QName(detail.getNamespaceURI(), detail.getLocalName());
    CheckedExceptionImpl ce = exceptions.get(detailName);
    if (ce == null) {
        //No Checked exception for the received detail QName, throw a SOAPFault exception
        return attachServerException(getProtocolException());

    }

    if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
        return attachServerException(createUserDefinedException(ce));

    }
    Class exceptionClass = ce.getExceptionClass();
    try {
        Constructor constructor = exceptionClass.getConstructor(String.class, (Class) ce.getDetailType().type);
        Exception exception = (Exception) constructor.newInstance(getFaultString(), getJAXBObject(detail, ce));
        return attachServerException(exception);
    } catch (Exception e) {
        throw new WebServiceException(e);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:SOAPFaultBuilder.java

示例14: selectNodes

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * @param sibling
 * @param uri
 * @param nodeName
 * @return nodes with the constraint
 */
public static Element[] selectNodes(Node sibling, String uri, String nodeName) {
    List<Element> list = new ArrayList<Element>();
    while (sibling != null) {
        if (sibling.getNamespaceURI() != null && sibling.getNamespaceURI().equals(uri)
            && sibling.getLocalName().equals(nodeName)) {
            list.add((Element)sibling);
        }
        sibling = sibling.getNextSibling();
    }
    return list.toArray(new Element[list.size()]);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:XMLUtils.java

示例15: getNamespaceForPrefix

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Given a namespace, get the corrisponding prefix.
 * Warning: This will not work correctly if namespaceContext
 * is an attribute node.
 * @param prefix Prefix to resolve.
 * @param namespaceContext Node from which to start searching for a
 * xmlns attribute that binds a prefix to a namespace.
 * @return Namespace that prefix resolves to, or null if prefix
 * is not bound.
 */
public String getNamespaceForPrefix(String prefix,
                                    org.w3c.dom.Node namespaceContext)
{

  Node parent = namespaceContext;
  String namespace = null;

  if (prefix.equals("xml"))
  {
    namespace = Constants.S_XMLNAMESPACEURI;
  }
  else
  {
    int type;

    while ((null != parent) && (null == namespace)
           && (((type = parent.getNodeType()) == Node.ELEMENT_NODE)
               || (type == Node.ENTITY_REFERENCE_NODE)))
    {
      if (type == Node.ELEMENT_NODE)
      {
              if (parent.getNodeName().indexOf(prefix+":") == 0)
                      return parent.getNamespaceURI();
        NamedNodeMap nnm = parent.getAttributes();

        for (int i = 0; i < nnm.getLength(); i++)
        {
          Node attr = nnm.item(i);
          String aname = attr.getNodeName();
          boolean isPrefix = aname.startsWith("xmlns:");

          if (isPrefix || aname.equals("xmlns"))
          {
            int index = aname.indexOf(':');
            String p = isPrefix ? aname.substring(index + 1) : "";

            if (p.equals(prefix))
            {
              namespace = attr.getNodeValue();

              break;
            }
          }
        }
      }

      parent = parent.getParentNode();
    }
  }

  return namespace;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:63,代码来源:PrefixResolverDefault.java


注:本文中的org.w3c.dom.Node.getNamespaceURI方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。