Scrier Posted March 1, 2008 Share Posted March 1, 2008 Hi, I have a xml dokument with a couple of spans. in the following order: <span> <from>0</from> <to>23</to></span><span> <from>31</from> <to>31</to></span> And the issue I have with a call-template is how to make this into a proper if statement. If I only have one I can use this call <xsl:template match="span" mode="ifvalue"> <xsl:value-of select="from" /> <= value && value <= <xsl:value-of select="to" /></xsl:template> and it comes out as if( 0 <= value && value <= 23 ) Problem is if I have more than one span I wan't it to come out as: if( 0 <= value && value <= 23 || 31 <= value && value <= 31 ) or if( 0 <= value && value <= 23 || 31 == value ) But I can't really find a way to know if it is more than 1 span and how to put it in before the second so I don't get it in the end.Any help is appreciated// Scrier Link to comment Share on other sites More sharing options...
boen_robot Posted March 1, 2008 Share Posted March 1, 2008 lol.... and I was wondering why is the topic called like that. Most fitting title I've seen in a while .XSLT has other constructs you know. Like <xsl:if> and <xsl:choose>. They serve like the C++ "if" and "switch" respectively.I think for your pboblem, the following might help <xsl:template match="span" mode="ifvalue"> <xsl:value-of select="from" /> <= value && value <= <xsl:value-of select="to" /><xsl:if test="position() != last()"> || </xsl:if></xsl:template> Link to comment Share on other sites More sharing options...
Scrier Posted March 2, 2008 Author Share Posted March 2, 2008 Thanks alot. Will have to look into that one a bit more. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.