【问题标题】:What we mean by this xsl notation <xsl:template match="/|@*|node()">我们所说的 xsl 表示法是什么意思 <xsl:template match="/|@*|node()">
【发布时间】:2012-11-05 11:57:29
【问题描述】:

我不明白这是什么意思..

<xsl:template match="/|@*|node()">
<xsl:apply-templates match="@*|node()"/>
</xsl:template>

请帮帮我..

    <xsl:template match="local-name()='status'"/> 
<xsl:template match="/|@*|node()"> 
<xsl:copy> 
<xsl:apply-templates match="@*|node()"/> 
<xsl:copy> 
</xsl:template>

如果我这样申请,它会在我的 xml 中省略 &lt;status&gt;node,它是如何发生的

【问题讨论】:

    标签: xslt notation


    【解决方案1】:

    /|@*|node() 是由三个单一模式组成的match pattern/ 匹配根节点,也称为文档节点,@* 匹配任何属性节点,node() 作为模式“匹配除属性节点和根节点之外的任何节点”。因此,对于任何类型的节点(因为这三种模式描述了所有类型的节点),模板都会显示&lt;xsl:apply-templates select="@*|node()"/&gt;,这意味着处理属性节点和子节点的联合。 / 匹配的文档节点没有属性节点,属性也没有它们,但作为一种紧凑的方式,您经常会看到这样的模板。

    但是,有一个用于文档节点的内置模板 &lt;xsl:template match="/"&gt;&lt;xsl:apply-templates/&gt;&lt;/xsl:template&gt;,因此人们通常会在模式中省略 /

    【讨论】:

    • 另外,xsl:apply-templates 中的match 应该是select
    • 如果我这样申请,它会在我的 xml 中省略 节点,它是如何发生的跨度>
    • DevNull,感谢您指出apply-templates sn-p 中的错误,我现在已经更正了。
    • Srivatsava Sesham,如果您对某个特定的输入文档和 XSLT 有疑问,那么请考虑提出一个新问题,清楚地向我们展示所有相关代码(XML 输入、您拥有的 XSLT、您想要的输出、您当前获得的输出)。
    猜你喜欢
    • 2014-09-23
    • 2011-04-25
    • 2012-12-03
    • 2020-12-31
    • 2011-02-05
    • 1970-01-01
    • 2011-10-18
    • 2012-12-30
    相关资源
    最近更新 更多