DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6585>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6585

<xsl:for-each select="id(@idrefs)"/> loops

[EMAIL PROTECTED] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |TestID, XSLTBug



------- Additional Comments From [EMAIL PROTECTED]  2002-02-20 21:07 -------
The problem is with the last() function, as used within your xsl:for-each.
If you really like the commas in all but the last position, you can workaround
the bug by passing in the value of last, like this:
<xsl:template match="test">
  <xsl:param name="last" select="1000"/><!-- 1000 as safety value -->
  <xsl:for-each select="id( @refids )">
    <xsl:value-of select="@name"/>
    <xsl:if test="not(position()= $last)">
      <xsl:text>, </xsl:text>
    </xsl:if>
  </xsl:for-each>
</xsl:template>
Now the only issue is how to count the number of words in document/test/@refids
efficiently. You can build a readable solution around Xalan's tokenize
function. For a pure-XSLT solution, I succeeded by counting spaces like this:
<xsl:with-param name="last"
select="string-length(
translate(normalize-space(document/test/@refids),
'abcdefghijklmnopqrstuvwxyz',''))
+1"/>
(Add more characters to the letter list if they could appear in @refids.)
The +1 is because 3 words have 2 spaces between them after normalizing.
Research on this bug will continue.

Reply via email to