This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: display in a recursive way
- To: xsl-list at mulberrytech dot com
- Subject: Re: display in a recursive way
- From: Paul Tchistopolskii <paul at qub dot com>
- Date: Tue, 25 Apr 2000 20:58:48 -0700
- Organization: The Qub Group
- References: <OF3C2C9DA3.16429067-ON062568CC.007E4BE4@innovatec.com.mx>
- Reply-To: xsl-list at mulberrytech dot com
> What do we need to add to the program to make these item display in a
> recursive way?
1 If you can change the schema of XML document - change it to
<itemdesc>
<item/>
...
</itemdesc>
Then use simple <xsl:for-each select ="itemdesc">
2. If you can not change the schema, you may try using
some cool constructions of XSLT ( decreasing the readabily
of the code a bit.)
Attached please find the changed stylesheet and the result
of rendering with XT. Beware - I don't know what will happen
with the latest MS XSL version - my current (old) version of MSIE
says that:
"Keyword xsl:call-template may not be used here."
3. If I have to write the stylesheet from stratch, I'l write it in another
way. But because I was trying to minimize the number of changes
for your stylesheet there are just :
a.
<xsl:apply-templates select="data"/>
<xsl:for-each select="detail/item">
<xsl:call-template name="draw_item">
<xsl:with-param name="item" select="."/>
</xsl:call-template>
</xsl:for-each>
Instead of <xsl:apply-template>
b.
<xsl:template name="draw_item">
<xsl:param name="item"/>
Instead of
<xsl:template match="detail">
c.
<xsl:value-of select="following-sibling::itemdesc"/>
instead of
<xsl:value-of select="itemdesc"/>
d.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
Instead of
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
The rest is the same. ;-)
Rgds.Paul.
Title: Purchase Order Demo
SUPPLIER | SHIP TO | ORDER NUMBER |
X001830 | LASER FORWARDING 13504 NORTH UNITEC UNITEC INDUSTRIAL PARK LAREDO, TEXAS 78045 USA | P008422-00 |
CONTACT | BILL TO |
MAGGIE DE BENITO | INDUSTRIAS GILVERT, S.A DE C.V |
TELEPHONE | FAX |
0013058188890 | 0013058188888 |
DATE | SHIP VIA | FREE ABOARD | TERMS | INSTRUCTIONS |
1902-03-10 00:00:00 | THE BEST WAY SIDNEY | null | NET 45 DAYS/EX-WORKS | null |
BUYER | BUYER TELEPHONE |
MERCEDES NAVA JIMENEZ | 565-76-22 |
ITEM | DELIVER DATE | QUANTITY | U.M | PRICE | AMOUNT |
COMP KAKA-0200-TAC-200 | 1999-11-17 00:00:00 | 4 | PZ | 372 | 1489 |
ITEM | DELIVER DATE | QUANTITY | U.M | PRICE | AMOUNT |
COMP KAGA-0150-TAC-200 | 1999-11-17 00:00:00 | 2 | PZ | 356 | 713 |
ITEM | DELIVER DATE | QUANTITY | U.M | PRICE | AMOUNT |
COMP 0001 | 1999-10-13 00:00:00 | 8 | PZ | 952 | 0 |
ITEM | DELIVER DATE | QUANTITY | U.M | PRICE | AMOUNT |
COMP 0002 | 1999-11-17 00:00:00 | 2 | PZ | 952 | 3806 |
ITEM | DELIVER DATE | QUANTITY | U.M | PRICE | AMOUNT |
COMP 2DA3-0750-TFC-200 MT | 1999-11-17 00:00:00 | 2 | PZ | 932 | 1965 |
ITEM | DELIVER DATE | QUANTITY | U.M | PRICE | AMOUNT |
COMP 3DA3-0750-TFC-200 MT | 1999-09-30 00:00:00 | 3 | PZ | 1106 | 3317 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="purchase_order">
<html>
<head>
<title>Purchase Order Demo</title>
</head>
<body>
<table border="2" ALIGN="LEFT" >
<xsl:apply-templates select="data"/>
<xsl:for-each select="detail/item">
<xsl:call-template name="draw_item">
<xsl:with-param name="item" select="."/>
</xsl:call-template>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="data">
<tr width="100">
<th COLSPAN="2"><font face="ARIAL" size="1"> <small>SUPPLIER </small></font></th>
<th COLSPAN="1"><font face="ARIAL" size="1"> <small>SHIP TO </small></font></th>
<th COLSPAN="3"><font face="ARIAL" size="1"> <small>ORDER NUMBER </small></font></th>
</tr>
<tr>
<td COLSPAN="2" ROWSPAN="1" ALIGN="CENTER"><font face="ARIAL" size="1">
<small><xsl:value-of select="id_supplier"/></small>
<small><xsl:value-of select="suplier"/></small></font>
</td>
<td COLSPAN="1" ROWSPAN="1" ALIGN="CENTER"><font face="ARIAL" size="1"><small> <xsl:value-of select="ship_to"/> </small></font></td>
<td COLSPAN="3" ROWSPAN="5" ALIGN="CENTER"><font face="ARIAL" size="1"><small> <xsl:value-of select="order_number"/> </small></font></td>
</tr>
<tr>
<th COLSPAN="2"><font face="ARIAL" size="1"> <small> CONTACT </small></font> </th>
<th COLSPAN="1"><font face="ARIAL" size="1"> <small> BILL TO </small></font> </th>
</tr>
<tr>
<td COLSPAN="2" ALIGN="CENTER"><font face="ARIAL" size="1"><small> <xsl:value-of select="contact"/></small></font></td>
<td COLSPAN="1" ALIGN="CENTER"><font face="ARIAL" size="1"><small> <xsl:value-of select="bill_to"/> </small></font></td>
</tr>
<tr>
<th COLSPAN="2"><font face="ARIAL" size="1"> <small> TELEPHONE </small></font></th>
<th COLSPAN="1"><font face="ARIAL" size="1"> <small> FAX </small></font></th>
</tr>
<tr>
<td COLSPAN="2" ALIGN="CENTER"><font face="ARIAL" size="1"><small><xsl:value-of select="telcontact"/></small></font></td>
<td COLSPAN="1" ALIGN="CENTER"><font face="ARIAL" size="1"><small><xsl:value-of select="faxcontact"/> </small></font></td>
</tr>
<tr>
<th COLSPAN="1"><font face="ARIAL" size="1"> <small> DATE </small></font></th>
<th COLSPAN="1"><font face="ARIAL" size="1"> <small> SHIP VIA </small></font></th>
<th COLSPAN="1"><font face="ARIAL" size="1"> <small> FREE ABOARD </small></font> </th>
<th COLSPAN="2"><font face="ARIAL" size="1"> <small> TERMS</small></font></th>
<th COLSPAN="2"><font face="ARIAL" size="1"> <small> INSTRUCTIONS</small></font></th>
</tr>
<tr>
<td COLSPAN="1" ALIGN="CENTER"><font face="ARIAL" size="1"><small> <xsl:value-of select="date"/> </small></font></td>
<td COLSPAN="1" ALIGN="CENTER"><font face="ARIAL" size="1"><small> <xsl:value-of select="ship_via"/></small></font></td>
<td COLSPAN="1" ALIGN="CENTER"><font face="ARIAL" size="1"><small> <xsl:value-of select="free"/></small></font></td>
<td COLSPAN="2" ALIGN="CENTER"><font face="ARIAL" size="1"><small> <xsl:value-of select="terms"/></small></font></td>
<td COLSPAN="2" ALIGN="CENTER"><font face="ARIAL" size="1"><small> <xsl:value-of select="instructions"/></small></font></td>
</tr>
<tr>
<th COLSPAN="2"><font face="ARIAL" size="1"><small> BUYER </small></font> </th>
<th COLSPAN="1"><font face="ARIAL" size="1"><small> BUYER TELEPHONE </small></font> </th>
</tr>
<tr>
<td COLSPAN="2" ALIGN="CENTER"><font face="ARIAL" size="1"> <small> <xsl:value-of select="buyer"/></small></font></td>
<td COLSPAN="1" ALIGN="CENTER"><font face="ARIAL" size="1"> <small> <xsl:value-of select="telcomp"/></small></font></td>
</tr>
</xsl:template>
<xsl:template name="draw_item">
<xsl:param name="item"/>
<tr width="100">
<th COLSPAN="1" ALIGN="CENTER" BGCOLOR="ORANGE"><font face="ARIAL" size="1"> <small>ITEM</small></font> </th>
<th COLSPAN="1" ALIGN="CENTER" BGCOLOR="ORANGE"><font face="ARIAL" size="1"> <small>DELIVER DATE </small></font> </th>
<th COLSPAN="1" ALIGN="CENTER" BGCOLOR="ORANGE"><font face="ARIAL" size="1"> <small>QUANTITY</small></font> </th>
<th COLSPAN="1" ALIGN="CENTER" BGCOLOR="ORANGE"><font face="ARIAL" size="1"> <small>U.M</small></font> </th>
<th ALIGN="CENTER" BGCOLOR="ORANGE"><font face="ARIAL" size="1"> <small>PRICE </small></font></th>
<th BGCOLOR="ORANGE"> <small><font face="ARIAL" size="1">AMOUNT </font> </small></th>
</tr>
<tr>
<td COLSPAN="1" ALIGN="CENTER" ><font face="ARIAL" size="1"><small> <xsl:value-of select="item"/>
<xsl:value-of select="following-sibling::itemdesc"/></small></font></td>
<td COLSPAN="1" ALIGN="CENTER"><font face="ARIAL" size="1"><small> <xsl:value-of select="following-sibling::date_detail"/></small></font></td>
<td COLSPAN="1" ALIGN="CENTER"><font face="ARIAL" size="1"><small> <xsl:value-of select="following-sibling::quantity"/></small></font></td>
<td COLSPAN="1" ALIGN="CENTER"><font face="ARIAL" size="1"><small> <xsl:value-of select="following-sibling::type"/></small></font></td>
<td ALIGN="CENTER"><font face="ARIAL" size="1"><small> <xsl:value-of select="following-sibling::price"/></small></font></td>
<td ALIGN="CENTER"><font face="ARIAL" size="1"><small> <xsl:value-of select="following-sibling::amount"/></small></font></td>
</tr>
</xsl:template>
</xsl:stylesheet>