[jdom-interest] XPATH Question
Sanjeev Verma [CONTRACTOR]
sanjeev.verma at Sun.Com
Thu May 8 15:44:05 PDT 2003
Thanx a ton Stefan. That makes perfect sense. I knew what is the reason of the
error, but I was not able to figure out the correct expression. Thanx again.
Best Regards
Sanjeev
>Delivered-To: jdom-interest at dorothy.denveronline.net
>From: Stefan Schoenmackers <stef at cparity.com>
>X-Sender: stef at parity
>To: "Sanjeev Verma [CONTRACTOR]" <sanjeev.verma at Sun.COM>
>Cc: jdom-interest at jdom.org
>Subject: Re: [jdom-interest] XPATH Question
>MIME-Version: 1.0
>X-BeenThere: jdom-interest at jdom.org
>X-Mailman-Version: 2.0.1
>List-Help: <mailto:jdom-interest-request at jdom.org?subject=help>
>List-Post: <mailto:jdom-interest at jdom.org>
>List-Subscribe: <http://lists.denveronline.net/mailman/listinfo/jdom-interest>,
<mailto:jdom-interest-request at jdom.org?subject=subscribe>
>List-Id: JDOM Mailing List for General Issues and Updates
<jdom-interest.jdom.org>
>List-Unsubscribe:
<http://lists.denveronline.net/mailman/listinfo/jdom-interest>,
<mailto:jdom-interest-request at jdom.org?subject=unsubscribe>
>List-Archive: <http://lists.denveronline.net/pipermail/jdom-interest/>
>Date: Thu, 8 May 2003 15:09:04 -0700 (PDT)
>
>What about trying something along the lines of:
>
>/.../parent-tag[category[@level=certain_level]="certain string"]
>
>I tried the parent-tag part on the following document:
>
>(modified xpath: /root/parent-tag[category[@level=1]="A"] )
>
><root>
><parent-tag>
> <category level="1">A</category>
> <category level="2">B</category>
> <category level="3">C</category>
></parent-tag>
><parent-tag>
> <category level="3">H</category>
> <category level="4">I</category>
> <category level="5">A</category>
></parent-tag>
></root>
>
>The original way returned two nodes, whereas the xpath above only returned
>one (the top one). The problem with your xpath, to the best of my
>knowledge (I am by no means an expert), is that the boolean and argument
>intersects the matching node-sets after evaluating each piece. I.e.
>running your xpath intersected the set of all parent-tag's that had a
>category matching "certain string" with the set of all parent-tag's having
>a category child with @level=some_level . If you add the level clause to
>category child as above, then it will only match category nodes at the
>specified level first, and then those that match the given string (or
>maybe in the other order, but it will have the same effect).
>
>Hopefully that makes sense.
>
>--Stef Sch...
>
>On Thu, 8 May 2003, Sanjeev Verma [CONTRACTOR] wrote:
>
>> Hi all:
>>
>> Although I am using JDom in my application, this is purely an XPath question.
>>
>> I have an XML document, that has a "*" as the multiplicity assigned to an
>> element. This element, lets say category, is defined to have a PCDATA value
and
>> an attribute called "level", which can be 1, 2, 3...
>>
>> My problem is, I need an XPath expression by which I can select parent node
of
>> all such category elements whose PCDATA value equals "certain string" and
whose
>> attribute "level" equals "certain level". I used an expression like:
>>
>> /.../parent-tag[category="certain string" and category[@level=certain_level]]
>>
>> But this expression gives erroneous output, because of the multiplicity of
this
>> element. What I get is a list of <parent-tag> where ANY category element has
>> PCDATA equals "certain string" and ANY OTHER category element attribute level
>> equals "certain level". That is, it is not the same category element that is
>> being used for comparison.
>>
>> Is the problem statement clear? can someone help?
>>
>> Best Regards
>>
>> Sanjeev
>>
>> _______________________________________________
>> To control your jdom-interest membership:
>>
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.co
m
>>
>
>_______________________________________________
>To control your jdom-interest membership:
>http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.c
om
Best Regards
Sanjeev Verma
Sun ONE App Server Migration Consultant
Web Services, Tools and Migration Tools
Market Development Engineering
More information about the jdom-interest
mailing list