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

Re: display in a recursive way

Subject: Re: display in a recursive way
From: Paul Tchistopolskii <paul@xxxxxxx>
Date: Tue, 25 Apr 2000 20:58:48 -0700
laser forwarding
> 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
X001830LASER FORWARDING 13504 NORTH UNITEC UNITEC INDUSTRIAL PARK LAREDO, TEXAS 78045 USAP008422-00
CONTACT BILL TO
MAGGIE DE BENITOINDUSTRIAS GILVERT, S.A DE C.V
TELEPHONE FAX
00130581888900013058188888
DATE SHIP VIA FREE ABOARD TERMS INSTRUCTIONS
1902-03-10 00:00:00THE BEST WAY SIDNEYnullNET 45 DAYS/EX-WORKSnull
BUYER BUYER TELEPHONE
MERCEDES NAVA JIMENEZ565-76-22
ITEMDELIVER DATE QUANTITYU.MPRICE AMOUNT
COMP KAKA-0200-TAC-2001999-11-17 00:00:004PZ3721489
ITEMDELIVER DATE QUANTITYU.MPRICE AMOUNT
COMP KAGA-0150-TAC-2001999-11-17 00:00:002PZ356713
ITEMDELIVER DATE QUANTITYU.MPRICE AMOUNT
COMP 00011999-10-13 00:00:008PZ9520
ITEMDELIVER DATE QUANTITYU.MPRICE AMOUNT
COMP 00021999-11-17 00:00:002PZ9523806
ITEMDELIVER DATE QUANTITYU.MPRICE AMOUNT
COMP 2DA3-0750-TFC-200 MT1999-11-17 00:00:002PZ9321965
ITEMDELIVER DATE QUANTITYU.MPRICE AMOUNT
COMP 3DA3-0750-TFC-200 MT1999-09-30 00:00:003PZ11063317
<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>

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.