This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: scanning a tree (again)


> 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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]