Re: [xsl] comparing values

Subject: Re: [xsl] comparing values
From: "Joris Gillis" <roac@xxxxxxxxxx>
Date: Sun, 20 Feb 2005 21:21:26 +0100
Tempore 17:26:49, die 02/20/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Dionisio Ruiz de ZC!rate <dionisio@xxxxxxxxxxxxx>:

hello i have into one xml this:
- <eleccion>
  <eleccionusuario_id>219</eleccionusuario_id>
  <eleccion_id>2</eleccion_id>
  <usuario_id>55</usuario_id>
  <eleccionusuario_valor>false,true,false,false,true,false,true,false,false</eleccionusuario_valor>
</eleccion>

into the <eleccionusuario_valor> node there is this:
false,true,false,false,true,false,true,false,false
how can i change this values with number using xsl?
it the node value is:
false,true,false,false,true,false,true,false,false
the result must be 2,5,7
the tru values are numbres.
Hi,

In XSLT1.0, you'd have to use some recursively called template that does some string-realted tests.

e.g.:

<xsl:template match="eleccionusuario_valor">
	<xsl:call-template name="number"/>
</xsl:template>

<xsl:template name="number">
	<xsl:param name="index" select="1"/>
	<xsl:param name="string" select="."/>
	<xsl:if test="substring-before($string,',') = 'true'">
		<xsl:value-of select="$index"/>
		<xsl:if test="contains(substring-after($string,','), 'true')">
			<xsl:text>,</xsl:text>
		</xsl:if>		
	</xsl:if>
	<xsl:if test="contains($string,',')">
		<xsl:call-template name="number">
			<xsl:with-param name="string" select="substring-after($string,',')"/>
			<xsl:with-param name="index" select="$index + 1"/>
		</xsl:call-template>
	</xsl:if>
</xsl:template>

(tested with AltovaXSLT)

regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
"Et ipsa scientia potestas est"  - Francis Bacon , Meditationes sacrae

Current Thread