XSLT(7) Attribute Value Template

来源:互联网 发布:多功能网络电力仪表 编辑:程序博客网 时间:2024/05/17 23:26

An attribute value template is an XPath expression enclosed in curly braces that's placed in the attribute value in the stylesheet. When the processor outputs that attribute, it replaces the attribute value template with its value.


For example, suppose you wanted to write a name template that changed the input name elements to empty elements with first_name, middle_initial, and last_name attributes like this:

<name first="Richard" initial="P" last="Feynman"/>

This template accomplishes that task:

<xsl:template match="name"><name first="{first_name}"initial="{middle_initial}"last="{last_name}" /></xsl:template>

Without attribute value templates, we have to use <xsl:attribute> to achieve the same functionality.