You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ws.apache.org by Asiri Liyana Arachchi <as...@gmail.com> on 2013/10/10 10:48:16 UTC

Re: AXIOM-367 :Improving AXIOMXPath to support XPath 2.0

Here the Input stream "is" is created using String and passed  to the
createOMBuilder method. Then the Document "doc" can be successfully passed
to the Psychopath processor and get the desired out puts.

But when Input stream is created from a file "is1" , the corresponding
Document "doc" cannot be successfully passed to the pyscopath. then it
gives this [7] error.

As the same error  occurred here [8] it seems that Axiom's DOM
implementation doesn't implement the *compareDocumentPosition *method. I've
checked the method and it's just the method with out any content and yet to
implement. Fixing this will ensure DOOM has a level of compliance to DOM
that is high enough to support psychopath to some extent as you've
mentioned.

In a situation where an xml file is provided for the xpath evaluation what
if an inside functionality is implemented in AXIOMXPath2 class  to read and
xml file in to a String then use it to get the work done?

I'll appreciate if you can give me some advice on this situation.

        String str = " <Persons name='cad'> <Person> <Name>Dihini
Himahansi</Name><Sex>Female</Sex><Address><City>Rajagiriya</City><District>Colombo</District><Country>Sri
Lanka</Country></Address></Person></Persons>  ";
        InputStream is = new ByteArrayInputStream(str.getBytes());

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

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


        StaticContextBuilder scb = new StaticContextBuilder();

        String xpathText = "/Persons/Person/Name/text()";
        XPath2Expression expr = new Engine().parseExpression(xpathText, scb);

        ResultSequence rs = expr.evaluate(new
DynamicContextBuilder(scb),new Object[] { doc });

         for (int i = 0; i < rs.size(); ++i) {
             System.out.println(rs.value(i));
         }

[7]
Exception in thread "main" org.w3c.dom.DOMException: NOT_SUPPORTED_ERR: The
implementation does not support the requested type of object or operation.
at org.apache.axiom.om.impl.dom.DOMUtil.newDOMException(DOMUtil.java:82)
at
org.apache.axiom.om.impl.dom.NodeImpl.compareDocumentPosition(NodeImpl.java:212)
at
org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType.compare_node(NodeType.java:222)
at
org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType.access$0(NodeType.java:210)
at
org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType$1.compare(NodeType.java:63)
at java.util.TreeMap.put(TreeMap.java:545)
at java.util.TreeSet.add(TreeSet.java:255)
at java.util.AbstractCollection.addAll(AbstractCollection.java:342)
at java.util.TreeSet.addAll(TreeSet.java:312)
at
org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType.linarize(NodeType.java:418)
at
org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.do_step(DefaultEvaluator.java:1165)
at
org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.visit(DefaultEvaluator.java:1249)
at
org.eclipse.wst.xml.xpath2.processor.internal.ast.XPathExpr.accept(XPathExpr.java:43)
at
org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.do_expr(DefaultEvaluator.java:337)
at
org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.visit(DefaultEvaluator.java:366)
at org.eclipse.wst.xml.xpath2.processor.ast.XPath.accept(XPath.java:58)
at
org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.evaluate2(DefaultEvaluator.java:325)
at org.eclipse.wst.xml.xpath2.processor.ast.XPath.evaluate(XPath.java:131)
at psychopath.main(psychopath.java:78)

[8] :
http://stackoverflow.com/questions/18943283/how-to-pass-dom-document-created-using-axiom-to-evaluate-xpath-in-psychopath-pro


Thanks

Asiri

On Sun, Sep 22, 2013 at 2:40 PM, Andreas Veithen
<an...@gmail.com>wrote:

