Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


XSLT for-each position() problem

From: balderdash@-----.---
To: NULL
Date: 2/9/2007 3:58:00 AM
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) &gt; 1">
              <xsl:choose>
                <xsl:when test="position() &gt; 1">
                  <xsl:value-of select="$gSlash"/>
                  <xsl:value-of select=".//value"/>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:value-of select=".//value"/>
                </xsl:otherwise>
              </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..



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