dvdvorle
dvdvorle

Reputation: 961

Get a nodeset of all local-names with xpath

With XPath 1.0, Instead of

<xsl:for-each select="*">
  <xsl:variable name="varName" select="local-name()" />
  <!-- Do stuff with $varName -->
</xsl:for-each>

I really want to do something like

<xsl:for-each select="*/local-name()">
  <!-- Do stuff with . ('.' as in the current value) -->
</xsl:for-each>

or

<xsl:for-each select="local-name(*)">
  <!-- Do stuff with . ('.' as in the current value) -->
</xsl:for-each>

Is there any way to do this?

Upvotes: 2

Views: 1112

Answers (1)

Michael Kay
Michael Kay

Reputation: 163352

A node set contains nodes. It doesn't contain names. Therefore your question contains the contradiction that proves it can't be done.

The XPath 2.0 data model makes it perfectly possible to manage a collection of names as a value. But XPath 1.0 only allows node-sets, or singleton strings, booleans, and numbers.

Upvotes: 2

Related Questions