On Fri, 20 Jul 2001 [EMAIL PROTECTED] wrote: > > Regarding the fact that <col> is one of the elements subject to > special treatment when the output method is HTML: > > >This is an interesting issue. The <col> element is being produced > >by an extension function. So the output method of the extension > >function is "xml" but the output of the transformation is "html". > >To correct this problem, I would have to changed the output for > >the whole transformation, which may produce invalid html. > >Is this a bug or feature ?? > >JohnG > > I guess it's a bug somewhere, depending on the point-of-view of the > beholder. Possible solutions: I don't really understand. The extension function is generating XML in some format, which is not XHTML or HTML4 or anything close. So you cannot directly embed the result of the extension function in the result tree. Instead, you'd have to transform it first. But hey, XSLT is a transformation language, which is ideally suited for this purpose. For an example, see the attached stylesheet which transforms the row-set of mr Gentilin's e-mail to an HTML table. Note that it uses the xalan extension function nodeset() because I bind the variable rset to a result-tree fragment; if the row-set was the result of an extension function it would already be a nodeset and the xalan:nodeset($rset) could be just $rset. But maybe I'm not seeing the problem here. Erwin Bolwidt > 1. Extension functions ought to be able to ascertain the "current" > output method, which will be a dicey proposition in XSLT 2.0. > 2. Pass in the name to be used, rather than assuming "col". > 3. Assume a name that's not one of the special HTML names. > > I like (2). > .................David Marston > > >
<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xalan" exclude-result-prefixes="xalan" version="1.0"> <xsl:output method="html"/> <xsl:variable name="rset"> <row-set> <column-header>ID</column-header> <column-header>First Name</column-header> <column-header>Last Name</column-header> <row> <col>42</col> <col>John</col> <col>Doe</col> </row> </row-set> </xsl:variable> <xsl:template match="/"> <html> <head><title>Row-set example</title></head> <body> <h1>Row-set example</h1> <xsl:apply-templates select="xalan:nodeset($rset)" mode="row-set"/> </body> </html> </xsl:template> <xsl:template match="row-set" mode="row-set"> <table> <tr> <xsl:apply-templates select="column-header" mode="row-set"/> </tr> <xsl:apply-templates select="row" mode="row-set"/> </table> </xsl:template> <xsl:template match="column-header" mode="row-set"> <th><xsl:value-of select="text()"/></th> </xsl:template> <xsl:template match="col" mode="row-set"> <td><xsl:value-of select="text()"/></td> </xsl:template> <xsl:template match="row" mode="row-set"> <tr> <xsl:apply-templates select="col" mode="row-set"/> </tr> </xsl:template> </xsl:stylesheet>
