嗨再次,我只想在每个页面节点之间放置一个<hr>
标签来分隔内容
这是XML文件
XML:
<site>
<page>
<content><p align="center"> thank you</p>
<P align="center">
<FONT size="2" face="Tahoma">
<p>some data too</p>
</FONT>
</P>
</content>
</page>
<page>
<content><p>some data</p>
</content>
</page>
</site>
这是xsl文件
XSL:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<xsl:copy-of select="site/page/content"/><hr/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
线路显示在输出结束时的问题,我需要在每个页面节点之间 谢谢你
答案 0 :(得分:0)
您可以在此处使用基于模板的方法。有一个与内容元素匹配的模板,您只需复制该节点的数据,然后将 hr 元素放在其后
<xsl:template match="content">
<xsl:copy-of select="*" />
<hr />
</xsl:template>
然后,而不是<xsl:copy-of select="site/page/content"/>
做<xsl:apply-templates select="site/page/content"/>
而不是。{/ p>
试试这个XSLT
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates select="site/page/content"/>
</body>
</html>
</xsl:template>
<xsl:template match="content">
<xsl:copy-of select="*"/>
<hr/>
</xsl:template>
</xsl:stylesheet>