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
> 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
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:

    <xsl:when test="$modified">yes</xsl:when>

> 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:

Current Thread