Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Change xpath depending on whether a param has been set

From: "Dimitre Novatchev" <dnovatchev@-----.--->
To: NULL
Date: 2/5/2005 9:37:00 AM
"Joe Gass" <joe@n...> wrote in message 
news:OsVVysqCFHA.4072@T......
> Thanks for that idea Dimitre, I worked it out another way.  I moved my 
> workings to a new template, then...
>
> <xsl:choose>
> <xsl:when test="$maxNodes!=''">
>  <xsl:apply-templates select="/RESULTS/REVIEWS/REVIEW[position() &lt;= 
> $maxNodes]"/>
> </xsl:when>
> <xsl:otherwise>
>  <xsl:apply-templates select="/RESULTS/REVIEWS/REVIEW"/>
> </xsl:otherwise>
> </xsl:choose>
>
> I'll give your way a go too
>
> Many thanks

Yes,

The idea of conditionally processing one out of two node-sets is simple and 
has a generic solution. The XPath expression to be used in the select 
attribute of xsl:apply-templates, xsl:for-each or for whatever other 
processing (e.g. as an argument to a function) is the following:

          $ns1[$condition]   |   $ns2[not($condition)]

where

    $condition is the same in both predicates XPath expression.

This is naturally generalised to a selection of one out of N node-sets based 
on the outcome of N mutually exclusive events.


Cheers,
Dimitre Novatchev. 




transparent
Print
Mail
Like It
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