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


Java Element.getParentNode方法代码示例

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


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

示例1: startElement

import org.w3c.dom.Element; //导入方法依赖的package包/类
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) {
    super.startElement(namespaceURI, localName, qName, atts);

    Element e = getCurrentElement();
    locatorTable.storeStartLocation( e, locator );

    // check if this element is an outer-most <jaxb:bindings>
    if( Const.JAXB_NSURI.equals(e.getNamespaceURI())
    &&  "bindings".equals(e.getLocalName()) ) {

        // if this is the root node (meaning that this file is an
        // external binding file) or if the parent is XML Schema element
        // (meaning that this is an "inlined" external binding)
        Node p = e.getParentNode();
        if( p instanceof Document
        ||( p instanceof Element && !e.getNamespaceURI().equals(p.getNamespaceURI()))) {
            outerMostBindings.add(e);   // remember this value
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:DOMBuilder.java

示例2: traverseLevel

import org.w3c.dom.Element; //导入方法依赖的package包/类
private static void traverseLevel(TreeWalker walker, Element topParent, String indent) {
    // describe current node:
    Element current = (Element) walker.getCurrentNode();
    //System.out.println(indent + "- " + ((Element) current).getTagName());
    
    // store elements which need to be moved
    if (topParent != null) {
    	Element parent = (Element) current.getParentNode();
    	if (parent != null && !topParent.equals(parent)) {
    	    OutputFilter outputFilter = (OutputFilter)walker.getFilter();
    		outputFilter.getToAddList(topParent).add(current);
    	}
    }
    
    // traverse children:
    for (Node n = walker.firstChild(); n != null; n = walker.nextSibling()) {
      traverseLevel(walker, current, indent + '\t');
    }
    
    // return position to the current (level up):
    walker.setCurrentNode(current);
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:23,代码来源:Sequence.java

示例3: getAttributeWithInheritance

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Returns an attribute value from this node, or first parent node with this attribute defined
 *
 * @return A non-zero-length value if defined, otherwise null
 */
public static String getAttributeWithInheritance(Element element, String attributeName) {
  String result = element.getAttribute(attributeName);
  if ((result == null) || ("".equals(result))) {
    Node n = element.getParentNode();
    if ((n == element) || (n == null)) {
      return null;
    }
    if (n instanceof Element) {
      Element parent = (Element) n;
      return getAttributeWithInheritance(parent, attributeName);
    }
    return null; //we reached the top level of the document without finding attribute
  }
  return result;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:DOMUtils.java

示例4: startElement

import org.w3c.dom.Element; //导入方法依赖的package包/类
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) {
    super.startElement(namespaceURI, localName, qName, atts);

    Element e = getCurrentElement();
    locatorTable.storeStartLocation( e, locator );

    // check if this element is an outer-most <jaxb:bindings>
    if( JAXWSBindingsConstants.JAXWS_BINDINGS.getNamespaceURI().equals(e.getNamespaceURI())
    &&  "bindings".equals(e.getLocalName()) ) {

        // if this is the root node (meaning that this file is an
        // external binding file) or if the parent is XML Schema element
        // (meaning that this is an "inlined" external binding)
        Node p = e.getParentNode();
        if( p instanceof Document) {
            outerMostBindings.add(e);   // remember this value
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:DOMBuilder.java

示例5: getIdentifier

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Returns a previously registered element with the specified
 * identifier name, or null if no element is registered.
 *
 * @see #putIdentifier
 * @see #removeIdentifier
 */
public Element getIdentifier(String idName) {

    if (needsSyncData()) {
        synchronizeData();
    }

    if (identifiers == null) {
        return null;
    }
    Element elem = (Element) identifiers.get(idName);
    if (elem != null) {
        // check that the element is in the tree
        Node parent = elem.getParentNode();
        while (parent != null) {
            if (parent == this) {
                return elem;
            }
            parent = parent.getParentNode();
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:CoreDocumentImpl.java

示例6: test

import org.w3c.dom.Element; //导入方法依赖的package包/类
@Override
public boolean test(Element start, Element root) {
    if (start == root) {
        return false;
    }
    Node parent = start.getParentNode();
    if (parent == root) {
        return false;
    }
    Element element = (Element)parent;
    return test(element) && testPrevious(element, root);
}
 
开发者ID:i49,项目名称:cascade,代码行数:13,代码来源:ChildSequence.java

示例7: filterProjectXML

import org.w3c.dom.Element; //导入方法依赖的package包/类
private static void filterProjectXML(FileObject fo, ZipInputStream str, String name) throws IOException {
    try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        FileUtil.copy(str, baos);
        Document doc = XMLUtil.parse(new InputSource(new ByteArrayInputStream(baos.toByteArray())), false, false, null, null);
        NodeList nl = doc.getDocumentElement().getElementsByTagName("name");
        if (nl != null) {
            for (int i = 0; i < nl.getLength(); i++) {
                Element el = (Element) nl.item(i);
                if (el.getParentNode() != null && "data".equals(el.getParentNode().getNodeName())) {
                    NodeList nl2 = el.getChildNodes();
                    if (nl2.getLength() > 0) {
                        nl2.item(0).setNodeValue(name);
                    }
                    break;
                }
            }
        }
        OutputStream out = fo.getOutputStream();
        try {
            XMLUtil.write(doc, out, "UTF-8");
        } finally {
            out.close();
        }
    } catch (Exception ex) {
        Exceptions.printStackTrace(ex);
        writeFile(str, fo);
    }

}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:31,代码来源:ExampleBotProjectWizardIterator.java

示例8: removeNodeSpi

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Removes this node from the backing store. Please note that, though the 
 * AbstractPreferences method signature defines that this method should 
 * throw a BackingStoreException, this implementation doesn't.
 */
protected void removeNodeSpi() throws BackingStoreException {
	org.w3c.dom.Node root = AIPreferencesController.getInstance().getXMLDocument().getDocumentElement();
	Element myNode = myXMLNode();
	Element parentNode = (Element)myNode.getParentNode();
	
	if(root.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
		Element docRoot = (Element) root;
		
		parentNode.removeChild(myNode);
	}	
}
 
开发者ID:guilhebl,项目名称:routerapp,代码行数:17,代码来源:AIXMLPreferences.java

示例9: test

import org.w3c.dom.Element; //导入方法依赖的package包/类
@Override
public boolean test(Element start, Element root) {
    if (start == root) {
        return false;
    }
    Node parent = start.getParentNode();
    while (parent != root) {
        Element element = (Element)parent;
        if (test(element) && testPrevious(element, root)) {
            return true;
        }
        parent = parent.getParentNode();
    }
    return false;
}
 
开发者ID:i49,项目名称:cascade,代码行数:16,代码来源:DescendantSequence.java

示例10: filterProjectXML

import org.w3c.dom.Element; //导入方法依赖的package包/类
private static void filterProjectXML(FileObject fo, ZipInputStream str, String name) throws IOException {
    try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        FileUtil.copy(str, baos);
        Document doc = XMLUtil.parse(new InputSource(new ByteArrayInputStream(baos.toByteArray())), false, false, null, null);
        NodeList nl = doc.getDocumentElement().getElementsByTagName("name");
        if (nl != null) {
            for (int i = 0; i < nl.getLength(); i++) {
                Element el = (Element) nl.item(i);
                if (el.getParentNode() != null && "data".equals(el.getParentNode().getNodeName())) {
                    NodeList nl2 = el.getChildNodes();
                    if (nl2.getLength() > 0) {
                        nl2.item(0).setNodeValue(name);
                    }
                    break;
                }
            }
        }
        try (OutputStream out = fo.getOutputStream()) {
            XMLUtil.write(doc, out, "UTF-8");
        }
    } catch (IOException | DOMException | SAXException ex) {
        Exceptions.printStackTrace(ex);
        writeFile(str, fo);
    }

}
 
开发者ID:onekosha,项目名称:nb-clojure,代码行数:28,代码来源:ClojureTemplateWizardIterator.java

示例11: postGetDocument

import org.w3c.dom.Element; //导入方法依赖的package包/类
@Override
public Object postGetDocument(Document document) throws Exception {
	NodeList attachs = document.getDocumentElement().getElementsByTagName("attachment");
	if (attachs != null) 
		for(int i=attachs.getLength()-1;i>=0;i--){
			Element attach = (Element)attachs.item(i);
			if (attach.getParentNode()==attach.getOwnerDocument().getDocumentElement())
				return AttachmentManager.getAttachment(attach);
		}
	return null;
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:12,代码来源:BinaryServletRequester.java

示例12: getParentNameSpaces

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Adds to ns the definitions from the parent elements of el
 * @param el
 * @param ns
 */
protected final void getParentNameSpaces(Element el, NameSpaceSymbTable ns)  {
    Node n1 = el.getParentNode();
    if (n1 == null || Node.ELEMENT_NODE != n1.getNodeType()) {
        return;
    }
    //Obtain all the parents of the element
    List<Element> parents = new ArrayList<Element>();
    Node parent = n1;
    while (parent != null && Node.ELEMENT_NODE == parent.getNodeType()) {
        parents.add((Element)parent);
        parent = parent.getParentNode();
    }
    //Visit them in reverse order.
    ListIterator<Element> it = parents.listIterator(parents.size());
    while (it.hasPrevious()) {
        Element ele = it.previous();
        handleParent(ele, ns);
    }
    parents.clear();
    Attr nsprefix;
    if (((nsprefix = ns.getMappingWithoutRendered(XMLNS)) != null)
            && "".equals(nsprefix.getValue())) {
        ns.addMappingAndRender(
                XMLNS, "", getNullNode(nsprefix.getOwnerDocument()));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:CanonicalizerBase.java

示例13: getWsdlBackupDir

import org.w3c.dom.Element; //导入方法依赖的package包/类
@Override
protected String getWsdlBackupDir(Element element) throws Exception {
	String backupDir = super.getWsdlBackupDir(element);
	
	Element connectorNode = (Element) element.getParentNode();
   	NodeList properties = connectorNode.getElementsByTagName("property");
	Element pName = (Element) XMLUtils.findNodeByAttributeValue(properties, "name", "name");
	String connectorName = (String) XMLUtils.readObjectFromXml((Element) XMLUtils.findChildNode(pName, Node.ELEMENT_NODE));
	backupDir += "/" + connectorName;
	return backupDir;
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:12,代码来源:Transaction.java

示例14: findElementWithModule

import org.w3c.dom.Element; //导入方法依赖的package包/类
/** Find a matching web element - useful for updating or deleting an existing element */
   protected Element findElementWithModule(Document doc) {
NodeList moduleNodeList = doc.getElementsByTagName("java");
Element matchingModuleElement = findElementWithMatchingText(module, moduleNodeList);
if (matchingModuleElement != null) {
    return (Element) matchingModuleElement.getParentNode();
} else {
    return null;
}
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:UpdateApplicationXmlTask.java

示例15: initNamespaceSupport

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Initialize namespace support by collecting all of the namespace
 * declarations in the root's ancestors. This is necessary to
 * support schemas fragments, i.e. schemas embedded in other
 * documents. See,
 *
 * https://jaxp.dev.java.net/issues/show_bug.cgi?id=43
 *
 * Requires the DOM to be created with namespace support enabled.
 */
private void initNamespaceSupport(Element schemaRoot) {
    fNamespaceSupport = new SchemaNamespaceSupport();
    fNamespaceSupport.reset();

    Node parent = schemaRoot.getParentNode();
    while (parent != null && parent.getNodeType() == Node.ELEMENT_NODE
            && !parent.getNodeName().equals("DOCUMENT_NODE"))
    {
        Element eparent = (Element) parent;
        NamedNodeMap map = eparent.getAttributes();
        int length = (map != null) ? map.getLength() : 0;
        for (int i = 0; i < length; i++) {
            Attr attr = (Attr) map.item(i);
            String uri = attr.getNamespaceURI();

            // Check if attribute is an ns decl -- requires ns support
            if (uri != null && uri.equals("http://www.w3.org/2000/xmlns/")) {
                String prefix = attr.getLocalName().intern();
                if (prefix == "xmlns") prefix = "";
                // Declare prefix if not set -- moving upwards
                if (fNamespaceSupport.getURI(prefix) == null) {
                    fNamespaceSupport.declarePrefix(prefix,
                            attr.getValue().intern());
                }
            }
        }
        parent = parent.getParentNode();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:40,代码来源:XSDocumentInfo.java


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