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

  • Contents of a stylesheet element that creates a result element
  • Contents of an xsl:attribute-set instantiation

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:

  • Add an attribute to a node that is not an element.
  • Add an attribute to an element that already has child nodes.
  • Create anything other than characters during instantiation of the contents of the xsl:attribute element.

Stylus Studio Blogs

Blogging is the hottest fad on the Internet and Stylus Studio has jumped on the bandwagon. Bookmark these XML Blogs to keep up with all the latest XML buzz in the internet blogosphere. Includes RSS and Atom Feeds!

XSLT Debugger

Stylus Studio's XSLT debugger - a requirement for building bug-free XSLT stylesheets and XML data transformation applications. Stylus Studio's XSLT debugger gives you complete visibility and control over the XSLT transformation process.

XML Applications

XML Applications are software applications that process data using standard XML technologies like XML, XML Schema, XSLT and XQuery. Using Stylus Studio XML Pipeline, learn how to model, edit, test and deploy an XML Application with ease.

XML File Explorer

The XML File Explorer provides a productive, consistent, and easy-to-use interface for working with any data sources (relational data, EDI, binary, XML, CSV, and more) used in enterprise data integration projects.

Stylus Most Wanted

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.