Hi Mike,
I tried using following xsl:
<xsl:template match="Root[Cell='##']">
<xsl:variable name="poscurrent" select="position()"/>
<Level>
<xsl:copy-of
select="following-sibling::Row[not(Cell='##')][position() < poscurrent]"/>
</Level>
</xsl:template>
Please let me know where I'm going wrong?
<Root>
<Cell>###</Cell>
<Cell>x</Cell>
<Cell>y</Cell>
<Cell>###</Cell>
<Cell>z</Cell>
</Root>
<Root>
<Level>
<Cell>x</Cell>
<Cell>y</Cell>
</Level>
<Level>
<Cell>z</Cell>
</Level>
</Root>
Thanks,
Amrit
-----Original Message-----
From: Michael Kay [mailto:mike(_at_)saxonica(_dot_)com]
Sent: Monday, December 12, 2005 2:28 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] XSL to generate required output
It's a positional grouping problem. For XSLT 2.0, do
<xsl:for-each-group select="Row" group-starting-with="Row[Cell='##']">
For XSLT 1.0 solutions, google for "XSLT positional grouping".
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Amrit Pal Singh [mailto:ampsingh(_at_)quark(_dot_)com]
Sent: 12 December 2005 04:45
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] XSL to generate required output
Hi friends,
I'm Having following input xml file.
<?xml version="1.0" encoding="UTF-8"?> <WoorkBook>
<WorkSheet>
<Name>Tarifs Clts & prog. de commande</Name>
<table>
<Row>
<Cell>##</Cell>
</Row>
<Row>
<Cell>COUPE</Cell>
<Cell>Puissance</Cell>
<Cell>Transmission</Cell>
<Cell>Puissance fiscale</Cell>
<Cell>Prix clientTTC EUR </Cell>
<Cell>Code modèle</Cell>
</Row>
<Row/>
<Row>
<Cell>Audi TT</Cell>
<Cell>163 ch</Cell>
<Cell>BV 5 </Cell>
<Cell>10 CV*</Cell>
<Cell>28900</Cell>
<Cell>8N30L40C00</Cell>
</Row>
<Row>
<Cell>Audi TT</Cell>
<Cell>190 ch</Cell>
<Cell>BV 5 </Cell>
<Cell>12 CV*</Cell>
<Cell>30800</Cell>
<Cell>8N30M40C00</Cell>
</Row>
<Row>
<Cell>##</Cell>
</Row>
<Row/>
<Row>
<Cell>Audi TT</Cell>
<Cell>163 ch</Cell>
<Cell>BV 5 </Cell>
<Cell>10 CV*</Cell>
<Cell>31000</Cell>
<Cell>8N90L40C00</Cell>
</Row>
<Row>
<Cell>Audi TT</Cell>
<Cell>190 ch</Cell>
<Cell>BV 5 </Cell>
<Cell>12 CV*</Cell>
<Cell>33300</Cell>
<Cell>8N90M40C00</Cell>
</Row>
</table>
</WorkSheet>
</WoorkBook>
I need to generate the ouput as below. i.e to take hierarchy one level
down when I see ## in Cell.
<?xml version="1.0" encoding="UTF-8"?> <WoorkBook>
<WorkSheet>
<Name>Tarifs Clts & prog. de commande</Name>
<table>
<New>
<Row>
<Cell>COUPE</Cell>
<Cell>Puissance</Cell>
<Cell>Transmission</Cell>
<Cell>Puissance fiscale</Cell>
<Cell>Prix clientTTC EUR </Cell>
<Cell>Code modèle</Cell>
</Row>
<Row/>
<Row>
<Cell>Audi TT</Cell>
<Cell>163 ch</Cell>
<Cell>BV 5 </Cell>
<Cell>10 CV*</Cell>
<Cell>28900</Cell>
<Cell>8N30L40C00</Cell>
</Row>
<Row>
<Cell>Audi TT</Cell>
<Cell>190 ch</Cell>
<Cell>BV 5 </Cell>
<Cell>12 CV*</Cell>
<Cell>30800</Cell>
<Cell>8N30M40C00</Cell>
</Row>
</New>
<New>
<Row>
<Cell>Audi TT</Cell>
<Cell>163 ch</Cell>
<Cell>BV 5 </Cell>
<Cell>10 CV*</Cell>
<Cell>31000</Cell>
<Cell>8N90L40C00</Cell>
</Row>
<Row>
<Cell>Audi TT</Cell>
<Cell>190 ch</Cell>
<Cell>BV 5 </Cell>
<Cell>12 CV*</Cell>
<Cell>33300</Cell>
<Cell>8N90M40C00</Cell>
</Row>
</New>
</table>
</WorkSheet>
</WoorkBook>
Please let me know how to achaive this.
Thanks,
Amrit
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--