Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Output text containing 


Status
Not open for further replies.

jeffward

MIS
Jul 3, 2002
33
GB
My xml source file contains text representing code and the software that saves this to xml format has converted the line breaks in the code to &#10.

I am using xsl to output the contents to html and so need to display the code block properly.

for example if the xml contains:-
Code="line 1
line 2
line 1
"

by default this is displayed in html as:-
line 1
line 2
line 1


i would like this displayed as:-
line 1
line 2
line 3
 
Have you tried using: disable-output-escaping="yes"

Jon

"Asteroids do not concern me, Admiral. I want that ship, not excuses.
 
I have managed to find a solution elsewhere and have adapted this into a template which replaces the &amp;#10; entries with <br/> and then uses a pre tab to retain the formating, as follows: -

<pre>
<xsl:call-template name="ReplaceWithNL">
<xsl:with-param name="P_String">
<xsl:value-of select="." />
</xsl:with-param>
</xsl:call-template>
</pre>

<!-- Output P_String with <br /> instead of &amp;#10; -->
<xsl:template name="ReplaceWithNL">
<xsl:param name="P_String" />

<!-- Does the string contain '&amp;#10;' ? -->
<xsl:if test="contains($P_String, '&amp;#10;')">

<!-- Output the first part of the string -->
<xsl:value-of select="substring-before($P_String, '&amp;#10;')" />

<!-- Output the line break -->
<br />

<!-- Call the template again to replace any further occurances -->
<xsl:call-template name="ReplaceWithNL">
<xsl:with-param name="P_String">
<xsl:value-of select="substring-after($P_String, '&amp;#10;')" />
</xsl:with-param>
</xsl:call-template>

</xsl:if>

<!-- If the string does not contain the value to replace then simply output it as is -->
<xsl:if test="not(contains($P_String, '&amp;#10;'))">
<xsl:value-of select="$P_String" />
</xsl:if>

</xsl:template>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top