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" <[EMAIL PROTECTED]>
To: "Jakarta Commons Users List" <[EMAIL PROTECTED]>
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 = '123'"
> 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:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
>
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>