Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Returning node-set between two node

From: "Anthony Jones" <Ant@------------.--->
To: 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




transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent