Name

<xsl:attribute>

Allows you to create an attribute in the output document. Using the <xsl:attribute> instruction allows you to determine the name or content of an attribute at runtime. You can build the attribute’s name or value from parts of the input document, hardcoded text, values returned by functions, global variables, and any other value you can access from your stylesheet. You can also use <xsl:if> to determine whether the attribute should be created at all.

Category

Instruction.

Required Attribute

name

The name attribute defines the name of the attribute created by the <xsl:attribute> element. (No matter how you try to say this, talking about the attributes of the <xsl:attribute> element is confusing, isn’t it?)

Optional Attributes

namespace

The namespace attribute defines the namespace URI that should be used for this attribute in the output document. You don’t have control over the namespace prefix used; the only thing you specify with the namespace attribute is the namespace’s URI.

[2.0] select

An XPath expression that defines the content of this attribute. If the <xsl:attribute> element has a select attribute, the element must be empty.

[2.0] separator

Defines the characters that separate multiple values generated by the <xsl:attribute> instruction. If <xsl:attribute> has a select attribute, the default value is a single space (#x20). Without a select attribute, the default value is a zero-length string (""). The separator attribute overrides the default value whether select ...

Get XSLT, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.