Re: startMode available in XSLTProcessor
Jonas Sicking <[email protected]> Mon, 20 Aug 2007 14:05:37 -0700
| Newsgroups | gmane.comp.mozilla.devel.layout.xslt |
|---|---|
| Message-ID | <[email protected]> |
> and then an xsl which transforms it to a HTML table:-
>
> <xsl:template match="/documents">
> <table ...>
> <thead><tr>
> <th>
> .
> .
> .
> </th>
> </tr></thead>
> <tbody>
> <xsl:apply-templates select="document" />
> </tbody>
> </table>
> <xsl:template>
>
> all pretty standard stuff. However at times I may want only the tbody. So
> I add to the stylesheet this template:-
>
> <xsl:template match="/documents" mode="tbodyOnly">
> <tbody>
> <xsl:apply-templates select="document" />
> </tbody>
> </xsl:template>
>
> Now on the MSXML processor object I set startMode = "tbodyOnly" and this
> will get me the tbody only.
>
> I was hoping to be able to use the XSL as is. Clearly I can't. I guess if
> I add a parameter and place a choose in the top template the XSL would
> continue to work with existing MSXML code where as in firefox I can add a
> parameter to acheive the same thing.
Basically you are putting two different stylesheets, or two different
transforms, into the same XSLT file. I take it the reason you're putting
these in the same XSLT file is that there are a bunch of templates that
are used in both transforms?
Using a startMode does work, but there is no API for it in mozilla.
> <xsl:template match="/documents">
> <xsl:choose>
> <xsl:when test="$startMode='tbodyOnly'">
> <xsl:apply-templates select="." mode="tbodyOnly" />
> </xsl:when>
> <xsl:otherwise>
> <xsl:apply-templates select="." mode="full" />
> </xsl:otherwise>
> </xsl:choose>
> <xsl:template>
Yup, this would work. Another way would be to create one XSLT file that
contains all the templates, and then create two separate XSLT files that
both <xsl:import> the templates stylesheet. That way you can use
different URIs for when you want just the body, and when you want the
whole thing.
Feel free to file a bug on adding a startMode property to the XSLT
processor though, as that should be simple enough to add.
> Would this work:-
>
> <xsl:apply-templates select="." mode="{$startMode}" />
>
> if param defined as:-
>
> <xsl:param name="startMode">full</xsl:param>
>
> I wonder ? hmm..
Nope, that will not work as 'mode' is not defined to use
attribute-value-templates.
/ Jonas