> On Sun, Sep 22, 2013 at 8:53 AM, Asiri Liyana Arachchi
> <as...@gmail.com> wrote:
> > Couldn't find a method to create W3C Document using Axiom. [1] says
> > createDocument method is protected which returns OMDocument which can be
> > cast to W3C Document. But [2] suggests that in impemetation of the
> > StAXOMBuilder class that method is declared private.
> > I have discussed this matter here [3].
> > Isn't there any way to create w3c Document using Axiom.
> >
> > [1]
> >
> http://people.apache.org/~veithen/axiom/apidocs/org/apache/axiom/om/impl/builder/StAXOMBuilder.html
> > [2]
> >
> http://svn.wso2.org/repos/wso2/branches/carbon/3.0.0/dependencies/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java
> > [3]
> http://stackoverflow.com/questions/18940777/cant-invoke-the-protected-method-in-staxombuilder-class
>
> Please refer to the release Javadoc at [4] and the official source
> code at [5]. I've answered your question on Stackoverflow. Also note
> that the quickstart samples document [6] on the Axiom Web site has an
> example of using DOM.
>
> [4] http://ws.apache.org/axiom/apidocs/index.html
> [5] https://svn.apache.org/repos/asf/webservices/axiom/
> [6] http://ws.apache.org/axiom/quickstart-samples.html
>
> > About the requirement of  the PsychoPath library being available as a
> Maven
> > artifact from the central repository, I got to know that the psychopath
> > XPath2 engine is available through the P2 repositories (only - at this
> > point), and if Apache maven is used for building , Tycho can be used to
> > fetch the dependencies through P2. I'm still working on that.
>
> Note that the purpose of the restriction on the allowed repositories
> is to ensure long term build stability. In particular, the source code
> of an Axiom version released today should still be buildable in a
> couple of years. Introducing a P2 repository is fine, provided that it
> has similar guarantees in terms of long term stability as the Maven
> central repository. Probably this is the case for the P2 repositories
> linked to particular Eclipse releases (such as
> http://download.eclipse.org/releases/kepler).
>
> > Regards
> > Asiri
> >
> >
> > On Sun, Sep 15, 2013 at 12:14 AM, Andreas Veithen
> > <an...@gmail.com> wrote:
> >>
> >> On Thu, Sep 12, 2013 at 4:05 PM, Asiri Liyana Arachchi
> >> <as...@gmail.com> wrote:
> >> > Since there are no other processors which are object model
> independent,
> >> > and
> >> > because of the fact that the Axiom provides a DOM implementation I
> think
> >> > integrating Psychopath Xpath Processor with Axiom is the option left
> if
> >> > to
> >> > give Axiom XPath 2 support.
> >> > in the issue page you have mentioned that
> >> >  "Because of (1) the work required to integrate PsychoPath with Axiom
> >> > would
> >> > be to ensure that DOOM has a level of compliance to DOM that is high
> >> > enough
> >> > to support PsychoPath. "
> >> >
> >> > what work need to be done to ensure this?
> >> >
> >>
> >> The process should be as follows:
> >>
> >> 1. Write some test cases that use PsychoPath together with Axiom's DOM
> >> implementation. Ideally these tests should be integrated into the
> >> Axiom build, but this requires that the PsychoPath library be
> >> available as a Maven artifact from the central repository, which was
> >> not the case last time I checked.
> >> 2. Identify the DOM methods that cause problems and that need to be
> >> implemented/fixed.
> >> 3. Add test cases to axiom-dom-testsuite that provide test coverage
> >> for these methods. The test suite in axiom-dom-testsuite is executed
> >> twice during the Axiom build: once against Apache Xerces and once
> >> against Axiom's DOM implementation. This approach ensures that the
> >> covered code is compliant with the DOM specs (assuming that Xerces is
> >> compliant).
> >> 4. Make the required changes to the DOM implementation to make the
> >> test cases added in the previous step pass. If changes are required to
> >> existing code, ensure that the code has enough test coverage to avoid
> >> regressions.
> >>
> >> Steps 2 to 4 would have to be repeated until the tests developed in
> >> step 1 all succeed.
> >>
> >> Andreas
> >>
> >> >
> >> > Regards,
> >> > Asiri
> >> >
> >> >
> >> >
> >> > .
> >> >
> >> >
> >> > On Sun, Jul 7, 2013 at 3:42 PM, Andreas Veithen
> >> > <an...@gmail.com>
> >> > wrote:
> >> >>
> >> >> From the documentation:
> >> >>
> >> >> "Saxon supports these models by wrapping each external node in a
> >> >> wrapper that implements the Saxon NodeInfo interface. When nodes are
> >> >> returned by the XQuery or XPath API, these wrappers are removed and
> >> >> the original node is returned. Similarly, the wrappers are generally
> >> >> removed when extension functions expecting a node are called."
> >> >>
> >> >> That is very bad from a performance perspective. Jaxen uses a pattern
> >> >> [1] that avoids this, so that using Saxon would be a regression.
> >> >>
> >> >> Andreas
> >> >>
> >> >> [1]
> >> >>
> >> >>
> https://svn.apache.org/repos/asf/webservices/axiom/tags/1.2.14/modules/axiom-api/src/main/java/org/apache/axiom/om/xpath/DocumentNavigator.java
> >> >>
> >> >>
> >> >> On Sun, Jun 30, 2013 at 4:45 PM, Asiri Liyana Arachchi
> >> >> <as...@gmail.com> wrote:
> >> >> > Hi all,
> >> >> > I am 3rd year undergraduate of Department of Computer Science and
> >> >> > Engineering, University of Moratuwa, Sri Lanka.
> >> >> > I would to like to work on the above project.
> >> >> >
> >> >> > I went through the discussion on the issue:AXIOM-367 page. As far
> as
> >> >> > I
> >> >> > understood Saxon-HE is good choice if it supports integration with
> >> >> > object
> >> >> > models other than DOM.
> >> >> >
> >> >> > [1]   " Support for Axiom, JDOM, JDOM2, XOM, and DOM4J is not
> >> >> > available
> >> >> > "out
> >> >> > of the box" with Saxon-HE, but the source code is open source (in
> >> >> > sub-packages of net.sf.saxon.option) and can be compiled for use
> with
> >> >> > Saxon-HE if required. "
> >> >> >
> >> >> > Does this make Saxon-HE a viable option?
> >> >> >
> >> >> > [1]
> http://www.saxonica.com/documentation/sourcedocs/thirdparty.html
> >> >> >
> >> >> > Best,
> >> >> > Asiri
> >> >> >
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: dev-unsubscribe@ws.apache.org
> >> >> For additional commands, e-mail: dev-help@ws.apache.org
> >> >>
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: dev-unsubscribe@ws.apache.org
> >> For additional commands, e-mail: dev-help@ws.apache.org
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: dev-help@ws.apache.org
>
>

