![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Returning node-set between two node [Thread Next] Re: Returning node-set between two nodeTo: NULL Date: 9/12/2007 1:44:00 PM
<mariolongos@g...> wrote in message
news:1189594077.610398.67550@y......
> Hello, i've an xml file that contains element table and p.
> <html>
> <p>sbbbbbbb</p>
> <p>aaaa</p>
> <table nodeID="TTT99999">
> ........
> </table>
> <p>a</p>
> <p>b</p>
> <p>d</p>
> <table nodeID="55666TTeee">
> .......
> </table>
> <p>....
> </p>
> ...
> ...
>
> </html>
>
> How can I retrieving the elements "p" between table with
> nodeID=55666TTeee and
> nodeID=TTT99999.
>
> Result expected for the example above:
>
> <p>a</p>
> <p>b</p>
> <p>d</p>
>
> I tried with "preceding-sibling::*", but without useful results.
>
Here is some air code. The template matches a table and processes only the p
elements up until the next table element.
It works on the basis that if you union ( | ) two nodesets, nodes found in
bothe the sets will only be included in the result once. Hence the for-each
only processes p elements when first following table element is the same as
the first following table element of the current table element. Also < 2
catches the final case where there is no following table element.
<xsl:template match="table">
<xsl:for-each
select="following-sibling::p[count(following-sibling::table[1] | current()/
following-sibling::table[1]) < 2)]">
<!-- Process each p here -->
</xsl:for-each>
</xsl:template>
to process p elements after TTT99999 specifically use:-
<xsl:apply-templates select="/html/table[nodeID='TTT99999']" />
--
Anthony Jones - MVP ASP/ASP.NET
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||
|
