Re: startMode available in XSLTProcessor

"Anthony Jones" <[email protected]> Fri, 17 Aug 2007 20:37:17 +0100
Newsgroups gmane.comp.mozilla.devel.layout.xslt
Message-ID <[email protected]>
"Jonas Sicking" <[email protected]> wrote in message
news:[email protected]...
> Martin Honnen wrote:
> > Anthony Jones wrote:
> >> MSXML supports specifying a starting mode for the processor however
there
> >> doesn't appear to be a startMode property on the XSLTProcessor?  Is
there
> >> anyway to acheive this without adjusting existing stylesheets designed
to
> >> work in conjunction with startMode?
> >
> > I don't see a way with Mozilla's XSLTProcessor API.
>
> Nope, there is no way to do that. Never even occurred to me that it
> might be useful. Why do you want to do it? Are you basically putting
> multiple stylesheets into the same .xsl file?
>


For example I have a some XML like:-

<documents>
    <document> ....</document>
    .
    .
    .
</documents>

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.

<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>

Would this work:-

    <xsl:apply-templates select="." mode="{$startMode}" />

if param defined as:-

    <xsl:param name="startMode">full</xsl:param>

I wonder ? hmm..


-- 
Anthony Jones