如何传递使用Axiom创建的DOM Document来评估Psychopath处理器中的XPath

时间:2013-09-22 11:16:40

标签: java dom xpath axiom

目前,Psychopath Xpath处理器使用XercesLoader类来加载字节流并创建org.w3c.dom.Document,并且可以传递它来评估Xpath。

 InputStream is = new FileInputStream("resources/test.xml");
 DOMLoader loader = new XercesLoader(); 
 Document doc = loader.load(is);

我使用公理创建了org.w3c.dom.Document并将其传递给了Psychopath。

    InputStream is = new FileInputStream("resources/test.xml");

    OMMetaFactory omMetaFactory = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM);
    OMFactory omFac = omMetaFactory.getOMFactory();
    OMXMLParserWrapper wrapper = OMXMLBuilderFactory.createOMBuilder(omFac, is) ;
    Document doc = (Document) wrapper.getDocument(); 

但是当传递doc2时,它会给出错误

  

线程“main”中的异常org.w3c.dom.DOMException:NOT_SUPPORTED_ERR:实现不支持请求的对象或操作类型。       在org.apache.axiom.om.impl.dom.DOMUtil.newDOMException(DOMUtil.java:82)       在org.apache.axiom.om.impl.dom.NodeImpl.compareDocumentPosition(NodeImpl.java:212)       在org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType.compare_node(NodeType.java:219)       at org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType.access $ 0(NodeType.java:207)       在org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType $ 1.compare(NodeType.java:64)       在java.util.TreeMap.put(TreeMap.java:545)       在java.util.TreeSet.add(TreeSet.java:255)       at java.util.AbstractCollection.addAll(AbstractCollection.java:342)       在java.util.TreeSet.addAll(TreeSet.java:312)       在org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType.linarize(NodeType.java:415)       at org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.do_step(DefaultEvaluator.java:1165)       在org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.visit(DefaultEvaluator.java:1249)       在org.eclipse.wst.xml.xpath2.processor.internal.ast.XPathExpr.accept(XPathExpr.java:43)       在org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.do_expr(DefaultEvaluator.java:337)       在org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.visit(DefaultEvaluator.java:366)       在org.eclipse.wst.xml.xpath2.processor.ast.XPath.accept(XPath.java:58)       at org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.evaluate2(DefaultEvaluator.java:325)       在org.eclipse.wst.xml.xpath2.processor.ast.XPath.evaluate(XPath.java:131)       在psychopath.main(psychopath.java:85)

需要解释。如何将使用公理制作的DOM Document实例传递给Psychopath来评估XPath?

1 个答案:

答案 0 :(得分:0)

解释很简单:Axiom的DOM实现没有实现compareDocumentPosition方法(由DOM 3定义)。