Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: question about create table by using xslt >Thread Next - Re: question about create table by using xslt Re: question about create table by using xsltTo: 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 <xsl:apply-templates select="/*/Product"/></div> > <hr/> > <div>Height <xsl:apply-templates > select="/*/Product/SpecList/Spec/SpecLabel[.='Height']"/></div> > <div>Width <xsl:apply-templates > select="/*/Product/SpecList/Spec/SpecLabel[.='Width']"/></div> > <div>Weight <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> </xsl:text> > <xsl:value-of select="@id"/> > <xsl:text> </xsl:text> > </xsl:template> > <xsl:template match="SpecLabel"> > <xsl:value-of select="../SpecValue"/> > <xsl:text> </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 <xsl:apply-templates select="/*/Product"/> </div> <hr/> <xsl:for-each select="/*/Product/SpecList"> <div> <xsl:value-of select="Spec/SpecLabel[.=$currentLabel]" / > <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> </xsl:text> <xsl:value-of select="@id"/> <xsl:text> </xsl:text> </xsl:template> <xsl:template match="SpecLabel"> <xsl:value-of select="../SpecValue"/> <xsl:text> </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. | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
