Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: How can i append a break line
after character is found.How can i use xpath/xsl for this

From: "Anthony Jones" <Ant@------------.--->
To: NULL
Date: 11/9/2007 5:06:00 PM

"rote" <naijacoder@h...> wrote in message
news:eOGxNUZIIHA.484@T......
> I found out that i can't use replace but translate so i did
> <xsl:value-of select="translate(@Title,':   ','&#60;br&#62;')" />
> for example lets say the @title is : THE BOY IS GOOD:THE GIRL IS GOOD
> what i want o achieve is
> THE BOY IS GOOD
> THE GIRL IS GOOD
> But what i get now is :THE BOY IS GOOD<THE GIRL IS GOOD<

translate replaces one character with another.  You can't replace a
character with a set of characters.

<xsl:template name="colonToBR">
    <xsl:param name="input" />
    <xsl:choose>
        <xsl:when test="contains($input, ':')">
            <xsl:value-of select="substring-before($input, ':')" />
            <xsl:call-template name="colonToBR>
                <xsl:with-param name="input" select="substring-after($input,
':')" />
            </xsl:call-template>
            <br />
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="$input" />
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

<xsl:call-template name="colonToBR">
    <xsl:with-param select="@title" />
</xsl:call-template>

Of course all this pre-supposes that colons in the title text aren't intend
to be colons.


-- 
Anthony Jones - MVP ASP/ASP.NET




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent