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

RE: scanning a tree (again)

Subject: RE: scanning a tree (again)
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Mon, 4 Dec 2000 11:03:10 -0000
scanning dom tree
> I am sorry for sending this question again but I didn't got 
> the answer that
> I need maybe because I didn't explained my self !

Yes, I didn't understand your question first time around and I'm not sure I
fully understand it now.

> I need to run an xsl stylesheet on my xml tree that do the following :
> on every node in my xml tree I have a tag named 'modified' 
> that tells me if the current node has been modified.

By "every node" do you mean "every element"?
By "xml tree" do you mean an XPath tree, or a DOM tree? How is this tree
constructed?
By "tag" do you mean "attribute?"

> I need to hold a flag that will tell me if one of the nodes has been
> modified !

You can set a variable as follows:

<xsl:variable name="modified" select="//*[@modified]"/>

This boolean variable will be true if any element on the source tree has a
"modified" attribute.

> this flag will be the attribute of the first tag in my result 
> tree.

You can write this to the output using something like:

<first-element>
  <xsl:attribute>
    <xsl:choose>
    <xsl:when test="$modified">yes</xsl:when>
    <xsl:otherwise>no</xsl:otherwise>
    </xsl:choose>
  </xsl:attribute>
  ...
</first-element>

> can you do something like this ?
> 
> 
> <xsl:variable name="valueofFlag"> false </xsl:variable>
> 
> 	   <xsl:when test ="//*[@modified='true']"> <xsl:variable
> name="valueofFlag"> true </xsl:variable>  </xsl:when>

You can do it, but it won't have the desired effect. XSLT is a language free
of side-effects, it doesn't have a conventional assignment statement. Your
xsl:when is creating a new variable, which goes out of scope immediately. It
is not modifying the value of the global variable.

Mike Kay 


 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.