Iterate trough a string

Discussion in 'XML' started by Jurrie, Oct 20, 2003.

  1. Jurrie

    Jurrie Guest

    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
     
    Jurrie, Oct 20, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ivailokroumov

    Using FPGA trough internet

    ivailokroumov, Aug 17, 2004, in forum: VHDL
    Replies:
    2
    Views:
    521
    ivailokroumov
    Aug 17, 2004
  2. Maki

    seek trough files in vhdl

    Maki, Jan 24, 2005, in forum: VHDL
    Replies:
    0
    Views:
    964
  3. Gogo
    Replies:
    1
    Views:
    2,107
    Sudsy
    Sep 4, 2003
  4. runescience
    Replies:
    0
    Views:
    1,463
    runescience
    Feb 9, 2006
  5. John
    Replies:
    4
    Views:
    925
    RedGrittyBrick
    Apr 1, 2008
Loading...

Share This Page