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/1/2007 5:58:00 PM

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

toudidel,

Thank you very much for your help. it really help me a lot.
But I still have some questions. Because in my XML, I acutually don't
know how many specs it will have, also I don't know what label it will
be. so I have to loop through the whole speclist nodes and list them
one by one. but within for-each loop, I can not use param, so how
could I know which label I am dealing with? I modified your code a
little bit, but I don't know how to get the $currentLabel value when I
loop through the SpecList.

<?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:param name="currentLabel" />
	<xsl:template match="/">
		<html>
			<body>
				<hr/>
				<div>
					Label&#160;<xsl:apply-templates select="/*/Product"/>
				</div>
				<hr/>
				<xsl:for-each select="/*/Product/SpecList">
				<div>
					<xsl:value-of select="Spec/SpecLabel[.=$currentLabel]" /
>&#160;<xsl:apply-templates select="Spec/SpecLabel[.=$currentLabel]"/>
				</div>
				</xsl:for-each>
			</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>

I am thinking about use position() but I still don't know how to set a
loop counter to know which line I am in. Thanks a lot for your help.



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