jm wrote:
can anybody give me a hint, how I can store code-listings (java, c++, ....)
in my xml-file and put it out as html with XSLT?
It's just for showing some code-chunks on the website.
I tried to use <![CDATA[ ... code in here ]> but this doesn't work properly.
I even need do recognize LF to format the output.
You can use CDATA sections in the XML, that's fine. Or you can replace all the
"<" with "<" and "&" with "&", which is all a CDATA section saves you
from having to do...
<code><![CDATA[
text and <tags> & stuff
]]></code>
is the same as
<code>
text and <tags> & stuff
</code>
Make sure you have <xsl:output method="html"/>, and copy the parsed
text through...
<xsl:template match="code">
<pre>
<xsl:value-of select="."/>
</pre>
</xsl:template>
Your HTML output will have
<pre>
text and <tags> & stuff
</pre>
The fact that it's in a <pre> will cause whitespace to be preserved when it is
rendered by the HTML user agent. The "<" and "&" are how the HTML
serializer in the XSLT processor decided to output the "<" and "&" in the
parsed data, in order to conform to HTML syntax. It will be parsed by the HTML
browser just like it would in XML, so you'll get "<" in the rendering, don't
worry. Fine-tune the rendering with CSS. No need to get fancy with replacing
linefeeds with <br>s since <pre> does all the work for you.
Mike
--
Mike J. Brown | http://skew.org/~mike/resume/
Denver, CO, USA | http://skew.org/xml/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list