Remko:
At 03:57 PM 7/16/2003, you wrote:
I have an XML-file that contains a sequence of ids. I need to transform
this to a String of space separated ids.
So I transform the xml to a text file and after each id-node I add a
space, like this:
<xsl:template match="*">
<xsl:for-each select="//ns1:genbankid">
<xsl:value-of select="text()"/> </xsl:for-each>
</xsl:template>
but when I try to trim the space of the lastly added id, it refuses to do
it! My application is in Java:
ids.trim()
does not work.
This is rather extravagantly hopeful ain't it? (Do you try XSLT in your
Java, too? :-)
In any case, if you want a space after every value but the last, try
something like
<xsl:for-each select="//nsl:genbankid">
<xsl:value-of select="."/>
<xsl:if test="not(position() = last())"> </xsl:if>
</xsl:for-each>
Any suggestions?? In VIM the transformed file shows not a space but a
capital A with a ^ on top, I assume this is the problem.
Nope: it's a red herring. You are seeing this because VIM does not support
the encoding of your output (probably UTF-8). Use an editor that does, to
get a better view of what's actually in your file; or change how your
output is being serialized (on the xsl:output top-level element) to an
encoding that your toolset supports.
what can I use instead of  ??
You could use a plain space instead of the non-breaking one:
<xsl:if test="not(position() = last())">
<xsl:text> </xsl:text>
</xsl:if>
assuming you don't mind that they break, of course.
Cheers,
Wendell
======================================================================
Wendell Piez
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list