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

Re: identity transformation problem

Subject: Re: identity transformation problem
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 13 Mar 2003 15:51:35 -0500
identity transformation
At 2003-03-13 11:54 -0800, Mac Martine wrote:
 I am basically doing an identity transformation (copying xml tree), but
adding attributes in certain places.

An XSLT stylesheet is obliged to produce the result tree in result parse order, so for the bulk of your transform, the copying of the source XML tree to the result tree is straightforward.


I need to change the value of an attribute in my 'testSuite' element to
one value if I add a @task attribute to any element. If I don't add an
@task attribute to any elements then I want to update that attribute in
the 'testSuite' element to a different value. This 'testSuite' element
is always a child of the root element. I can't figure out how to do
this...

You are using the terms "change" and "update" ... but you cannot do that to the result tree. Once created, nodes in the result tree cannot be changed. The processor isn't even obliged to keep it around in memory and can serialize it instantly to a result file if you are asking the processor to produce syntax for your result.


Your obligation is not to "change" or "update" the result tree, but to put out the result tree as desired *the first time around*. This requires you to do all of your logic for the value of the testSuite attribute *at the time the testSuite attribute is added to the result tree*, which will be long before you actually get around to putting out the individual attributes deep inside the tree.

This isn't as difficult as it may sound ... at the time you are doing the testSuite child of the document element, at the time you need to add the currentTask attribute, do whatever checking you need to do through the entire source node tree to establish the value of @currentTask. Then continue producing the result tree doing whatever you need to do with the individual constructs, knowing that when you did the testSuite element you already set its attribute value as desired.

I hope this helps.

.............. Ken

--
Upcoming hands-on in-depth XSLT/XPath and/or XSL-FO
                             North America:      June 16-20, 2003

G. Ken Holman                mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.         http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0   +1(613)489-0999 (F:-0995)
ISBN 0-13-065196-6                      Definitive XSLT and XPath
ISBN 0-13-140374-5                              Definitive XSL-FO
ISBN 1-894049-08-X  Practical Transformation Using XSLT and XPath
ISBN 1-894049-10-1              Practical Formatting Using XSL-FO
Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc


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



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.