Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Creating a table within a XSL-stylesheet

From: "Neil Smith [MVP Digital Media]" <neil@------.--->
To: NULL
Date: 12/2/2004 2:08:00 PM
You've used <xsl:apply-templates select="ingredients"/> outside the
table - how do you expect its output to get automagically placed
*inside* the table ?

Also (anyway) there's no 'ingredients' template, so probably it's just
using the default stylesheet template (which is to output all the text
nodes in your selected node, in this case "cookbook"). Which, it is
doing, as you can see all the text of the recipe is concatenated eg 

# Kladdkaka. dessert. Jenny. Värm ugnen till 175 grader. Smält smöret
och rör ner i din
smet2mskSmör2mskMjöl2mskSocker2mskBlockchoklad2mskKakao3stÄgg1tskBakpulver

Why not create an "ingredients" template and see if that helps ?

Cheers - Neil

On 2 Dec 2004 05:32:51 -0800, tessan@t... (Tessie  Sweden) wrote:

>Hi!
>
>A table is supposed to be created inside the <body>-tags, correct?
>Mine is displayed, but all of it's contents ends up OUTSIDE the table:
>
>http://www.student.nada.kth.se/~u1j80hrt/2D1517/XMLprojekt/recept.php
>
>I think it is a problem with "<xsl:apply-templates
>select="ingredients"/>" on line 15. I don't know where to put it
>really :)If I remove that line, everything goes away!
>
>This is my XSL-stylesheet:
>******************************************************************
><xsl:template match="cookbook"> 
> <html>
>  <head>
>	<title>	 
>		<xsl:apply-templates select="title"/>
>	</title>
>  </head>
>	  <body>
>  		<h1>Recipe:</h1>
>		<ul>
>	  <xsl:apply-templates select="recipe"/>
>		</ul>
>		<h1>Ingredients:</h1>
>	
>  <xsl:apply-templates select="ingredients"/>
>	  
>      <table border="1">
>         <tr bgcolor="#ffffff">
>         <th>Amount</th>
>         <th>Unit</th>
>         <th>Ingredient</th>
>         </tr>
>       <xsl:for-each select="ingredients/recipe_id">	
>        <tr>
>		 <td><xsl:value-of select="amount"/></td>
>         <td><xsl:value-of select="unit"/></td>
>         <td><xsl:value-of select="ingredient"/></td>
>        </tr>
>       </xsl:for-each>
>      </table>
>	 </body>  
>	</html>
> </xsl:template>
>
>    <xsl:template match="recipe">
>		<li>
>             <xsl:apply-templates select="recipe_name"/>
>			 <xsl:text>. </xsl:text>
>             <xsl:apply-templates select="type"/>
>			 <xsl:text>. </xsl:text>
>             <xsl:apply-templates select="chef"/>
>			 <xsl:text>. </xsl:text>
>             <xsl:apply-templates select="description"/>
>		</li>
>	</xsl:template>
>
>   <xsl:template match="cookbook/ingredients/amount">			
>				<xsl:apply-templates />
>				</xsl:template>
>
>   <xsl:template match="cookbook/ingredients/unit">			
>				<xsl:apply-templates />			
>				</xsl:template>
>
>   <xsl:template match="cookbook/ingredients/ingredient">			
>				<xsl:apply-templates />
>				</xsl:template>
>
></xsl:stylesheet>
>*********************************************************************



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent