caucho
 Attribute Value Templates


Because calculating attributes is very common, the XSLT standard adds a special syntax for attribute value templates. A stylesheet can uses an attribute value template to calculate the template value for the element directly. Curly brackets introduce a value-of expression, e.g. "{@class}". The following stylesheet is a direct translation of the previous example.

default.xsl
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="box">
  <table class="{@class}">
    <tr>
      <td>
        <xsl:apply-templates/>
      </td>
    </tr>
  </table>
</xsl:template>

</xsl:stylesheet>

The example XTP and its generated HTML is identical to the previous example since attribute value templates are just a syntactic shortcut.

hello.xtp

<example>
This is an example.
</example>

<table class="example">
<tr>
  <td>This is an example</td>
</tr>
</table>

Summary

  • "{...}" interpolates an attribute's value.

Copyright © 1998-2002 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark, and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc.