xsl:attribute

Creates an attribute.

Format

<xsl:attribute name="qualified_name"> 
  attribute_value 
</xsl:attribute> 

Description

You can specify the xsl:attribute instruction in the

In a stylesheet element that creates a result element, the xsl:attribute instruction causes an attribute to be added to the created result element.

The prefix part of the name attribute value becomes the prefix for the attribute you are creating. The local part of the name attribute value becomes the local name of the attribute you are creating.

The XSLT processor interprets the name attribute as an attribute value template. The string that results from instantiating the attribute value template must be a qualified name. If it is not, the XSLT processor reports an error.

The result of instantiating the content of the xsl:attribute instruction is used as the value of the created attribute. It is an error if instantiating this content generates anything other than characters.

If you add an attribute to an element and that element already has an attribute with the same expanded name, the attribute you are creating replaces the existing attribute.

Example

<xsl:attribute name="library:ISBN"  
     namespace="http://www.library.org/namespaces/library"> 
     1-2222-333-4 
</xsl:attribute> 

If this instruction is inside a book element, the resulting book element would include the following attribute:

library:ISBN="1-22222-333-4" 

The XSLT processor reports an error if you try to do any of the following:

Developer Resource Center: Learn XML and Stylus Studio

Learning XML is easy with Stylus Studio. Check out our free XML tutorials, XML whitepapers, online video demonstrations, XML examples and XML references and more.

XSL:FO Editor

The XSL-FO editor provides syntax help, code completion integrated PDF preview, and integration with industry-leading XSL-FO processors including RenderX XEP and Apache FOP. Simplify XSL FO development with Stylus Studio.

XQuery Mapper

Stylus Studio has the industry's only XQuery mapper, enabling you to develop sophisticated XML mappings consisting of queries and data transformation in an intuitive, visual manner.

XQuery and Web Services

XQuery provides a flexible means for data abstraction, while Web services provide process abstraction. In this online video demonstration, learn how integrated XQuery & Web service tools simplify development of XQuery-based Web service applications.

Stylus Most Wanted

 
Free Stylus Studio XML Training:
W3C Member