RE: [xsl] skip formatting ala <pre>?

Subject: RE: [xsl] skip formatting ala <pre>?
From: Pieter Reint Siegers Kort <pieter.siegers@xxxxxxxxxxx>
Date: Tue, 30 Nov 2004 08:43:46 -0600
Hi Wong,

No, it shouldn't be necessary, just try this XSL:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:output method="html" omit-xml-declaration="yes"/>

<xsl:template match="/">
	<html>
	<head>
	</head>
	<body>
	<xsl:copy-of select="MyPre" />
	</body>
	</html>
</xsl:template>

</xsl:stylesheet>

Output generated using your XML "as-is":

<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-16">
</head>
<body><MyPre><p>Hello<br>this is a <a href="http://www.google.com";
alt="nothing">test</a></p></MyPre></body>
</html>

This renders correctly in IE6 on Windows 2003 Server.

If you want to output XML (or better said XHTML) then this also works:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:output method="xml" omit-xml-declaration="no"/>

<xsl:template match="/">
	<html>
	<head>
	</head>
	<body>
	<xsl:copy-of select="MyPre" />
	</body>
	</html>
</xsl:template>

</xsl:stylesheet>

I have tested this in Xselerator 2.6.

HTH,
<prs/> 

-----Original Message-----
From: Wong Chin Shin [mailto:publicbbs@xxxxxxxxxxxxxxxx] 
Sent: Tuesday, November 30, 2004 5:11 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] skip formatting ala <pre>?

Hi,

Let's say for example an XML file contains the following element: 

<MyPre><p>Hello<br />this is a <a href="http://www.google.com";
alt="nothing">test</a></p></MyPre>

Is there a way for me to output the contents of <MyPre> "as-is" including
the tags contained within?

Do I need to convert all "<" to "&lt;" and so on in order to accomplish what
I want?

Thanks
Wong

Current Thread