local-name() Function |
Returns the local part of the first node in the argument node-set.
Inputs
A node-set. If the node-set is empty, the function returns an empty string. If the node-set is omitted, the function uses a node-set with the context node as its only member.
Output
A string corresponding to the local name of the first element in the argument node-set. If the node-set is empty, the local-name() function returns an empty string.
Defined in
XPath section 4.1, Node Set Functions.
Example
Here is a stylesheet that uses the document() function to process all its own nodes. It then calls the local-name() function against each node.
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:months="Lookup table for month names">

      <months:name sequence="12">December</months:name>
      <months:name sequence="01">January</months:name>
      <months:name sequence="02">February</months:name>
      <months:name sequence="03">March</months:name>
      <months:name sequence="04">April</months:name>
      <months:name sequence="05">May</months:name>
      <months:name sequence="06">June</months:name>
      <months:name sequence="07">July</months:name>
      <months:name sequence="08">August</months:name>
      <months:name sequence="09">September</months:name>
      <months:name sequence="10">October</months:name>
      <months:name sequence="11">November</months:name>

      <xsl:output method="text"/>

      <xsl:variable name="newline">
    <xsl:text>
    </xsl:text>
      </xsl:variable>

      <xsl:template match="/">
        <xsl:value-of select="$newline"/>
        <xsl:text>A test of the local-name() function:</xsl:text>

        <xsl:value-of select="$newline"/>
        <xsl:value-of select="$newline"/>
        <xsl:for-each select="document('')//*">
          <xsl:text>local-name: </xsl:text>
          <xsl:value-of select="local-name()"/>
          <xsl:value-of select="$newline"/>
        </xsl:for-each>
      </xsl:template>

    </xsl:stylesheet>
The stylesheet generates these results:
    A test of the local-name() function:

    local-name: stylesheet
    local-name: name
    local-name: name
    local-name: name
    local-name: name
    local-name: name
    local-name: name
    local-name: name
    local-name: name
    local-name: name
    local-name: name
    local-name: name
    local-name: name
    local-name: output
    local-name: variable
    local-name: text
    local-name: template
    local-name: value-of
    local-name: text
    local-name: value-of
    local-name: value-of
    local-name: for-each
    local-name: text
    local-name: value-of
    local-name: value-of