Subject: [xsl] creating attributes from preceding element.. From: Arulraj <p_arulraj@xxxxxxxxx> Date: Sun, 20 Nov 2005 21:46:46 -0800 (PST) |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Too many apply-templates , UlyLee | Thread | Re: [xsl] creating attributes from , Ragulf Pickaxe |
RE: [xsl] Too many apply-templates , UlyLee | Date | Re: [xsl] creating attributes from , Ragulf Pickaxe |
Month |