首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么在使用<xsl:apply-templates />时输出元素内容

为什么在使用<xsl:apply-templates />时输出元素内容
EN

Stack Overflow用户
提问于 2013-10-24 17:03:46
回答 1查看 26关注 0票数 0

当我在浏览器中打开pstrong.xml (如下所示)时,输出如下:

heading_1

这是第一段

请您解释一下以下内容:

1)为什么输出第二行(这是第一段)-因为它不是在"pr“模板中完成的?即首先调用"catalog“模板,然后调用"pr”模板。然后调用输出第一行(“heading_1”)的"strong“模板

2)为什么在strong模板中不需要xsl:apply- template?

// pstrong.xml

代码语言:javascript
复制
<?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

代码语言:javascript
复制
<?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>
EN

回答 1

Stack Overflow用户

发布于 2013-10-24 17:07:14

如果您使用apply-templates但自己没有匹配的模板,则可以使用built-in templates

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19561476

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档