Eksempel: CDATA
schema-fil(cdata.xsd)
<?xml version="1.0" encoding="iso-8859-1"?>
<wt:schema xmlns:wt="http://www.w3.org/2001/XMLSchema">
<wt:element name="kodeeksempel">
<wt:complexType>
<wt:sequence>
<wt:element name="kode" minOccurs="0" maxOccurs="unbounded">
<wt:complexType>
<wt:sequence>
<wt:element name="språk" type="wt:string"/>
<wt:element name="koden" type="wt:string"/>
</wt:sequence>
</wt:complexType>
</wt:element>
</wt:sequence>
</wt:complexType>
</wt:element>
</wt:schema>
xml-fil(cdata.xml)
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="cdata.xsl"?>
<kodeeksempel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="cdata.xsd">
<kode>
<språk>C</språk>
<koden>
<![CDATA[
#include <stdio.h>
void helloPrint(int ant)
{
int i;
if(ant>0)
for(i=0; i<ant;i++)
printf("Hello world\n");
}
int main()
{
helloPrint(3);
return 0;
}
]]>
</koden>
</kode>
<kode>
<språk>HTML</språk>
<koden>
<![CDATA[
<html>
<head>
<title>kodetest</title>
</head>
<body>
<h1>kodetest nr. 1</h1>
</body>
</html>
]]>
</koden>
</kode>
</kodeeksempel>
style-fil(cdata.xsl)
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title>Kode</title>
</head>
<body>
<h1>Kodeeksempler</h1>
<table border="0" cellpadding="10" cellspacing="0">
<tr>
<th align="left" valign="top">Språk</th>
<th align="left" valign="top">Kode</th>
</tr>
<xsl:for-each select="kodeeksempel/kode">
<tr>
<td valign="top"><pre><xsl:value-of select="språk"/></pre></td>
<td valign="top"><pre><xsl:value-of select="koden"/></pre></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Se resultat(krever IE5 eller nyere)