#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2011
    Posts
    1
    Rep Power
    0

    Data won't appear in XHTML page


    Hi I'm trying to show my data in a table which will calculate the quantity by the price and show the totals of both the quantity and price on the bottom of the table. It will also show a summary of every single transaction at the top of the page.

    This is what it looks like currently

    http://oi53.tinypic.com/9i4cx2.jpg

    As you can see i got the image and summary working but not the table. I would appreciate it if any one could help me.

    This is my code

    XML Document

    Code:
    <?xml version="1.0" encoding="UTF-8" ?>
    
    <?xml-stylesheet type="text/xsl" href="order_09001291.xsl" ?>
    <BookShopOrders>
    
        <group type="Williams Orders">
    	   <Orders>
    	       <ItemName> XML Technology </ItemName>
               <OrderedItem ItemNumber="001" Quantity="1" Price="23.99" Date="2011-04-12" />
    	   </Orders>
        </group>
    		
    	<group type="Raynies Orders">
    	    <Orders>
    	       <ItemName> ONM</ItemName>
               <OrderedItem ItemNumber="002" Quantity="1" Price="3.99" Date="2011-04-16" />
    		</Orders>
    		<Orders>
    	       <ItemName> WIRED </ItemName>
               <OrderedItem ItemNumber="003" Quantity="2" Price="6.99" Date="2011-04-17" />
    	    </Orders>
    	</group>
    
    	<group type="Stockes Orders">
    	    <Orders>
    	       <ItemName> XML Technology </ItemName>
               <OrderedItem ItemNumber="004" Quantity="1" Price="29.99" Date="2011-04-12" />
    	    </Orders>
    	    <Orders>
    	       <ItemName> Final Fantasy 012 Dissidia Duodecim </ItemName>
               <OrderedItem ItemNumber="005" Quantity="1" Price="93.99" Date="2011-04-12" />
    	    </Orders>
    	</group>
    	
    	<group type="Coconas Orders">
    	    <Orders>
    	       <ItemName> Okamiden </ItemName>
               <OrderedItem ItemNumber="006" Quantity="5" Price="34.99" Date="2011-04-12" />
    	    </Orders>
    	    <Orders>
    	       <ItemName> Cooking cakes </ItemName>
               <OrderedItem ItemNumber="007" Quantity="2" Price="35.99" Date="2011-04-12" />
    	    </Orders>
    	</group>
    
    	<group type="Aotas Orders">
    	    <Orders>
    	       <ItemName> Espeo Laptop Computer </ItemName>
               <OrderedItem ItemNumber="008" Quantity="1" Price="699.99" Date="2011-04-12" />
    	    </Orders>
    	    <Orders>
    	       <ItemName> 80's DVD Jukebox </ItemName>
               <OrderedItem ItemNumber="009" Quantity="1" Price="29.99" Date="2011-04-12" />
    	    </Orders>
    	    <Orders>
    	       <ItemName> XML Technology </ItemName>
               <OrderedItem ItemNumber="010" Quantity="2" Price="29.99" Date="2011-04-12" />
    	    </Orders>
    	</group>
    </BookShopOrders>
    XSL Document

    Code:
    <?xml version="1.0" encoding="UTF-8" ?>
    <xsl:stylesheet version='1.0' xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
    <xsl:import href="Revenue.xsl" />
    <xsl:output method="html" version="4.0" />
    
    <xsl:param name="filter" select="''" />
    <xsl:variable name="productList" select="order_09001291/group[starts-with(@type,$filter)]" />
    
    <xsl:template match="/">
       <html>
       <head><title>Customer Orders</title></head>
       <link href="order_09001291.css" rel="stylesheet" type="text/css" />
       <body>
    
       <table class="Summary" border="2" cellpadding="2">
       <tr>
          <th colspan="2">Summary Information</th>
       </tr>
       <tr>
          <th class="Summary">Filter</th>
          <td class="Summary">
          	<xsl:if test="$filter=''">all
          	</xsl:if>
          </td>
       </tr>
       <tr>
          <th class="Summary">Products</th>
          <td class="Summary">
          	<xsl:value-of select="count($productList//product)" />
          </td>
       </tr>
       <tr>
          <th class="Summary">Quantity</th>
          <td class="Summary">
          	<xsl:value-of select="sum($productList//product//@qty)" />
          </td>
       </tr>
       <tr>
          <th class="Summary">Revenue</th>  
          <td class="Summary">
    	    <xsl:call-template name="totalRevenue">
      				<xsl:with-param name="list" select="$productList//order" />
    			</xsl:call-template>
          </td>
       </tr>
       </table>
       
       <p><img src="bookbg.jpg" alt="Book Logo" /></p>
       
       <xsl:apply-templates select="$productList" />
       </body>
       </html> 
    </xsl:template>
    
     
    <xsl:template match="group">
       <h1><xsl:value-of select="@type" /></h1>
       <table class="prod" border="10" cellpadding="5" bordercolor="blue" bordercolorlight="lightblue">
       <tr>
          <th>Name</th>
    	   <th>Date</th>
          <th>ItemNumber</th>
    	  <th>Quantity</th>
    	  <th>Price</th>
    	  <th>Total</th>
       </tr>
       <xsl:apply-templates select="Orders">
          <xsl:sort select="ItemName" />
       </xsl:apply-templates>
       <tr>
          <th colspan="3" class="num">Total</th>
          <th class="num"><xsl:value-of select="sum(OrderedItem/@Quantity)" /></th>
          <th colspan="2" class="num">
          	<xsl:call-template name="totalRevenue">
      			<xsl:with-param name="list" select="Orders/OrderedItem" />
    		</xsl:call-template>
          </th>
       </tr>
       </table>
    </xsl:template>
    
    <xsl:template match="Orders">
       <xsl:apply-templates select="OrderedItem">
          <xsl:sort select="@ItemNumber" />
       </xsl:apply-templates>
    </xsl:template>
    
    <xsl:template match="OrderItem">
    <tr>
       <td rowspan="count(../OrderedItem)"><xsl:value-of select="../ItemName" /></td>
       <td><xsl:value-of select="@ItemNumber" /></td>
       <td><xsl:value-of select="@Date" /></td>
       <td class="num"><xsl:value-of select="@Quantity" /></td>
       <td class="num"><xsl:value-of select="@Price" /></td>
       <td class="num"><xsl:value-of select="format-number(@Quantity*@Price,'#,#00.00')" /></td>
    </tr>
    </xsl:template>
    
    </xsl:stylesheet>
    Again thankyou for your help
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    191
    Rep Power
    49
    are many errors in the xsl
    be appropriate to the xml I have created a new xsl

    The error is.
    where node order_09001291
    Incorrect use xpath
    and as programmed in a programming language

    think in xslt templates
    so much easier
    nor a suggestion that does not use currency in the context
    sample
    Code:
    Price="29.99"
    also have a new template for the summation to write
    xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="order_09001291.xsl" ?>
    <BookShopOrders>
    
    	<group type="Williams Orders">
    		<Orders>
    			<ItemName>XML Technology</ItemName>
    			<OrderedItem ItemNumber="001" Quantity="1" Price="23.99" Date="2011-04-12"/>
    		</Orders>
    	</group>
    
    	<group type="Raynies Orders">
    		<Orders>
    			<ItemName>ONM</ItemName>
    			<OrderedItem ItemNumber="002" Quantity="1" Price="3.99" Date="2011-04-16"/>
    		</Orders>
    		<Orders>
    			<ItemName>WIRED</ItemName>
    			<OrderedItem ItemNumber="003" Quantity="2" Price="6.99" Date="2011-04-17"/>
    		</Orders>
    	</group>
    
    	<group type="Stockes Orders">
    		<Orders>
    			<ItemName>XML Technology</ItemName>
    			<OrderedItem ItemNumber="004" Quantity="1" Price="29.99" Date="2011-04-12"/>
    		</Orders>
    		<Orders>
    			<ItemName>Final Fantasy 012 Dissidia Duodecim</ItemName>
    			<OrderedItem ItemNumber="005" Quantity="1" Price="93.99" Date="2011-04-12"/>
    		</Orders>
    	</group>
    
    	<group type="Coconas Orders">
    		<Orders>
    			<ItemName>Okamiden</ItemName>
    			<OrderedItem ItemNumber="006" Quantity="5" Price="34.99" Date="2011-04-12"/>
    		</Orders>
    		<Orders>
    			<ItemName>Cooking cakes</ItemName>
    			<OrderedItem ItemNumber="007" Quantity="2" Price="35.99" Date="2011-04-12"/>
    		</Orders>
    	</group>
    
    	<group type="Aotas Orders">
    		<Orders>
    			<ItemName>Espeo Laptop Computer</ItemName>
    			<OrderedItem ItemNumber="008" Quantity="1" Price="699.99" Date="2011-04-12"/>
    		</Orders>
    		<Orders>
    			<ItemName>80's DVD Jukebox</ItemName>
    			<OrderedItem ItemNumber="009" Quantity="1" Price="29.99" Date="2011-04-12"/>
    		</Orders>
    		<Orders>
    			<ItemName>XML Technology</ItemName>
    			<OrderedItem ItemNumber="010" Quantity="2" Price="29.99" Date="2011-04-12"/>
    		</Orders>
    	</group>
    </BookShopOrders>
    xsl
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    	<!--<xsl:import href="Revenue.xsl" />-->
    	<xsl:output method="html" version="4.0" indent="yes"/>
    	<xsl:param name="filter" select="''"/>
    	<xsl:template match="/">
    		<html>
    			<head>
    				<title>Customer Orders</title>
    			</head>
    			<link href="order_09001291.css" rel="stylesheet" type="text/css"/>
    			<body>
    				<xsl:value-of select="//group[starts-with(@type,$filter)]"/>
    				<table class="Summary" border="2" cellpadding="2">
    					<tr>
    						<th colspan="2">Summary Information</th>
    					</tr>
    					<tr>
    						<th class="Summary">Filter</th>
    						<td class="Summary">
    							<xsl:choose>
    								<xsl:when test="$filter=''">
    									<xsl:text>all</xsl:text>
    								</xsl:when>
    								<xsl:otherwise>
    									<xsl:value-of select="$filter"/>
    								</xsl:otherwise>
    							</xsl:choose>
    						</td>
    					</tr>
    					<tr>
    						<th class="Summary">Products</th>
    						<td class="Summary">
    							<xsl:value-of select="count(BookShopOrders//group[starts-with(@type,$filter)]/Orders)"/>
    							<!--//group[starts-with(@type,$filter)]//product -->
    						</td>
    					</tr>
    					<tr>
    						<th class="Summary">Quantity</th>
    						<td class="Summary">
    							<xsl:value-of select="sum(BookShopOrders//group[starts-with(@type,$filter)]//Orders/OrderedItem/@Quantity)"/>
    						</td>
    					</tr>
    					<tr>
    						<th class="Summary">Revenue</th>
    						<td class="Summary">
    							<xsl:variable name="sum">
    								<xsl:call-template name="sum">
    									<xsl:with-param name="kn" select="BookShopOrders//group[starts-with(@type,$filter)]//Orders"/>
    								</xsl:call-template>
    							</xsl:variable>
    							<xsl:value-of select="$sum"/>
    						</td>
    					</tr>
    				</table>
    
    				<p>
    					<img src="bookbg.jpg" alt="Book Logo"/>
    				</p>
    
    				<xsl:apply-templates select="//group[starts-with(@type,$filter)]"/>
    			</body>
    		</html>
    	</xsl:template>
    	<xsl:template match="group">
    		<h1>
    			<xsl:value-of select="@type"/>
    		</h1>
    		<table class="prod" border="10" cellpadding="5" bordercolor="blue" bordercolorlight="lightblue">
    			<tr>
    				<th>Name</th>
    				<th>Date</th>
    				<th>ItemNumber</th>
    				<th>Quantity</th>
    				<th>Price</th>
    				<th>Total</th>
    			</tr>
    			<xsl:apply-templates select="Orders">
    				<xsl:sort select="ItemName"/>
    				<xsl:sort select="@ItemNumber"/>
    			</xsl:apply-templates>
    			<tr>
    				<th colspan="3" class="num">Total</th>
    				<th class="num">
    					<xsl:value-of select="sum(Orders//@Quantity)"/>
    				</th>
    				<th colspan="2" class="num">
    				</th>
    			</tr>
    		</table>
    	</xsl:template>
    
    	<xsl:template match="Orders">
    		<tr>
    			<td rowspan="{count(OrderedItem)}">
    				<xsl:value-of select="ItemName"/>
    			</td>
    			<xsl:apply-templates select="OrderedItem"/>
    		</tr>
    	</xsl:template>
    	<xsl:template match="OrderedItem">
    		<td>
    			<xsl:value-of select="@Date"/>
    		</td>
    		<td>
    			<xsl:value-of select="@ItemNumber"/>
    		</td>
    		<td class="num">
    			<xsl:value-of select="@Quantity"/>
    		</td>
    		<td class="num">
    			<xsl:value-of select="@Price"/>
    		</td>
    		<td class="num">
    			<xsl:value-of select="concat('',format-number(@Quantity * substring(@Price,2),'#,#00.00'))"/>
    		</td>
    	</xsl:template>
    	<xsl:template name="sum">
    		<xsl:param name="kn"/>
    		<xsl:param name="total" select="0"/>
    		<xsl:param name="cn" select="1"/>
    		<xsl:choose>
    			<xsl:when test="$cn &amp;lt;= count($kn)">
    				<xsl:value-of select="hallo"/>
    				<xsl:call-template name="sum">
    					<xsl:with-param name="cn" select="$cn +1"/>
    					<xsl:with-param name="kn" select="$kn"/>
    					<xsl:with-param name="total" select="$total + (substring($kn[$cn]/OrderedItem/@Price,2) * $kn[$cn]/OrderedItem/@Quantity)"/>
    				</xsl:call-template>
    			</xsl:when>
    			<xsl:otherwise>
    				<xsl:value-of select="format-number($total,'#,#00.00')"/>
    			</xsl:otherwise>
    		</xsl:choose>
    	</xsl:template>
    </xsl:stylesheet>
    result
    Code:
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html">
        <title>Customer Orders</title>
      </head>
      <link href="order_09001291.css" rel="stylesheet" type="text/css">
      <body>
    		
    			XML Technology
    			
    		
    	
        <table class="Summary" border="2" cellpadding="2">
          <tr>
            <th colspan="2">Summary Information</th>
          </tr>
          <tr>
            <th class="Summary">Filter</th>
            <td class="Summary">all</td>
          </tr>
          <tr>
            <th class="Summary">Products</th>
            <td class="Summary">10</td>
          </tr>
          <tr>
            <th class="Summary">Quantity</th>
            <td class="Summary">17</td>
          </tr>
          <tr>
            <th class="Summary">Revenue</th>
            <td class="Summary">1,202.83</td>
          </tr>
        </table>
        <p>
          <img src="bookbg.jpg" alt="Book Logo">
        </p>
        <h1>Williams Orders</h1>
        <table class="prod" border="10" cellpadding="5" bordercolor="blue" bordercolorlight="lightblue">
          <tr>
            <th>Name</th>
            <th>Date</th>
            <th>ItemNumber</th>
            <th>Quantity</th>
            <th>Price</th>
            <th>Total</th>
          </tr>
          <tr>
            <td rowspan="1">XML Technology</td>
            <td>2011-04-12</td>
            <td>001</td>
            <td class="num">1</td>
            <td class="num">23.99</td>
            <td class="num">23.99</td>
          </tr>
          <tr>
            <th colspan="3" class="num">Total</th>
            <th class="num">1</th>
            <th colspan="2" class="num"></th>
          </tr>
        </table>
        <h1>Raynies Orders</h1>
        <table class="prod" border="10" cellpadding="5" bordercolor="blue" bordercolorlight="lightblue">
          <tr>
            <th>Name</th>
            <th>Date</th>
            <th>ItemNumber</th>
            <th>Quantity</th>
            <th>Price</th>
            <th>Total</th>
          </tr>
          <tr>
            <td rowspan="1">ONM</td>
            <td>2011-04-16</td>
            <td>002</td>
            <td class="num">1</td>
            <td class="num">3.99</td>
            <td class="num">03.99</td>
          </tr>
          <tr>
            <td rowspan="1">WIRED</td>
            <td>2011-04-17</td>
            <td>003</td>
            <td class="num">2</td>
            <td class="num">6.99</td>
            <td class="num">13.98</td>
          </tr>
          <tr>
            <th colspan="3" class="num">Total</th>
            <th class="num">3</th>
            <th colspan="2" class="num"></th>
          </tr>
        </table>
        <h1>Stockes Orders</h1>
        <table class="prod" border="10" cellpadding="5" bordercolor="blue" bordercolorlight="lightblue">
          <tr>
            <th>Name</th>
            <th>Date</th>
            <th>ItemNumber</th>
            <th>Quantity</th>
            <th>Price</th>
            <th>Total</th>
          </tr>
          <tr>
            <td rowspan="1">Final Fantasy 012 Dissidia Duodecim</td>
            <td>2011-04-12</td>
            <td>005</td>
            <td class="num">1</td>
            <td class="num">93.99</td>
            <td class="num">93.99</td>
          </tr>
          <tr>
            <td rowspan="1">XML Technology</td>
            <td>2011-04-12</td>
            <td>004</td>
            <td class="num">1</td>
            <td class="num">29.99</td>
            <td class="num">29.99</td>
          </tr>
          <tr>
            <th colspan="3" class="num">Total</th>
            <th class="num">2</th>
            <th colspan="2" class="num"></th>
          </tr>
        </table>
        <h1>Coconas Orders</h1>
        <table class="prod" border="10" cellpadding="5" bordercolor="blue" bordercolorlight="lightblue">
          <tr>
            <th>Name</th>
            <th>Date</th>
            <th>ItemNumber</th>
            <th>Quantity</th>
            <th>Price</th>
            <th>Total</th>
          </tr>
          <tr>
            <td rowspan="1">Cooking cakes</td>
            <td>2011-04-12</td>
            <td>007</td>
            <td class="num">2</td>
            <td class="num">35.99</td>
            <td class="num">71.98</td>
          </tr>
          <tr>
            <td rowspan="1">Okamiden</td>
            <td>2011-04-12</td>
            <td>006</td>
            <td class="num">5</td>
            <td class="num">34.99</td>
            <td class="num">174.95</td>
          </tr>
          <tr>
            <th colspan="3" class="num">Total</th>
            <th class="num">7</th>
            <th colspan="2" class="num"></th>
          </tr>
        </table>
        <h1>Aotas Orders</h1>
        <table class="prod" border="10" cellpadding="5" bordercolor="blue" bordercolorlight="lightblue">
          <tr>
            <th>Name</th>
            <th>Date</th>
            <th>ItemNumber</th>
            <th>Quantity</th>
            <th>Price</th>
            <th>Total</th>
          </tr>
          <tr>
            <td rowspan="1">80's DVD Jukebox</td>
            <td>2011-04-12</td>
            <td>009</td>
            <td class="num">1</td>
            <td class="num">29.99</td>
            <td class="num">29.99</td>
          </tr>
          <tr>
            <td rowspan="1">Espeo Laptop Computer</td>
            <td>2011-04-12</td>
            <td>008</td>
            <td class="num">1</td>
            <td class="num">699.99</td>
            <td class="num">699.99</td>
          </tr>
          <tr>
            <td rowspan="1">XML Technology</td>
            <td>2011-04-12</td>
            <td>010</td>
            <td class="num">2</td>
            <td class="num">29.99</td>
            <td class="num">59.98</td>
          </tr>
          <tr>
            <th colspan="3" class="num">Total</th>
            <th class="num">4</th>
            <th colspan="2" class="num"></th>
          </tr>
        </table>
      </body>
    </html>
    Last edited by xml-profi; May 8th, 2011 at 10:17 PM.
    Helmut Hagemann Germany

    fallen to the bottom of the facts?
    I reach my hand and we go together


    wer lesen und google kann ist klar im Vorteil
    who read and google is able is clear in the advantage

IMN logo majestic logo threadwatch logo seochat tools logo