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

RE: XSL and javascript

Subject: RE: XSL and javascript
From: "Mac Martine" <email@xxxxxxxxxxxxxxxx>
Date: Wed, 12 Mar 2003 09:57:02 -0800
xsl back button

Hello-
 	I am trying to simply duplicate an XML tree with the addition of
adding an attribute to all the ancestors of a given element.

	In the example provided I am trying to copy all elements, but
when I find an element where @task='1', I want to give all of its
ancestors an attribute called 'task' as well. My current code is below.
 
Can anyone please help? 
 
Thanks so much-
  Mac


XML
======================
======================

<desktop id="desktop">
	<testSuite currentTask="1"/>
	<panel id="main">
		<panel id="toolbar">
			<button id="toolbar.back" task="1">Back</button>
			<button id="toolbar.forward"></button>
			<button id="toolbar.home">Show All</button>
			<button id="toolbar.importFromCamera"></button>
			<button id="toolbar.organize">Organize</button>
			<button id="toolbar.fix">Fix</button>
			<button id="toolbar.create">Create</button>
			<button id="toolbar.share"></button>
			<button id="toolbar.order">Order Online</button>
			<button id="print_tb"></button>
			<button
id="toolbar.slideshow">Slideshow</button>
			<button id="toolbar.slideshowOptions"></button>
			<button id="toolbar.calendar">Calendar</button>
			<button id="toolbar.calendarOptions"></button>
			<button id="howto_tb">Quick Guide</button>
			<button id="toolbar.adobe"></button>
			<QFrame id="v rule"/>
			<QFrame id="v rule"/>
		</panel>
	</panel>
</desktop>


XSL
======================
======================

<?xml version="1.0"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
	<root>
		<xsl:apply-templates />
	</root>
</xsl:template>

<xsl:template match="*">

	<xsl:if test="@task='1'">
		<xsl:call-template name="ancest" />
	</xsl:if>

	<xsl:if test="not(@task='1')">
		<xsl:copy-of select="." />
	</xsl:if>
	
</xsl:template>

<xsl:template name="ancest">

	<xsl:for-each select="ancestor::*[1]">
		<xsl:element name="elementName">
			<xsl:value-of select="name()" />
			<xsl:attribute name="task">
				<xsl:value-of select="1.1" />
			</xsl:attribute>
		</xsl:element>
	</xsl:for-each>

</xsl:template>

</xsl:stylesheet>


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


Current Thread
  • XSL and javascript
    • jeff - Tue, 11 Mar 2003 14:47:28 -0500 (EST)
      • <Possible follow-ups>
      • Passin, Tom - Tue, 11 Mar 2003 16:09:22 -0500 (EST)
        • jeff - Tue, 11 Mar 2003 17:55:16 -0500 (EST)
      • Passin, Tom - Wed, 12 Mar 2003 12:16:53 -0500 (EST)
        • Mac Martine - Wed, 12 Mar 2003 13:03:02 -0500 (EST) <=

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.