[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Using a template to transform a node attribute

Subject: Re: Using a template to transform a node attribute
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 12 Sep 2005 17:00:08 +0100
transform node attribute formatting
> As written, this template matches an element node, so the attribute tag 
> would need to be wrapped in an element, as you indicate.

The template was perfectly valid as it stood. The element that contains
the attribute in the result tree does not have to be generated by the
same template as generates the attribute.

<xsl:template match="/report/version[@id]">
  <xsl:attribute name="id">bar</xsl:attribute>
</xsl:template>


<xsl:template match="/report/version/@id">
  <xsl:attribute name="id">bar</xsl:attribute>
</xsl:template>

Both have the same status. If they are triggerd by an apply-templates in
a context such as

<foo>
 <xsl:apply-templates select=",,,,,

Then they are OK, and add an id attribute to foo.

If they are triggered by a context such as

<foo>
 some text
 <xsl:apply-templates select=",,,,,

then they are an error as you can't add attribute after the text node
has been added.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
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-2013 All Rights Reserved.