commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dmitri Plotnikov <dmi...@apache.org>
Subject Re: [JXPath] Urgent problem with xpath evaluations on DOM - please help
Date Fri, 29 Nov 2002 07:29:27 GMT
Joern,

The bug was in InfoSetUtils.booleanValue().  The implementation did not
follow the specification properly.  The spec says: "boolean value of a node
set is true if the set is not empty".  So, for example, in the case of

    <foo>false</foo>

the expression

    boolean(foo)

is supposed to return true, because such an element exists, not because it
contains a true value.  JXPath would return false if the node was not empty,
but the first node of the set was empty.

That is now fixed. Please download the new binaries at
www.plotnix.com/jxpath/commons-jxpath.zip

Let me know if the fix has cleared out the problem you reported.

- Dmitri

----- Original Message -----
From: "Dmitri Plotnikov" <dmitri@plotnix.com>
To: "Jakarta Commons Users List" <commons-user@jakarta.apache.org>
Sent: Wednesday, November 27, 2002 7:42 PM
Subject: Re: [JXPath] Urgent problem with xpath evaluations on DOM - please
help


> Joern,
>
> I will try to reproduce this problem over the weekend.  In the meantime
you
> might want to try with a newer version of JXPath.  You can download one at
> www.plotnix.com/jxpath/commons-jxpath.zip
>
> If you want to build it yourself, make sure you have JDOM beta 8
>
> Regards,
>
> - Dmitri
>
> ----- Original Message -----
> From: "joern turner" <joern.turner@web.de>
> To: "Jakarta Commons Users List" <commons-user@jakarta.apache.org>
> Sent: Wednesday, November 27, 2002 5:35 PM
> Subject: [JXPath] Urgent problem with xpath evaluations on DOM - please
help
>
>
> > (sorry for missing identifier in last post)
> > hello,
> >
> > first of all let me say that JXPath is a really cool piece of software -
> > that's why we decided to use it ;)
> >
> > but currently i had a hard time with it, struggling two days to make
> > sense of some strange behaviours with executing XPathes on plain DOM:
> >
> > i'm running JDK 1.3.1 with Xerces 2.0.1 and use the 1.0 version of
> > JXPath (unfortunately i had problems with building the current the
> > latest cvs code due to problems in the jdom package - wrong jdom
version?)
> >
> > let me describe the problem. i wrote 2 very simple Junit tests to track
> > down the problem:
> >
> > test 1
> > ---------------------------------
> > i'm using the following input xml...
> >
> > <?xml version="1.0" encoding="iso-8859-1"?>
> > <instance xmlns:my="test">
> >     <my:order>
> >       <my:item my:money="50">
> >         <my:amount>500</my:amount>
> >         <my:discount>100</my:discount>
> >       </my:item>
> >     </my:order>
> > </instance>
> >
> >
> > the code
> > --------------------------------
> > Document doc=getXmlResource("instance.xml");
> > JXPathContext context= JXPathContext.newContext(doc);
> >
> >
> > Boolean b=(Boolean)context.getValue
> > ("boolean(//my:item/my:discount[../my:money > 100])");
> >
> > assertTrue(b.equals(Boolean.FALSE));
> >
> > b=(Boolean)context.getValue
> > ("boolean(//my:item/my:discount[../@my:money > 10])");
> >
> > assertTrue(b.equals(Boolean.TRUE));
> >
> > This snippet works as expected and evaluates the first expression to
> > false and the second to true. That would be exactly what i need.
> >
> > but now look at this ..........
> >
> > test 2
> > ------------------------------------
> >
> > <?xml version="1.0" encoding="iso-8859-1"?>
> > <html xmlns:xforms="xforms">
> >       <head>
> >           <xforms:model>
> >               <xforms:instance>
> >                   <payment>
> >                       <test method="cc">
> >                           <number>123</number>
> >                           <expiry></expiry>
> >                       </test>
> >                   </payment>
> >               </xforms:instance>
> >               <xforms:submission
> > xforms:action="http://example.com/submit" xforms:method="post"/>
> >               <xforms:bind xforms:id="b1"
xforms:nodeset="/payment/number"
> >                   xforms:required="true()" xforms:type="integer"/>
> >               <xforms:bind xforms:id="b2"
> >                   xforms:nodeset="/payment/test/expiry"
> >                   xforms:relevant="../number = &apos;123&apos;"
> >                   xforms:required="true()" xforms:type="string"/>
> >           </xforms:model>
> >       </head>
> >       <body/>
> > </html>
> >
> > and the code
> >
> > Document doc=getXmlResource("relevant1.xml");
> > JXPathContext context= JXPathContext.newContext(doc);
> >
> > System.out.println("result: " + context.getValue
> > ("boolean(//payment/test/expiry[../@method='cc'])"));
> >
> > as i see it, this expression should return 'true' (checked this with
> > other XPathTester) cause the parent of node 'expiry' has a attribute
> > with the value 'cc'.
> >
> > interestingly, when i add a text-node to the <expiry> element the
> > expression evaluates correctly. moreover the first test does not show
> > this error but i tried hard and unsuccessfully to find out a reason why
> > these documents are handled differently.
> >
> > cause JXPath is a really important part of our software any help would
> > be greatly welcome. i'm running out of ideas....
> >
> > Joern Turner
> >
> >
> >
> >
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:commons-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
> > <mailto:commons-user-help@jakarta.apache.org>
> >
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:commons-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
> <mailto:commons-user-help@jakarta.apache.org>
> >
> >
> >
>
>
> --
> To unsubscribe, e-mail:
<mailto:commons-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:commons-user-help@jakarta.apache.org>
>
>
>


Mime
View raw message