A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z
erzeugt im umschließenden Element des Ergebnisbaumes im Ergebnisdokument ein Attribut. Wahlweise kann die Instruktion auch die xsl:copy- oder xsl:element-Instruktionen umschließen. In dem Fall würde die xsl:attribute-Instruktion dem eben erzeugten Element das Attribut hinzufügen.
Es ist zu berücksitigen, dass zwischen dem Element indem das Attribut eingefügt werden soll und der xsl:attribute-Instruktion keine anderen Konstrukte, wie z.B. Text, Kommentare, Processing-Instructions, etc., erzeugt werden dürfen.
Im Attribut name wird der Name des erzeugten Attributes angegeben. Der Wert des Attributes ergibt sich durch den Inhalt der Instruktion. Mittels dem Attribut namespace kann dem Attributnamen ein Namensraum zugeordnet werden.
Attribute
name, namespace, select, separator, type, validation<?xml version="1.0"encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="xml"></xsl:output> <xsl:template match="/"> <html> <head> <title>attribute</title> </head> <body> <xsl:variable name="attribute">id</xsl:variable> <p> <xsl:attribute name="{$attribute}"> <xsl:value-of select="/root/section[1]/para/generate-id()"> </xsl:value-of></xsl:attribute> <xsl:value-of select="/root/section[1]/para"></xsl:value-of> </p> </body> </html> </xsl:template> </xsl:stylesheet>
<?xml version="1.0"encoding="UTF-8"?> <html> <head> <title> attribute </title> </head> <body> <p id="d1e5">Paragraph 1</p> </body> </html>
| > nach oben | |
| > zurück zur alphabetischen Liste der XSLT Elemente |