示例代码
1.test.xml
复制代码 代码如下:
<?xmlversion="1.0"encoding="gb2312"?>
<?xml-stylesheethref="test.xsl"type="text/xsl"?>
<entry>
<title>entrywithimages</title>
<date>August09,2003</date>
<author>Kevin</author>
<idnum>000033</idnum>
<permalink>http://alazanto.org/xml/archives/000033.xml</permalink>
<bodyxmlns:html="http://www.w3.org/1999/xhtml"><![CDATA[<p><img
class="archive"align="right"src="http://alazanto.org/images/sample.jpg"
alt="photographofaflower,justforshow"/>Maurisfeliselit,varius
quis,pulvinarvel,sodalesvehicula,mi.Nuncelementumpharetraelit.
</p>]]>
</body>
<morexmlns:html="http://www.w3.org/1999/xhtml"><![CDATA[]]></more>
<comment-link>http://alazanto.org/xml/archives/000033_comments.xml</comment-link>
<comment-count>6</comment-count>
</entry>
2.test.xsl
复制代码 代码如下:
<?xmlversion="1.0"?>
<xsl:stylesheetxmlns:xsl="http://www.w3.org/1999/XSL/Transform"version="1.0">
<xsl:templatematch="/entry">
<html>
<head>
</head>
<body>
<xsl:value-ofselect="title"/>
<xsl:value-ofselect="body"disable-output-escaping="yes"/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
关键之外在于使用的命名空间xmlns:xsl="http://www.w3.org/1999/XSL/Transform"和输出时加上disable-output-escaping="yes"