[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: question about a non-trivial apply-templates
Try this: <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:for-each select="/rowset/row/field3[not(.=preceding::field3)]"> sector <xsl:value-of select="."/> <xsl:for-each select="/rowset/row[field3=current()]"> row <xsl:value-of select="position()"/> label1 = value1 label2 = value2</xsl:for-each> <xsl:text> </xsl:text> </xsl:for-each> </xsl:template> </xsl:stylesheet> Josh -----Original Message----- From: Jaime A Stuardo Bahamondes [mailto:jstuardo@xxxxxxxxxxx] Sent: Thursday, December 04, 2003 2:45 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: question about a non-trivial apply-templates Hi all.. How can I this? I have an XML, for example, <rowset> <row> <field1>....</field1> <field2>....</field2> <field3>1</field3> </row> <row> <field1>....</field1> <field2>....</field2> <field3>1</field3> </row> <row> <field1>....</field1> <field2>....</field2> <field3>2</field3> </row> <row> <field1>....</field1> <field2>....</field2> <field3>2</field3> </row> <row> <field1>....</field1> <field2>....</field2> <field3>3</field3> </row> <row> <field1>....</field1> <field2>....</field2> <field3>3</field3> </row> </rowset> Notice the value of field3 in each <row>. I want to program an XSL that generates an HTML page that has 3 separate sectors, one for each value of field3. Each sector has exactly the same structure, more or less this way: sector 1 (when field3 evaluates to 1) row1 label1 = value1 label2 = value2 row2 label1 = value1 label2 = value1 <blank space> sector 2 (when field3 evaluates to 2) row1 label1 = value1 label2 = value2 row2 label1 = value1 label2 = value1 <blank space> sector 3 (when field3 evaluates to 3) row1 label1 = value1 label2 = value2 row2 label1 = value1 label2 = value1 I could do it if I generate an XML with the 3 sectors separately and calling apply templates for each, but in this case, that XML is built by mean of an Oracle query, so I cannot modify it. Any help? Thanks a lot in advance Jaime XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|