XML+XSL学习...

其实就是在一步一步的学习XSL了...

第一个是发现编码的问题....页面编码要指定为UTF-8的话,除了改变XML的编码之外,同时,XSL的头应该这样写:

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

不可以加那个
<xsl:output version="'1.0'" method="'html'" encoding="'UTF-8'" indent="'yes'/">

具体原因不明

再就是处理换行的问题,最佳的解决方式:
xml:
<根>
<内容> hello world
hello csdn


对应的xsl:
<xsl:stylesheet version="1.0" xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates select="根/内容">
</body>
</html>
</xsl:template>
<xsl:template match="br">
<xsl:copy-of select=".">
</xsl:template>
</xsl:stylesheet>

其实就是定义了一个特殊的模板来匹配br字符,然后在对应所需要转换换行的地方使用这个模板就好了

评论

此博客中的热门博文

远程记录OpenWRT日志

用OpenWRT打造自动翻墙路由器(详解篇)

Python中为什么要用is None来代替== None?