Freigeben über


name-Funktion

Gibt eine Zeichenfolge zurück, die einen QName enthält, der den erweiterten Namen des Knoten im node-set-Argument darstellt, der in der Dokumentreihenfolge an erster Stelle steht.

string name(node-set?)

Hinweise

Der QName muss den erweiterten Namen in Bezug auf den für den Knoten gültigen Namespace darstellen. Dies ist nicht erforderlich, wenn für den Knoten Namespacedeklarationen gelten, die demselben Namespace mehrere Präfixe zuordnen. Wenn das node-set-Argument leer ist oder der erste Knoten nicht über einen erweiterten Namen verfügt, wird eine leere Zeichenfolge zurückgegeben. Wenn das Argument weggelassen wird, erfolgt als Standard eine Konvertierung in eine Knotengruppe mit dem Kontextknoten als einzigem Member.

Beispiel

XML-Datei (bcat.xml)

<?xml version='1.0'?>
<?xml-stylesheet type="text/xsl" href="sample.xsl"?>
<b:catalog xmlns:b="x-schema:book-schema.xml">
   <b:book id="bk101">
      <b:author>Gambardella, Matthew</b:author>
      <b:title>XML Developer's Guide</b:title>
      <b:genre>Computer</b:genre>
      <b:price>44.95</b:price>
      <b:publish_date>2000-10-01</b:publish_date>      
      <b:description>An in-depth look at creating applications with XML.</b:description>
   </b:book>
   <b:book id="bk102">
      <b:author>Ralls, Kim</b:author>
      <b:title>Midnight Rain</b:title>
      <b:genre>Fantasy</b:genre>
      <b:price>5.95</b:price>
      <b:publish_date>2000-12-16</b:publish_date>
      <b:description>A former architect battles corporate zombies, an evil sorceress, and her own childhood to become queen of the world.</b:description>
   </b:book>
</b:catalog>

XSLT-Datei (sample.xsl)

<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>

<xsl:template match="/">
    <html>
       <body>
          <h3>name() Function</h3>
          
          <xsl:apply-templates />
                   
       </body>
    </html>
</xsl:template>

<xsl:template match="*">
    <xsl:value-of select="name()"/> = <xsl:value-of select="text()"/><br/>
    <xsl:apply-templates select="*"/>
</xsl:template>

</xsl:stylesheet>

XSLT-Hilfsdatei (book-schema.xml)

<Schema name="books" xmlns="urn:schemas-microsoft-com:xml-data"
           xmlns:dt="urn:schemas-microsoft-com:datatypes">
   <ElementType name="author"/>
   <ElementType name="title"/>
   <ElementType name="genre"/>
   <ElementType name="price"/>
   <ElementType name="publish_date"/>
   <ElementType name="description"/>
   <AttributeType name="id" dt:type="id"/>
         
   <ElementType name="catalog">
      <element type="book"/>
   </ElementType>
         
   <ElementType name="book" model="closed" content="eltOnly">
      <attribute type="id"/>
      <element type="author"/>
      <element type="title"/>
      <element type="genre"/>
      <element type="price"/>
      <element type="publish_date"/>
      <element type="description"/>
   </ElementType>
</Schema>

Formatierte Ausgabe

name() Function

b:catalog =

b:book =

b:author = Gambardella, Matthew

b:title = XML Developer's Guide

b:genre = Computer

b:price = 44.95

b:publish_date = 2000-10-01

b:description = An in-depth look at creating applications with XML.

b:book =

b:author = Ralls, Kim

b:title = Midnight Rain

b:genre = Fantasy

b:price = 5.95

b:publish_date = 2000-12-16

b:description = A former architect battles corporate zombies, an evil sorceress, and her own childhood to become queen of the world.

Prozessorausgabe

<html>

<body>

<h3>name() Function</h3>b:catalog = <br>b:book = <br>b:author = Gambardella, Matthew<br>b:title = XML Developer's Guide<br>b:genre = Computer<br>b:price = 44.95<br>b:publish_date = 2000-10-01<br>b:description = An in-depth look at creating applications with XML.<br>b:book = <br>b:author = Ralls, Kim<br>b:title = Midnight Rain<br>b:genre = Fantasy<br>b:price = 5.95<br>b:publish_date = 2000-12-16<br>b:description = A former architect battles corporate zombies, an evil sorceress, and her own childhood to become queen of the world.<br></body>

</html>

Siehe auch

Verweis

Referenz zu XML-Datentypen