xsl-list
[Top] [All Lists]

RE: [xsl] following-sibling question

2007-12-25 13:50:34
Thanks for the reply but it doesn't work as the first sample data is still 
selected. I was able to use the generate-id() function to apply the filter for 
the not(@id='d') case.

-----Original Message-----
From: Mukul Gandhi [mailto:gandhi(_dot_)mukul(_at_)gmail(_dot_)com]
Sent: Saturday, December 22, 2007 1:51 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] following-sibling question


Please try this

/items/item[(@id='a') or (@id='c') or (@id='f') or
(preceding-sibling::item[(_at_)id='a'] and
following-sibling::item[(_at_)id='c'] and not(@id='d'))]

(not tested)

On Dec 22, 2007 11:18 AM, Ken Tam <kentam(_at_)proteustech(_dot_)com> wrote:
Hi all,

I have the following XML sample data:

<items>
  <item id="a"/>
  <item id="b"/>
  <item id="c"/>
  <item id="d"/>
  <item id="e"/>
  <item id="f"/>
</items>

and a search requirement to select nodes starting with id="a" passing id="c"
with anything in between and ending in "f" but must not pass through "d".
Thus, the above sample is not a match. Here is a sample that is a match:

<items>
  <item id="a"/>
  <item id="b"/>
  <item id="b"/>
  <item id="e"/>
  <item id="c"/>
  <item id="e"/>
  <item id="f"/>
</items>

I am not sure how to write the XPATH expression to filter on the "must not
pass through "d" requirement. For example,

/items/item[(_at_)id="a"]/following-sibling::item[(_at_)id="c"]/following-sibling::ite
m[(_at_)id != "d"]/following-sibling::item[(_at_)id="f"]

doesn't work as "e" is picked up.

Thanks,
Ken


-- 
Regards,
Mukul Gandhi

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>