Re: AXIOM-367 :Improving AXIOMXPath to support XPath 2.0

Posted by Andreas Veithen <an...@gmail.com>.
I guess that this means that the content of resources/test.xml is not
the same as str.

Andreas

On Thu, Oct 10, 2013 at 10:48 AM, Asiri Liyana Arachchi
<as...@gmail.com> wrote:
> Here the Input stream "is" is created using String and passed  to the
> createOMBuilder method. Then the Document "doc" can be successfully passed
> to the Psychopath processor and get the desired out puts.
>
> But when Input stream is created from a file "is1" , the corresponding
> Document "doc" cannot be successfully passed to the pyscopath. then it gives
> this [7] error.
>
> As the same error  occurred here [8] it seems that Axiom's DOM
> implementation doesn't implement the compareDocumentPosition method. I've
> checked the method and it's just the method with out any content and yet to
> implement. Fixing this will ensure DOOM has a level of compliance to DOM
> that is high enough to support psychopath to some extent as you've
> mentioned.
>
> In a situation where an xml file is provided for the xpath evaluation what
> if an inside functionality is implemented in AXIOMXPath2 class  to read and
> xml file in to a String then use it to get the work done?
>
> I'll appreciate if you can give me some advice on this situation.
>
>         String str = " <Persons name='cad'> <Person> <Name>Dihini
> Himahansi</Name><Sex>Female</Sex><Address><City>Rajagiriya</City><District>Colombo</District><Country>Sri
> Lanka</Country></Address></Person></Persons>  ";
>         InputStream is = new ByteArrayInputStream(str.getBytes());
>
>         InputStream is1 = new FileInputStream("resources/test.xml");
>
>         OMMetaFactory omMetaFactory =
> OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM);
>         OMFactory omFac = omMetaFactory.getOMFactory();
>         OMXMLParserWrapper parser =
> OMXMLBuilderFactory.createOMBuilder(omFac,is) ;
>         Document doc = (Document) parser.getDocument();
>
>
>         StaticContextBuilder scb = new StaticContextBuilder();
>
>         String xpathText = "/Persons/Person/Name/text()";
>         XPath2Expression expr = new Engine().parseExpression(xpathText,
> scb);
>
>         ResultSequence rs = expr.evaluate(new DynamicContextBuilder(scb),new
> Object[] { doc });
>
>          for (int i = 0; i < rs.size(); ++i) {
>              System.out.println(rs.value(i));
>          }
>
> [7]
> Exception in thread "main" org.w3c.dom.DOMException: NOT_SUPPORTED_ERR: The
> implementation does not support the requested type of object or operation.
> at org.apache.axiom.om.impl.dom.DOMUtil.newDOMException(DOMUtil.java:82)
> at
> org.apache.axiom.om.impl.dom.NodeImpl.compareDocumentPosition(NodeImpl.java:212)
> at
> org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType.compare_node(NodeType.java:222)
> at
> org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType.access$0(NodeType.java:210)
> at
> org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType$1.compare(NodeType.java:63)
> at java.util.TreeMap.put(TreeMap.java:545)
> at java.util.TreeSet.add(TreeSet.java:255)
> at java.util.AbstractCollection.addAll(AbstractCollection.java:342)
> at java.util.TreeSet.addAll(TreeSet.java:312)
> at
> org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType.linarize(NodeType.java:418)
> at
> org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.do_step(DefaultEvaluator.java:1165)
> at
> org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.visit(DefaultEvaluator.java:1249)
> at
> org.eclipse.wst.xml.xpath2.processor.internal.ast.XPathExpr.accept(XPathExpr.java:43)
> at
> org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.do_expr(DefaultEvaluator.java:337)
> at
> org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.visit(DefaultEvaluator.java:366)
> at org.eclipse.wst.xml.xpath2.processor.ast.XPath.accept(XPath.java:58)
> at
> org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.evaluate2(DefaultEvaluator.java:325)
> at org.eclipse.wst.xml.xpath2.processor.ast.XPath.evaluate(XPath.java:131)
> at psychopath.main(psychopath.java:78)
>
> [8] :
> http://stackoverflow.com/questions/18943283/how-to-pass-dom-document-created-using-axiom-to-evaluate-xpath-in-psychopath-pro
>
>
> Thanks
>
> Asiri
>
> On Sun, Sep 22, 2013 at 2:40 PM, Andreas Veithen <an...@gmail.com>
> wrote:
>>
>> On Sun, Sep 22, 2013 at 8:53 AM, Asiri Liyana Arachchi
>> <as...@gmail.com> wrote:
>> > Couldn't find a method to create W3C Document using Axiom. [1] says
>> > createDocument method is protected which returns OMDocument which can be
>> > cast to W3C Document. But [2] suggests that in impemetation of the
>> > StAXOMBuilder class that method is declared private.
>> > I have discussed this matter here [3].
>> > Isn't there any way to create w3c Document using Axiom.
>> >
>> > [1]
>> >
>> > http://people.apache.org/~veithen/axiom/apidocs/org/apache/axiom/om/impl/builder/StAXOMBuilder.html
>> > [2]
>> >
>> > http://svn.wso2.org/repos/wso2/branches/carbon/3.0.0/dependencies/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java
>> >
>> > [3]http://stackoverflow.com/questions/18940777/cant-invoke-the-protected-method-in-staxombuilder-class
>>
>> Please refer to the release Javadoc at [4] and the official source
>> code at [5]. I've answered your question on Stackoverflow. Also note
>> that the quickstart samples document [6] on the Axiom Web site has an
>> example of using DOM.
>>
>> [4] http://ws.apache.org/axiom/apidocs/index.html
>> [5] https://svn.apache.org/repos/asf/webservices/axiom/
>> [6] http://ws.apache.org/axiom/quickstart-samples.html
>>
>> > About the requirement of  the PsychoPath library being available as a
>> > Maven
>> > artifact from the central repository, I got to know that the psychopath
>> > XPath2 engine is available through the P2 repositories (only - at this
>> > point), and if Apache maven is used for building , Tycho can be used to
>> > fetch the dependencies through P2. I'm still working on that.
>>
>> Note that the purpose of the restriction on the allowed repositories
>> is to ensure long term build stability. In particular, the source code
>> of an Axiom version released today should still be buildable in a
>> couple of years. Introducing a P2 repository is fine, provided that it
>> has similar guarantees in terms of long term stability as the Maven
>> central repository. Probably this is the case for the P2 repositories
>> linked to particular Eclipse releases (such as
>> http://download.eclipse.org/releases/kepler).
>>
>> > Regards
>> > Asiri
>> >
>> >
>> > On Sun, Sep 15, 2013 at 12:14 AM, Andreas Veithen
>> > <an...@gmail.com> wrote:
>> >>
>> >> On Thu, Sep 12, 2013 at 4:05 PM, Asiri Liyana Arachchi
>> >> <as...@gmail.com> wrote:
>> >> > Since there are no other processors which are object model
>> >> > independent,
>> >> > and
>> >> > because of the fact that the Axiom provides a DOM implementation I
>> >> > think
>> >> > integrating Psychopath Xpath Processor with Axiom is the option left
>> >> > if
>> >> > to
>> >> > give Axiom XPath 2 support.
>> >> > in the issue page you have mentioned that
>> >> >  "Because of (1) the work required to integrate PsychoPath with Axiom
>> >> > would
>> >> > be to ensure that DOOM has a level of compliance to DOM that is high
>> >> > enough
>> >> > to support PsychoPath. "
>> >> >
>> >> > what work need to be done to ensure this?
>> >> >
>> >>
>> >> The process should be as follows:
>> >>
>> >> 1. Write some test cases that use PsychoPath together with Axiom's DOM
>> >> implementation. Ideally these tests should be integrated into the
>> >> Axiom build, but this requires that the PsychoPath library be
>> >> available as a Maven artifact from the central repository, which was
>> >> not the case last time I checked.
>> >> 2. Identify the DOM methods that cause problems and that need to be
>> >> implemented/fixed.
>> >> 3. Add test cases to axiom-dom-testsuite that provide test coverage
>> >> for these methods. The test suite in axiom-dom-testsuite is executed
>> >> twice during the Axiom build: once against Apache Xerces and once
>> >> against Axiom's DOM implementation. This approach ensures that the
>> >> covered code is compliant with the DOM specs (assuming that Xerces is
>> >> compliant).
>> >> 4. Make the required changes to the DOM implementation to make the
>> >> test cases added in the previous step pass. If changes are required to
>> >> existing code, ensure that the code has enough test coverage to avoid
>> >> regressions.
>> >>
>> >> Steps 2 to 4 would have to be repeated until the tests developed in
>> >> step 1 all succeed.
>> >>
>> >> Andreas
>> >>
>> >> >
>> >> > Regards,
>> >> > Asiri
>> >> >
>> >> >
>> >> >
>> >> > .
>> >> >
>> >> >
>> >> > On Sun, Jul 7, 2013 at 3:42 PM, Andreas Veithen
>> >> > <an...@gmail.com>
>> >> > wrote:
>> >> >>
>> >> >> From the documentation:
>> >> >>
>> >> >> "Saxon supports these models by wrapping each external node in a
>> >> >> wrapper that implements the Saxon NodeInfo interface. When nodes are
>> >> >> returned by the XQuery or XPath API, these wrappers are removed and
>> >> >> the original node is returned. Similarly, the wrappers are generally
>> >> >> removed when extension functions expecting a node are called."
>> >> >>
>> >> >> That is very bad from a performance perspective. Jaxen uses a
>> >> >> pattern
>> >> >> [1] that avoids this, so that using Saxon would be a regression.
>> >> >>
>> >> >> Andreas
>> >> >>
>> >> >> [1]
>> >> >>
>> >> >>
>> >> >> https://svn.apache.org/repos/asf/webservices/axiom/tags/1.2.14/modules/axiom-api/src/main/java/org/apache/axiom/om/xpath/DocumentNavigator.java
>> >> >>
>> >> >>
>> >> >> On Sun, Jun 30, 2013 at 4:45 PM, Asiri Liyana Arachchi
>> >> >> <as...@gmail.com> wrote:
>> >> >> > Hi all,
>> >> >> > I am 3rd year undergraduate of Department of Computer Science and
>> >> >> > Engineering, University of Moratuwa, Sri Lanka.
>> >> >> > I would to like to work on the above project.
>> >> >> >
>> >> >> > I went through the discussion on the issue:AXIOM-367 page. As far
>> >> >> > as
>> >> >> > I
>> >> >> > understood Saxon-HE is good choice if it supports integration with
>> >> >> > object
>> >> >> > models other than DOM.
>> >> >> >
>> >> >> > [1]   " Support for Axiom, JDOM, JDOM2, XOM, and DOM4J is not
>> >> >> > available
>> >> >> > "out
>> >> >> > of the box" with Saxon-HE, but the source code is open source (in
>> >> >> > sub-packages of net.sf.saxon.option) and can be compiled for use
>> >> >> > with
>> >> >> > Saxon-HE if required. "
>> >> >> >
>> >> >> > Does this make Saxon-HE a viable option?
>> >> >> >
>> >> >> > [1]
>> >> >> > http://www.saxonica.com/documentation/sourcedocs/thirdparty.html
>> >> >> >
>> >> >> > Best,
>> >> >> > Asiri
>> >> >> >
>> >> >>
>> >> >>
>> >> >> ---------------------------------------------------------------------
>> >> >> To unsubscribe, e-mail: dev-unsubscribe@ws.apache.org
>> >> >> For additional commands, e-mail: dev-help@ws.apache.org
>> >> >>
>> >> >
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: dev-unsubscribe@ws.apache.org
>> >> For additional commands, e-mail: dev-help@ws.apache.org
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@ws.apache.org
>> For additional commands, e-mail: dev-help@ws.apache.org
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ws.apache.org
For additional commands, e-mail: dev-help@ws.apache.org