Functions name, local-name, and namespace-uri() are used to get informations about element and attribute names and namespaces : local name « XSLT stylesheet « XML Tutorial

XML Tutorial
1. Introduction
2. Namespace
3. XML Schema
4. XPath
5. XSLT stylesheet
Java
XML
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
XML Tutorial » XSLT stylesheet » local name 
5. 59. 1. Functions name, local-name, and namespace-uri() are used to get informations about element and attribute names and namespaces
local-name()- Takes zero or one node-sets as its argument and returns the local part of the element name if it exists; if no argument node-set exists, it returns the local part of the name of the context node.  


File: Data.xml
<?xml version="1.0" encoding="utf-8"?>
<data xmlns:standard="http://www.w3.org/1999/XSL/Transform"
      xmlns:java2s="http://www.java2java.com">
    <standard:id>standardAAA</standard:id>
    <standard:size>258</standard:size>
    <java2s:id>java2s1258</java2s:id>
</data>
File: Transform.xslt

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
      <TABLE border="1">
        <TR>
          <td>name</TH>
          <td>local</TH>
          <td>URI</TH>
        </TR>
        <xsl:apply-templates select="//*"/>
      </TABLE>
    </xsl:template>
    <xsl:template match="*">
      <TR>
        <TD>
          <xsl:value-of select="name()"/>
        </TD>
        <TD>
          <xsl:value-of select="local-name()"/>
        </TD>
        <TD>
          <xsl:value-of select="namespace-uri()"/>
        </TD>
      </TR>
    </xsl:template>
</xsl:stylesheet>
Output:

<?xml version="1.0" encoding="UTF-8"?><TABLE border="1"><TR><td>name</TH><td>local</TH><td>URI</TH></TR><TR><TD>data</TD><TD>data</TD><TD/></TR><TR><TD>standard:id</TD><TD>id</TD><TD>http://www.w3.org/1999/XSL/Transform</TD></TR><TR><TD>standard:size</TD><TD>size</TD><TD>http://www.w3.org/1999/XSL/Transform</TD></TR><TR><TD>java2s:id</TD><TD>id</TD><TD>http://www.java2java.com</TD></TR></TABLE>
5. 59. local name
5. 59. 1. Functions name, local-name, and namespace-uri() are used to get informations about element and attribute names and namespaces
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.