当我在浏览器中打开pstrong.xml (如下所示)时,输出如下:
heading_1
这是第一段
请您解释一下以下内容:
1)为什么输出第二行(这是第一段)-因为它不是在"pr“模板中完成的?即首先调用"catalog“模板,然后调用"pr”模板。然后调用输出第一行(“heading_1”)的"strong“模板
2)为什么在strong模板中不需要xsl:apply- template?
// pstrong.xml
<?xml version="1.0" encoding="windows-1252"?>
<?xml-stylesheet type="text/xsl" href="pstrong_current.xsl"?>
<catalog>
<pr><strong>heading_1</strong>this is the first paragraph</pr>
</catalog>// pstrong_current.xsl
<?xml version="1.0" encoding="windows-1252"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="catalog">
<html>
<body>
<xsl:apply-templates />
</body>
</html>
</xsl:template>
<xsl:template match="strong">
<xsl:value-of select="."/><br/>
</xsl:template>
<xsl:template match="pr">
<xsl:apply-templates />
</xsl:template>
</xsl:stylesheet>发布于 2013-10-24 17:07:14
如果您使用apply-templates但自己没有匹配的模板,则可以使用built-in templates。
https://stackoverflow.com/questions/19561476
复制相似问题