Iterate trough a string

J

Jurrie

hi all,

In my XML document i have <paragraph type="...">some text</paragraph>
the type="..." specifies what type the paragraph is. This is all
defined somewehere else in the document.
The type specifies what font should be used, if the text should be
bold etc.
It also specifies if the text should be underlined including spaces,
underlined excluding spaces or not underlined at all.
The problem arise when i need to underline excluding the spaces
(space, tab etc.)
To do this i have to itterate trough the string and use underscore if
the character is not a whitespace. I have this in my xsl document:
===code=========================================================================
<xsl:template name="word_underline">
<xsl:param name="pos" />
<xsl:choose>
<xsl:when test="substring(current()/text(),$pos,$pos)=' '">
<fo:inline text-decoration="no-underline">
<xsl:value-of select="substring(current()/text(),$pos,$pos)" />
</fo:inline>
</xsl:when>
<xsl:eek:therwise>
<fo:inline text-decoration="underline">
<xsl:value-of select="substring(current()/text(),$pos,$pos)" />
</fo:inline>
</xsl:eek:therwise>
</xsl:choose>
<xsl:if test="string-length()!=$pos">
<xsl:call-template name="word_underline">
<xsl:with-param name="pos">
<xsl:value-of select="$pos+1" />
</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:template>
===/code========================================================================

and then i call this template like this:

===code=========================================================================
<xsl:when test="/document/definitions/stylesheets/stylesheet[@name=current()/@stylesheet]/character/face/wordunderline='1'">
<xsl:call-template name="word_underline">
<xsl:with-param name="pos">1</xsl:with-param>
</xsl:call-template>
</xsl:when>
===/code========================================================================

If I run the above throug FOP (with xalan-j) the text looks all messed
up. If the string is <paragraph type="...">some text</paragraph> the
output looks something like this:
soos mesome t somet tex mtxt ext
or something like that. and everything is underlined. (spaces also)

Does anybody know what i am doing wrong?
thanks for any help,
Jurrie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top