Xml xslt中的xpath产生与直接计算xpath不同的结果

Xml xslt中的xpath产生与直接计算xpath不同的结果,xml,xslt,xpath,Xml,Xslt,Xpath,我有一个简单的xml文档 <?xml version="1.0" encoding="UTF-8"?> <root xmlns="http://example.org/attributes"> <record> <codice_fiscale>IT07654930130</codice_fiscale> <indirizzo tipo="casa">Viale Carlo Espina

我有一个简单的xml文档

<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="http://example.org/attributes">
    <record>
        <codice_fiscale>IT07654930130</codice_fiscale>
        <indirizzo tipo="casa">Viale Carlo Espinasse 5, Como</indirizzo>
    </record>
    <n:record xmlns:n="http://test.com/records">
        <n:codice_fiscale>IT87654770157</n:codice_fiscale>
        <n:indirizzo tipo="ufficio">Via Biancospini 20, Messina</n:indirizzo>
    </n:record>
    <record>
        <codice_fiscale>IT471142131</codice_fiscale>
        <indirizzo tipo="ufficio">Via Chiasserini 88B, Firenze</indirizzo>
        <test>
            <nummeroo>01-000-000</nummeroo>
            <nummeroo>02-000-000</nummeroo>
        </test>
        <test>
            <nummeroo>03-000-000</nummeroo>
            <nummeroo>04-000-000</nummeroo>
        </test>
        <stuff>other stuff</stuff>
    </record>
    <things>
        <nummero>08-000-000</nummero>
        <nummero>09-000-000</nummero>
    </things>
</root>
在样式表中使用模板的XPath2.0表达式,即

//*[child::*[not(*)]]
与name()-函数结合使用,将元素名称作为字符串获取,即

//*[child::*[not(*)]]/name()
我得到以下结果(使用不同的编辑器/XPath2.0计算器)

使用XSLT2.0样式表并使用编辑器直接计算XPath2.0表达式会产生不同的结果

我希望结果完全一样。xpath
/*[child::*[not(*)]]/name()
的样式表和直接求值本质上是相同的,应该提供相同的文本输出

xpath表达式和样式表非常简单,但我无法理解为什么对这两个表达式的求值会产生不同的结果

有人知道为什么这两个计算结果不同吗?

匹配模式与选择表达式不同

样式表会发生以下情况:

  • 首先,内置模板规则应用于
    /
    根节点

  • 然后,使用内置递归,将相同的内置模板应用于
    root
    root元素

  • 接下来,模板将启动并处理作为根元素的子元素的节点,在这里处理将停止,因为模板不包含
    xsl:apply templates
    指令


请注意,匹配模式中会忽略前导的
/

谢谢你的解释,迈克尔。看来我还需要学习很多关于xslt的知识。
//*[child::*[not(*)]]
//*[child::*[not(*)]]/name()
record
n:record
record
test
test
things