Is there an XSLT name-of element?

后端 未结 5 1715
暖寄归人
暖寄归人 2020-11-28 23:47

In XSLT there is the


to get the value of an element, but is there something to select the tag-n

5条回答
  •  爱一瞬间的悲伤
    2020-11-28 23:52

    Nobody did point the subtle difference in the semantics of the functions name() and local-name().

    • name(someNode) returns the full name of the node, and that includes the prefix and colon in case the node is an element or an attribute.
    • local-name(someNode) returns only the local name of the node, and that doesn't include the prefix and colon in case the node is an element or an attribute.

    Therefore, in situations where a name may belong to two different namespaces, one must use the name() function in order for these names to be still distinguished.

    And, BTW, it is possible to specify both functions without any argument:

    name() is an abbreviation for name(.)

    local-name() is an abbreviation for local-name(.)

    Finally, do remember that not only elements and attributes have names, these two functions can also be used on PIs and on these they are identical).

提交回复
热议问题