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">
<xslaram 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>
<xsltherwise>
<fo:inline text-decoration="underline">
<xsl:value-of select="substring(current()/text(),$pos,$pos)" />
</fo:inline>
</xsltherwise>
</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
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">
<xslaram 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>
<xsltherwise>
<fo:inline text-decoration="underline">
<xsl:value-of select="substring(current()/text(),$pos,$pos)" />
</fo:inline>
</xsltherwise>
</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