當前位置: 首頁>>代碼示例>>Java>>正文


Java ParserConfigurationException.getStackTrace方法代碼示例

本文整理匯總了Java中javax.xml.parsers.ParserConfigurationException.getStackTrace方法的典型用法代碼示例。如果您正苦於以下問題:Java ParserConfigurationException.getStackTrace方法的具體用法?Java ParserConfigurationException.getStackTrace怎麽用?Java ParserConfigurationException.getStackTrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.xml.parsers.ParserConfigurationException的用法示例。


在下文中一共展示了ParserConfigurationException.getStackTrace方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: processDTree

import javax.xml.parsers.ParserConfigurationException; //導入方法依賴的package包/類
public Map<Integer, Dependency> processDTree(Node dTree){
	Map<Integer, Dependency> dep = new HashMap<Integer, Dependency>();
	// Tuple to position mapping
	Map<String, Integer> tupleMap = new HashMap<String, Integer>();
	// here starts the hard part
	try {
		Document D = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
		Node initialTree = D.importNode(dTree.getLastChild().getFirstChild(), true);
		D.appendChild(initialTree);
        //rebuild tree nodes
        NodeList treeNodes = D.getElementsByTagName("tree");
        ArrayList<Node> tNodes = new ArrayList<Node>();            
        for (int l = 0; l < treeNodes.getLength(); l++)
        {
            tNodes.add(treeNodes.item(l));    
        }
        for (int i = 0; i < tNodes.size(); i++)
        {
            Node treeNode = tNodes.get(i);
            String treeid = treeNode.getAttributes().getNamedItem("id").getNodeValue();
            TagTree tree  = subgrammar.get(treeid);
            int posi = this.getPosition(tree, tupleMap);
            // we process the "local" dependencies, ie co-anchors or lexical items
            this.getPositionsForTree(tree, posi, dep);
            
            if (treeNode.getParentNode().getParentNode() != null) {
            	// ie it is not the root node
            	// we retrieve the operation's Gorn address
                String opNode = treeNode.getParentNode().getAttributes().getNamedItem("node").getNodeValue();	                
            	// we retrieve the parent
                String parent = treeNode.getParentNode().getParentNode().getAttributes().getNamedItem("id").getNodeValue();
                //System.err.println(treeid + " --> " + parent);
                TagTree ptree = subgrammar.get(parent);
                // we retrieve the node cat:
                List<de.tuebingen.tree.Node> ln = new LinkedList<de.tuebingen.tree.Node>();
                ptree.findNode(ptree.getRoot(), opNode, ln);
                TagNode n  = ln.size() > 0 ? (TagNode) ln.get(0) : null;
                String cat = "";
                if (n != null) {
                	cat = n.getCategory();
                }
                int parentPosi = this.getPosition(ptree, tupleMap);
                if (parentPosi != posi && tree.getIsHead()) {
                	//System.err.println(" Dependency detected " + posi + " " + parentPosi);
                	dep.put(posi, new Dependency(parentPosi, cat));
                }
            } else {
            	// otherwise
            	//System.err.println(" Dependency detected " + posi + " " + 0);
            	dep.put(posi, new Dependency(0, "ROOT"));
            }
        }
	} catch (ParserConfigurationException e){
           System.err.println("Error while extracting dependencies: ");
           System.err.println(e.toString());
           StackTraceElement[] stack = e.getStackTrace();
           for (int i = 0; i < stack.length; i++)
           {
               System.err.println(stack[i]);
           }
	}
	//System.err.println(" ------ " );
	return dep;
}
 
開發者ID:spetitjean,項目名稱:TuLiPA-frames,代碼行數:65,代碼來源:DependencyExtractor.java


注:本文中的javax.xml.parsers.ParserConfigurationException.getStackTrace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。