Get current node's local-name in XSL

Posted by green67 on Stack Overflow See other posts from Stack Overflow or by green67
Published on 2010-05-13T21:43:54Z Indexed on 2010/05/13 22:04 UTC
Read the original article Hit count: 150

Filed under:

Here's the structure of my XML

<FileRoot>
    <UserSet1>
         <User>
            <FirstName></FirstName>
            <LastName></LastName>
         </User>
         <User>
            <FirstName></FirstName>
            <LastName></LastName>
         </User>
         ...
    </UserSet1>
    <InactiveUsers>
         <User>
            <FirstName></FirstName>
            <LastName></LastName>
         </User>
         <User>
            <FirstName></FirstName>
            <LastName></LastName>
         </User>
         ...
    </InactiveUsers>
</FileRoot>

In my XSL template

<xsl:template match="/*/*">
   <File>
      <xsl attribute name="Name">
          <xsl:value-of select="local-name(/*/*)"/>
      </xsl:attribute>
   </File>
</xsl>

After transforming, for both UserSet1 and InactiveUsers, gave me "UserSet1". The expected results should be "UserSet1" for UserSet1, and "InactiveUsers" for InactiveUsers. How do I correctly retrieve the value?

Thanks

© Stack Overflow or respective owner

Related posts about xsl