RE: [xsl] client side style sheets?

Subject: RE: [xsl] client side style sheets?
From: "Kevin Jones" <kjouk@xxxxxxxxxxx>
Date: Tue, 30 Jan 2001 19:41:26 -0000

>Two questions...
>
>1) Are there standard/easy ways to allow users to apply/associate
>   XSL transforms to/with XML data from some server source?

The only standard way I know is adding the stylesheet PI that you mention.

>
>2) How do I correctly do c) above?
>
>  <xsl:template match="xdbpage">
>    <xsl:processing-instruction name="xml-stylesheet">
>	 type="text/xsl"
>	 href="<xsl:value-of select="@display" />"
>    </xsl:processing-instruction>
>    <xsl:apply-templates select="document(@source)/*" />
>  </xsl:template>
>

This approach can not work with IE because it appears to only be able to
perform one transform for each XML file loaded. So outputting a PI does not
help as the output just gets rendered rather than being considered for a
further possible transform. I think the <xsl:apply-template> should have
been a <xsl:copy-of ... if you wanted this to happen.

Some more alternatives to think about may be,

1. Use some JavaScript in to perform the second transform. In this model I
think you can make your first code generate a HTML file which contains
JavaScript to perform the required transform. See Pg. 690 of Michael Kay's
"XSLT Programmers Reference" for an example similar to this.

2. Use <xsl:import href="..."> to create a master stylesheet as below. This
will quickly become unmanageable for large sites and will reduce the
transformation speed.

<xsl:import href="file://path/to/xslt/display.xsl"/>

<xsl:template match="xdbpage">
    <xsl:apply-templates select="document(@source)/*" />
</xsl:template>

3. Use a server side transform to create XML with stylesheet PI's in. In
this case you can use a scheme similar to what you first proposed. The
stylesheet/XML below should do what you need as a server side transform.
This can be done as a final stage before the XML is sent from the server but
may suffer from your original objection of requiring too many code
modification. It would also perform much better if implemented as a simple
text insertion.

<xsl:template match="xdbpage">
   <xsl:processing-instruction name="xml-stylesheet">
	 type="text/xsl"
	 href="<xsl:value-of select="@display" />"
    </xsl:processing-instruction>
    <xsl:copy-of select="document(@source)/*" />
</xsl:template>

Any body else have any good solution for the XSL-XML association problem on
a client.

Regards,
Kev.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread