[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: Conny Krappatsch <conny@xxxxxxxxxxx>
Date: Mon, 4 Dec 2000 11:42:07 +0100
conny krappatsch
On Sun, 3 Dec 2000 13:10:20 +0200
"Shlomi Sarfati" <shlomi@xxxxxxxxxx> wrote:

Let's see if I understood you right. You have a XML tree which can contain <modified/> tags. If it does contain at least one of those tags, the result tree top element shall contain an attribute "modified" with value "true" and if not with value "false". Is that right?
If so, the following should do the job:

<xsl:template match="/">
    <newTopElement>

        <xsl:attribute name="modified">
            <xsl:choose>
                <xsl:when test="//modified">true</xsl:when>
                <xsl:otherwise>false</xsl:otherwise>
            </xsl:choose>
        </xsl:attribute>

    </newTopElement>
</xsl:template>

In fact, you could place the <xsl:attribute> part everywhere in your stylesheet. It will always add a "modified" attribute to the wrapping element with value "true" if the document contains <modified> tags, and "false" otherwise. If you change the value of the <xsl:when> "test" attribute you can check several part of the document for <modified> tags, as well.

Hope that helps,

Conny Krappatsch

> 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 !
> 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.
> I need to hold a flag that will tell me if one of the nodes has been
> modified !
> this flag will be the attribute of the first tag in my result tree. does it
> means that I need to check the source tree first
> for all the <modified> tags and then run my xsl (if so how should I do it
> ? )
> can you do something like this ?
> 
> 
> <xsl:variable name="valueofFlag"> false </xsl:variable>
> 
> 
> <xsl:template match="/">
> 	<head>
> 		<xsl:element name="menu">
> 			<xsl:attribute name="color">black</xsl:attribute>
> 			<xsl:apply-templates/>
> 			<xsl:attribute name="modified"> <xsl:copy-of select="$valueofFlag"/>
> </xsl:attribute>
> 		</xsl:element>
>  	</head>
> </xsl:template>
> 
> <xsl:template match="//child">
> 	<xsl:choose>
> 	   <xsl:when test ="//*[@modified='true']"> <xsl:variable
> name="valueofFlag"> true </xsl:variable>  </xsl:when>
> 	   <xsl:otherwise></xsl:otherwise>
> 	</xsl:choose>
> </xsl:template>
> 	.
> 	.
> 	.
> 	.
> 
> 
> this is example of my xml :
> 
> 
> <?xml version="1.0"?>
> <data_xml>
> 	  <list>
> 		<dynamic_menu_id>1003</dynamic_menu_id>
> 		<PARENT_ID>1003</PARENT_ID>
> 		<name>first child</name>
> 	      <position>1</position>
> 		<modified>true</modified>
> 		 <object>
> 		    <dynamic_menu_id>1004</dynamic_menu_id>
> 		    <object_name>Accounting</BUTTON_NAME>
> 		    <position>1</position>
>         	     <modified/>
> 		 </object>
> 	  	 <object>
> 		    <dynamic_menu_id>1005</dynamic_menu_id>
> 		    <object_name>management</BUTTON_NAME>
> 		    <position>2</position>
>         	     <modified/>
> 		 </object>
> 	  	 <object>
> 		    <dynamic_menu_id>1006</dynamic_menu_id>
> 		    <object_name>xxxx</BUTTON_NAME>
> 		    <position>3</position>
>         	     <modified/>
> 		 </object>
> 	  	 <object>
> 		    <dynamic_menu_id>1007</dynamic_menu_id>
> 		    <object_name>yyy</BUTTON_NAME>
> 		    <position>4</position>
>         	     <modified/>
> 		 </object>
> 	  </list>
> </data_xml>
> 
> 
> 
> 
> 
> 
> 
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


-- 
______________________________________________________________________
Conny Krappatsch                              mailto:conny@xxxxxxxxxxx
SMB GmbH                                        http://www.smb-tec.com




 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.