<root>
<tag>
<form>
some html form will be here
</form>
</tag>
<tag>
some visible data
</tag>
xslt
<xsl:template match="tag">
<div id="page-base">
<xsl:apply-templates />
</div>
</xsl:template>
生产
<div id="page-base">
</div>
<div id="page-base">
some visible data
</div>
期望的输出
<div id="page-base">
<form>
some html form will be here
</form>
</div>
<div id="page-base">
some visible data
</div>
编辑:
如果tag
嵌套在tag
模板规则适用的元素中,它将用模板替换标签并复制模板不匹配的其他元素。请看例子。tag
可以任意嵌套
<root>
<tag>
<form>
some html form will be here
</form>
<tag>
arbitrary nested tags
</tag>
</tag>
<tag>
some visible data
</tag>
</root>
预期结果
<div id="page-base">
<form>
some html form will be here
</form>
<div id="page-base">
arbitrary nested tags
</div>
</div>
<div id="page-base">
some visible data
</div>