August 2001
Intermediate to advanced
480 pages
11h 16m
English
name() Function — Returns the qualified name of a node. The qualified name includes the appropriate namespace prefix. For information on the namespace URI (not the prefix), XPath provides the namespace-uri() function.
stringname(node-set?)
An optional node-set. If no node-set is given, the name() function creates a node-set with the context node as its only member.
The expanded name of the node. If the argument node-set is empty, or if the first node in the node-set does not have an expanded name, an empty string is returned.
XPath section 4.1, Node Set Functions.
Here is the XML document we’ll use to demonstrate the name() function:
<?xml version="1.0"?>
<report>
<title>Miles Flown in 2001</title>
<month sequence="01">
<miles-flown>12379</miles-flown>
<miles-earned>35215</miles-earned>
</month>
<month sequence="02">
<miles-flown>32857</miles-flown>
<miles-earned>92731</miles-earned>
</month>
<month sequence="03">
<miles-flown>19920</miles-flown>
<miles-earned>76725</miles-earned>
</month>
<month sequence="04">
<miles-flown>18903</miles-flown>
<miles-earned>31781</miles-earned>
</month>
</report>We’ll use this stylesheet to output the value of the name() function for each node in the XML document:
<?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 ...