<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../make-menu.xsl" type="text/xsl"?><html>
   <head>
      <this-is section="xsl-elements" page="element" subpage=""/>
      <!--
           Generated at 2010-10-29T18:20:48.427+01:00--><title>Saxonica: XSLT and XQuery Processing: xsl:element</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title" content="Saxonica: XSLT and XQuery Processing: xsl:element"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>xsl:element</h1>
      <p>The <code>xsl:element</code> instruction is used to create an output element 
whose name might be calculated at run-time.</p>
      <p>The element has a mandatory attribute, <code>name</code>, which is the name of the generated element.
 The name attribute is an <i>attribute value template</i>, so it may contain string expressions inside
 curly braces.</p>
      <p>The attributes of the generated element are defined by subsequent <code>xsl:attribute</code> elements. The
content of the generated element is whatever is generated between the <code>&lt;xsl:element&gt;</code> and
<code>&lt;/xsl:element&gt;</code> tags.</p>
      <p>Additionally, attributes of the generated element can be defined by reference to a named attribute set.
The optional use-attribute-sets attribute contains a white-space-separated list of attribute set names. They
are applied in the order given: if the same attribute is generated more than once, the later value always takes
precedence.</p>
      <p>For example, the following code creates a &lt;FONT&gt; element with several attributes:</p>
      <div class="codeblock"
           style="border: solid thin; background-color: #B1CCC7; padding: 2px">
         <pre>
            <code>&lt;xsl:element name="FONT"&gt;
    &lt;xsl:attribute name="SIZE"&gt;4&lt;/xsl:attribute&gt;
    &lt;xsl:attribute name="FACE"&gt;Courier New&lt;/xsl:attribute&gt;
Some output text
&lt;/xsl:element&gt;</code>
         </pre>
      </div>
      <p>A new attribute <code>type-annotation</code> is available in XSLT 2.0. This indicates the
data type of the value of the element. In Saxon 7.3, the value must be a built-in type defined
in XML Schema, for example <code>xs:integer</code> or <code>xs:date</code>. Type annotations
are only accessible if the attribute is added to a temporary tree that specifies 
<code>type-information="preserve"</code>. The value given to the element must be a string
that conforms to the rules for the data type, as defined in XML Schema. In particular
this means that the element must not have any element children.</p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="evaluate.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>