Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Choosing right element

From: Joseph Kesselman <keshlam-nospam@-------.--->
To: NULL
Date: 5/7/2007 5:47:00 PM

> <xsl:choose>
>   <xsl:when test="@timezone=$tz">
>     <xsl:value-of select="."/>
>   </xsl:when>
>   <xsl:otherwise>
>     <xsl:value-of select="."/>
>   </xsl:otherwise>
> </xsl:choose>

What you've said is "If the current node's timezone attribute has the 
desired value, output the node's value. If it doesn't, then still output 
the node's value." Not what you wanted. Especially since value-of won't 
do what you want either; it will output the concatenated text content, 
which will be something like
   1
   15
with line breaks before and after, and with the indentation.
	

What you wanted was "If there is a <time> element which has the right 
timezone output it, otherwise output the one with no timezone". You 
didn't show us the context, but assuming that you're starting from the 
parent of the <time> elements one way to write this would be:

<xsl:choose>
   <xsl:when test="time[@timezone=$tz]">
     <xsl:apply-templates select="time[@timezone=$tz]"/>
   </xsl:when>
   <xsl:otherwise>
     <xsl:apply-templates select="time[@timezone='']"/>
   </xsl:otherwise>
</xsl:choose>

Note that here I'm also assuming you want to apply a template to the 
<time> elements in order to format their content a bit more usefully.

Hope that helps.




-- 
Joe Kesselman / Beware the fury of a patient man. -- John Dryden


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