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 xsltTo: 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 <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 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> | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
