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

Re: Add attribute to all node

Subject: Re: Add attribute to all node
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 29 Apr 2004 14:23:50 +0100
xsl loop on all node
> It adds the attribute only in root element.


Strange I would have expected it to work, but it is rather a strange
stylesheet.

<xsl:template match="//*">

That matches exactly the same elements as

<xsl:template match="*">

The only function of // is to change the default priority.
That means this template has higher priority for * than 

<xsl:template match="*|text()|@*">
	<xsl:copy>
		<xsl:apply-templates select="*|text()|@*"/>
	</xsl:copy>
</xsl:template>

which is good, otherwise there would be a recoverable error condition.
Since this second template will never fire for elements, you needn't
have * in the match and you needn't apply xsl:templates to teh chidren
as there are no children.

So all you need is something like

<xsl:stylesheet...
<xsl:template match="*">
	<xsl:copy>
		<xsl:copy-of select="@*"/>
		<xsl:attribute name="test1">Name</xsl:attribute>
		<xsl:apply-templates/>
	</xsl:copy>
</xsl:template>

</xsl:stylesheet>


Which processor are you using? perhaps it is not setting the priority
for //* correctly and treating it like * in which case I would have
expected that your second template was always used, and teh attribute
was never added. (That would still be a bug)

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. 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.