xsl:element

Syntax

<xsl:element>
     Template-Body
</xsl:element>


Postition

innerhalb des Template-Bodys


Attribute
Bezeichnung Wert Bedeutung
name {QName} Name des zu generierenden Elements
namespace {uri} Namespace für das zu generierende Element
use-attribute-sets list-of-QNames Attribut-Sets, die dem zu generierendem Element hinzugefügt werden

<xsl:element>

generiert einen Elementknoten an die aktuelle Position des Output-Dokuments.


Definition

XSLT Kapitel 7.1.2


Beispiel

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html"/>
    
<xsl:attribute-set name="default-table">
     <xsl:attribute name="BORDER">0</xsl:attribute>
     <xsl:attribute name="CELLSPACING">0</xsl:attribute>
     <xsl:attribute name="CELLPADDING">0</xsl:attribute>
</xsl:attribute-set>

<xsl:attribute-set name="aqua-table" use-attribute-sets="default-table">
     <xsl:attribute name="BGCOLOR">AQUA</xsl:attribute>
     <xsl:attribute name="BORDER">1</xsl:attribute>
</xsl:attribute-set>    

<xsl:template match="/">
     <HTML>
          <HEAD>
               <TITLE>Element: &lt;xsl:element&gt; / Beispiel 01</TITLE>
          </HEAD>
          <BODY>
               <xsl:apply-templates select="shop"/>
          </BODY>
     </HTML>
</xsl:template>

<xsl:template match="shop">
     <xsl:element name="TABLE" use-attribute-sets="aqua-table">
          <TR>
               <TH WIDTH="150">Abteilung:</TH>
               <TH WIDTH="100">Artikel:</TH>
               <TH WIDTH="100">Preis:</TH>
          </TR>
          <xsl:apply-templates select="order/product"/>
     </xsl:element>
</xsl:template>

<xsl:template match="product">
     <TR>
          <TD><xsl:value-of select="@department"/></TD>
          <TD><xsl:value-of select="name"/></TD>
          <TD ALIGN="RIGHT">
               <xsl:value-of select="price"/>
               <xsl:text> </xsl:text>
               <xsl:value-of select="currency"/>
          </TD>
     </TR>
</xsl:template>

</xsl:stylesheet>


© 2001 by Timo Schäfer