Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Iterate trough a string

Reply
Thread Tools

Iterate trough a string

 
 
Jurrie
Guest
Posts: n/a
 
      10-20-2003
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to iterate 2 nested collections w <logic:iterate> without a"getter" John Java 4 04-01-2008 09:46 AM
nested:iterate or logic: iterate with multibox?? runescience Java 0 02-09-2006 12:57 AM
seek trough files in vhdl Maki VHDL 0 01-24-2005 08:23 PM
Using FPGA trough internet ivailokroumov VHDL 2 08-17-2004 02:14 PM
<logic:iterate /> iterate beyond items in the collection Gogo Java 1 09-04-2003 08:40 PM



Advertisments