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

creating attributes from preceding element..

Subject: creating attributes from preceding element..
From: Arulraj <p_arulraj@xxxxxxxxx>
Date: Sun, 20 Nov 2005 21:46:46 -0800 (PST)
xsl creating attributes
Hello,

I have the following XML strcture.

<office>
	<table>
		<header-rows>
			<table-row>
				<table-cell>
					<p>sequencey</p>
				</table-cell>
				<table-cell>
					<p>id</p>
				</table-cell>
				<table-cell>
					<p>gif</p>
				</table-cell>
			</table-row>
		</header-rows>
		<table-row>
			<table-cell>
				<p>1</p>
			</table-cell>
			<table-cell>
				<p>help</p>
			</table-cell>
			<table-cell>
				<p>01_help</p>
			</table-cell>
	 	</table-row>
                <table-row> 
                  .................
                </table-row>
               
	</table>
</office>

I want to get the following output:

<icon sequence="1" id="help" gif="01_help"/>

I tried this using following XSL but i didnt get the
expected result..

--------------------------------------------------------------------
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml"/>
	<xsl:template match="office">
		<layout>
			<xsl:apply-templates select="table"/>
		</layout>
	</xsl:template>
	<xsl:template match="table">
		<xsl:for-each select="table-row">
			<xsl:element name="icon">
				<xsl:for-each select="table-cell">
					<xsl:attribute
name="{../preceding-sibling::header-rows/table-row/table-cell[position()]/p}"><xsl:value-of
select="p"/></xsl:attribute>
				</xsl:for-each>
			</xsl:element>
		</xsl:for-each>
	</xsl:template>
</xsl:stylesheet>
------------------------------------------------------------------

I got the following output:
<layout><icon sequencey="01_help"/></layout>

Is any other way to solve this problem?
Thanks in advance

Regards,
Raj




		
__________________________________ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com

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.