[xsl] Transforming a node in XSL multiple times

Subject: [xsl] Transforming a node in XSL multiple times
From: "Spencer" <spencer@xxxxxxxxxxxx>
Date: Tue, 29 Oct 2002 09:21:21 +0200
 Hi!
 
 We have a tag like this <img src="hello.bmp"/> and we want to perform
 multiple transformations on it such as adding alt and width
 attributes.  This can be done in one template quite easily.
 
However, the problem arises if we need to change this tag again but
 through a different Xpath.  For example, we do a template match on img
 and add alt and width attributes.  Then we do a template match on the
 div and because it has a center alignment, we now want to add the
 height attribute to the preceeding image using the xpath
 preceding::img
 
 <img src="hello.bmp"/>
 <div align="center"/>
 
 This is a completely arbitary example, there are many different cases
 when we need to do similiar transformations to the same tag but from
 more than one template and/or a different XPath that points to the
 same tag.
 
 In the template we use xsl:copy to output the tag and its changes. 
 This prints the tag to the result tree, but we can no longer change it
 in a different template.  If we do (using another xsl:copy) the img is
 printed out again with different attributes.
 
 How can we change this tag multiple times from multiple templates but
 have it only printed out once with all the changes to it?
 
 Thank you in advance for your help



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


Current Thread