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

RE: Simple attribute value replacement question

Subject: RE: Simple attribute value replacement question
From: Edward.Middleton@xxxxxxxxxxx
Date: Tue, 29 Jan 2002 13:49:36 +0900
simple attribute
There are two mistakes

	<xsl:value-of select="canine">
	gets the value of the canine attribute which doesn't exist so it returns nothing.
	You only have a dog attribute and you are not interested in its value you want to set it so you should use

	<xsl:attribute name="type">canine</xsl:attribute>

	you don't copy the <pet> before you try to add an attribute to it.  In your example it is actually copied by
	<xsl:copy-of select = "."/> 

	which occurs after you have tried to set the type attribute.  The following uses xsl:copy to copy pet.

		<xsl:apply-templates select="@type"/>
		<xsl:copy-of select = "child::*"/> 		-- you use child::* because you have allready
							   copied the current tag i.e. pet

The following should work.

<?xml version = "1.0" encoding = "UTF-8"?>
<xsl:transform xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
version = "1.0">

<xsl:template match = "petXML">
		<xsl:apply-templates select = "*"/>

<xsl:template match = "pet">
		<xsl:apply-templates select="@type"/>
		<xsl:copy-of select = "child::*"/>

<xsl:template match="@type[.='dog']">
	<xsl:attribute name="type">canine</xsl:attribute>



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread


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.
First Name
Last Name
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.