![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Do I have a bug, or am I pushing the limits of XSLT engines? >Thread Next - Re: Do I have a bug, or am I pushing the limits of XSLT engines? Re: Do I have a bug, or am I pushing the limits of XSLT engines?To: NULL Date: 5/3/2004 10:33:00 PM In article <faf20be8.0405031406.750d62e4@p...>, Mike Whittemore wrote: > I am trying to convert an HTML table into a list of name-value pairs, > one pair per field in the table. I believe my XSLT is correct, but > I've tried both Xalan and Saxon, which both fail with different > results. Below I've listed my HTML input, my expected XML output, my > XSLT, and the actual output from both Saxon and Xalan. Thanks in > advance. [snipped most of helpful example] > <xsl:transform version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > > <xsl:variable name="fields" select="//th" /> > > <xsl:template name="lookup-field"> > <xsl:param name="at-index"/> > <xsl:value-of select="$fields[$at-index]" /> > </xsl:template> > > <xsl:template match="/html/body/table"> > <records> > <xsl:apply-templates select="tr[td]"/> > </records> > </xsl:template> > > <xsl:template match="tr[td]"> > <record> > <xsl:for-each select="td"> > <field> > <name> > <xsl:call-template name="lookup-field"> > <xsl:with-param name="at-index"> > <xsl:value-of select="position()"/> > </xsl:with-param> Replace the above three lines with <xsl:with-param name="at-index" select="position()"/> What you have sets the param to a result tree fragment. You need to set the param to a number, so that in the called template $at-index evaluates to a number. > </xsl:call-template> > </name> > <value> > <xsl:value-of select="."/> > </value> > </field> > </xsl:for-each> > </record> > </xsl:template> > > </xsl:transform> | ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
