B
balderdash
Hi
I am very close to achieving the output I need but I cant seem to get
it right.
The problem is I am looping through a table and selecting values, if
there are 2 values per (row) Issuer I need to put a slash between them
in the output xml.
The problem is shown by the output at the bottom of this post. I am
using position() to determine that a slash is needed however sometimes
the first value is empty and so position() is not good enough (as
below)
Since there is no way to store local variables in xslt nor can I find
a way to examine what has been previously selected I am stumped!
Is there a way to put the string-length check in the for-each select
statement??
Here is the code I have:
....
<xsl:variable name="dataValue">
<xsl:for-each select="$records[row=$CurrentRow]">
<xsl:sort select=".//col"/>
<xsl:if test="string-length(.//value) > 1">
<xsl:choose>
<xsl:when test="position() > 1">
<xsl:value-of select="$gSlash"/>
<xsl:value-of select=".//value"/>
</xsl:when>
<xsltherwise>
<xsl:value-of select=".//value"/>
</xsltherwise>
</xsl:choose>
</xsl:if>
</xsl:for-each>
</xsl:variable>
.....
Here is the slightly wrong output with the unwanted slashes:
<Issuer>
<Value>+0.9%/+0.5%</Value>
</Issuer>
<Issuer>
<Value>/8.9%</Value>
</Issuer>
<Issuer>
<Value>/-6.4%</Value>
</Issuer>
Any help appreciated..
I am very close to achieving the output I need but I cant seem to get
it right.
The problem is I am looping through a table and selecting values, if
there are 2 values per (row) Issuer I need to put a slash between them
in the output xml.
The problem is shown by the output at the bottom of this post. I am
using position() to determine that a slash is needed however sometimes
the first value is empty and so position() is not good enough (as
below)
Since there is no way to store local variables in xslt nor can I find
a way to examine what has been previously selected I am stumped!
Is there a way to put the string-length check in the for-each select
statement??
Here is the code I have:
....
<xsl:variable name="dataValue">
<xsl:for-each select="$records[row=$CurrentRow]">
<xsl:sort select=".//col"/>
<xsl:if test="string-length(.//value) > 1">
<xsl:choose>
<xsl:when test="position() > 1">
<xsl:value-of select="$gSlash"/>
<xsl:value-of select=".//value"/>
</xsl:when>
<xsltherwise>
<xsl:value-of select=".//value"/>
</xsltherwise>
</xsl:choose>
</xsl:if>
</xsl:for-each>
</xsl:variable>
.....
Here is the slightly wrong output with the unwanted slashes:
<Issuer>
<Value>+0.9%/+0.5%</Value>
</Issuer>
<Issuer>
<Value>/8.9%</Value>
</Issuer>
<Issuer>
<Value>/-6.4%</Value>
</Issuer>
Any help appreciated..