Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
but however when it renders, it renders all one line how can i replace all \n with <br />'s.
i've tried
<xsl:value-of select='replace(msg, "
", "<br/>")' />
but i get this error
Error loading stylesheet: Invalid XSLT/XPath function.
how do i do this?
<xsl:param name="text" select="string(.)"/>
<xsl:choose>
<xsl:when test="contains($text, '
')">
<xsl:value-of select="substring-before($text, '
')"/>
<xsl:call-template name="break">
<xsl:with-param
name="text"
select="substring-after($text, '
')"
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Like this (it will work on the current node):
<xsl:template match="msg">
<xsl:call-template name="break" />
</xsl:template>
or like this, explicitly passing a parameter:
<xsl:template match="someElement">
<xsl:call-template name="break">
<xsl:with-param name="text" select="msg" />
</xsl:call-template>
</xsl:template>
I think you are working with an XSLT 1.0 processor, whereas replace() is a function that has been introduced with XSLT/XPath 2.0.
You can also achieve this by simple HTML tag,
Try this <pre>
tag before your msg and close it after msg.
Jayakumar Kulkarni (Consultant) :
Remark
Jayakumar Kulkarni :
Rematr 01
Jayakumar Kulkarni :
comment</pre>
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.