Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: question about create table by using xslt

From: Lee <lee.jenkins.ca@-----.--->
To: NULL
Date: 6/2/2007 12:45:00 AM

On Jun 1, 12:33 am, "toudidel" <x...@neostrada.pl> wrote:
> it'd be something like that:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output method="html" encoding="windows-1250"/>
> <xsl:template match="/">
>     <html>
>         <body>
>             <hr/>
>             <div>Label&#160;<xsl:apply-templates select="/*/Product"/></div>
>             <hr/>
>             <div>Height&#160;<xsl:apply-templates
> select="/*/Product/SpecList/Spec/SpecLabel[.='Height']"/></div>
>             <div>Width&#160;<xsl:apply-templates
> select="/*/Product/SpecList/Spec/SpecLabel[.='Width']"/></div>
>             <div>Weight&#160;<xsl:apply-templates
> select="/*/Product/SpecList/Spec/SpecLabel[.='Weight']"/></div>
>         </body>
> </html>
> </xsl:template>
> <xsl:template match="Product">
>     <xsl:value-of select="name()"/>
>     <xsl:text>&#160;</xsl:text>
>     <xsl:value-of select="@id"/>
>     <xsl:text>&#160;</xsl:text>
> </xsl:template>
> <xsl:template match="SpecLabel">
>     <xsl:value-of select="../SpecValue"/>
>     <xsl:text>&#160;</xsl:text>
>     </xsl:template>
> </xsl:stylesheet>
>
> --
> tdwww.paranoja.org

Thank you very much, I finially find out the problem, I know param is
not allowed in for-each loop, I thought variable should not be able to
use in for-each either, but actually, it is fine. Here is the final
version xslt based on your code. Thanks a lot!
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform">
	<xsl:output method="html" />
	<xsl:template match="/">
		<html>
			<body>
				<table border="1">
					<xsl:for-each select="/ProductList/Product[position()=1]/SpecList/
Spec">
						<xsl:variable name="label" select="SpecLabel"></xsl:variable>
						<tr>
							<td>
								<xsl:value-of select="$label"/>
							</td>

							<xsl:for-each select="/ProductList/Product">
								<td>
									<xsl:apply-templates select="SpecList/Spec/SpecLabel[.=
$label]"/>
								</td>
							</xsl:for-each>
						</tr>
					</xsl:for-each>
				</table>
			</body>
		</html>
	</xsl:template>

	<xsl:template match="SpecLabel">
		<xsl:value-of select="../SpecValue"/>
	</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