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


Java TreeWalker.firstChild方法代码示例

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


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

示例1: traverseLevel

import org.w3c.dom.traversal.TreeWalker; //导入方法依赖的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

示例2: parseTree

import org.w3c.dom.traversal.TreeWalker; //导入方法依赖的package包/类
private List<Feature> parseTree(TreeWalker walker,
                                String tag,
                                String chr,
                                List<Feature> features) {

    Node parent = walker.getCurrentNode();
    Element n = (Element) walker.firstChild();
    while (n != null) {
        if (n.getTagName().equalsIgnoreCase(tag)) {
            Feature f = getFeature(walker, chr);
            if (f != null) {
                features.add(f);
            }

            n = (Element) walker.nextSibling();
            continue;
        }
        parseTree(walker, tag, chr, features);
        n = (Element) walker.nextSibling();
    }
    walker.setCurrentNode(parent);
    return features;
}
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:24,代码来源:DASFeatureSource.java

示例3: setPackageToElements

import org.w3c.dom.traversal.TreeWalker; //导入方法依赖的package包/类
private void setPackageToElements(TreeWalker tw, String currentPackage) {
    Node n = tw.getCurrentNode();
    XmiElement element = new XmiElement((Element) n, this);
    if (isPackageElement(element)) {
        if (currentPackage.isEmpty()) {
            currentPackage = element.getNameTag();
        } else {
            currentPackage = currentPackage + XmiTags.SEPARATOR + element.getNameTag();
        }
        logger.debug("Current package has changed " + currentPackage);
    } else if (elementIdMap.get(element.getXmiId()) != null) {
        elementIdMap.get(element.getXmiId()).setPackageContainer(currentPackage);
    }
    for (Node child = tw.firstChild();
        child != null;
        child = tw.nextSibling()) {
        setPackageToElements(tw, currentPackage);
    }
    tw.setCurrentNode(n);
}
 
开发者ID:proyecto-adalid,项目名称:adalid,代码行数:21,代码来源:XmiDomTree.java

示例4: traverseLevel

import org.w3c.dom.traversal.TreeWalker; //导入方法依赖的package包/类
private static int traverseLevel(TreeWalker walker, int counter) {
	// describe current node:
	final Node parend = walker.getCurrentNode();

	if (parend instanceof Element) {
		if (((Element) parend).getAttribute("id").length() == 0) {
			((Element) parend).setAttribute("id", "gen-id-" + counter);
			counter++;
		}
	}

	// traverse children:
	for (Node n = walker.firstChild(); n != null; n = walker.nextSibling()) {
		counter = traverseLevel(walker, counter);
	}

	// return position to the current (level up):
	walker.setCurrentNode(parend);

	return counter;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:22,代码来源:Readability.java

示例5: hasChildElement

import org.w3c.dom.traversal.TreeWalker; //导入方法依赖的package包/类
public static boolean hasChildElement(TreeWalker walker)
{
    Node current = walker.getCurrentNode();
    Node child = walker.firstChild();
    if (child != null)
    {
        walker.setCurrentNode(current);
        return true;
    }
    return false;
}
 
开发者ID:jmarranz,项目名称:jnieasy,代码行数:12,代码来源:TreeWalkerUtil.java

示例6: fillElementIdMap

import org.w3c.dom.traversal.TreeWalker; //导入方法依赖的package包/类
private void fillElementIdMap(TreeWalker tw) {
    Node n = tw.getCurrentNode();
    Element element = (Element) n;
    if (element.getAttributeNode(XmiTags.XMI_ID_TAG) != null) {
        XmiElement xmiElement = new XmiElement(element, this);
        elementIdMap.put(xmiElement.getXmiId(), xmiElement);
        //System.out.println("entity "+xmiElement.getNameTag()+" type "+xmiElement.getXmiType());
    }
    for (Node child = tw.firstChild();
        child != null;
        child = tw.nextSibling()) {
        fillElementIdMap(tw);
    }
    tw.setCurrentNode(n);
}
 
开发者ID:proyecto-adalid,项目名称:adalid,代码行数:16,代码来源:XmiDomTree.java

示例7: getArticleTextMapping

import org.w3c.dom.traversal.TreeWalker; //导入方法依赖的package包/类
protected void getArticleTextMapping(TreeWalker walker, List<MappingNode> map) throws DOMException {
	final Node parend = walker.getCurrentNode();

	if (parend.getNodeType() == Node.TEXT_NODE && parend.getParentNode().getAttributes().getNamedItem("id") != null)
	{
		if (parend.getTextContent().trim().length() > 0)
		{
			final int index = findChildNodeIndex(parend.getParentNode(), parend);
			if (index != -1)
			{
				// square brackets are not valid XML/HTML identifier
				// characters, so we can use them here
				map.add(new MappingNode(
						parend.getParentNode().getAttributes().getNamedItem("id").getNodeValue() + "[" + index + "]",
						parend.getNodeValue()));

				// System.out.println(
				// "ELEMENT '"+parend.getParentNode().getAttributes().getNamedItem("id").getNodeValue()
				// + "["+index+"]"+"'");
				// System.out.println( "VALUE:  '"+parend.getNodeValue()+"'"
				// );
			}
		}
	}

	// traverse children:
	for (Node n = walker.firstChild(); n != null; n = walker.nextSibling()) {
		getArticleTextMapping(walker, map);
	}

	// return position to the current (level up):
	walker.setCurrentNode(parend);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:34,代码来源:Readability.java

示例8: firstChildElement

import org.w3c.dom.traversal.TreeWalker; //导入方法依赖的package包/类
public static Element firstChildElement(TreeWalker walker,boolean mustExist)
{
    Element childNode = (Element)walker.firstChild();
    checkElement(childNode,walker, mustExist, "child");
    return childNode;
}
 
开发者ID:jmarranz,项目名称:jnieasy,代码行数:7,代码来源:TreeWalkerUtil.java


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