Re: how to change xsl dynamically?

Subject: Re: how to change xsl dynamically?
From: "Dan Machak" <machak@xxxxxxxxxxxx>
Date: Fri, 10 Sep 1999 09:31:03 -0700
On Sep 10,  2:06pm, Sam.Walker wrote:
> Subject: RE: how to change xsl dynamically?
> I can't speak for Michele, but the solution I am looking for does not
> involve an http server.
> example
> If I had three files on my machine myinfo.xml, filter1.xsl, filter2.xsl. I
> want to use my web browser to view myinfo.xml using filter1.xsl or
> filter2.xsl. I have not identified a way to achieve this without
> (a) modifiying myinfo.xml or

You're right. One of the rationales behind XSL is that you separate content
from formatting. If you then go and bind your content to a specific
format/transformation, you're defeating the purpose.

> (b) using a http server with a server side script/application.

If the XML files don't contain a stylesheet reference, and XSL files don't
contain any XML references, then some outside entity has to provide the binding
between a specific XML file and a stylesheet.

What is your objection to using server-side scripts/applications/(or servlets)
to handle this binding?

Using servlets, you would provide a unique name for each stylesheet, so that
each stylesheet is its own servlet. Using the servlet provided with XT, you
don't need to write any code, just provide the name of a stylesheet for each
servlet. The path variable in the URL is then passed through the stylesheet.

Using the servlet server provided in JSDK with XT, you would only need to add
the following lines to the servlet.properties file:

Filter1.code=com.jclark.xsl.sax.XSLServlet
Filter1.initparams=stylesheet=/filter1.xsl
Filter2.code=com.jclark.xsl.sax.XSLServlet
Filter2.initparams=stylesheet=/filter2.xsl

Then to access the two different views of you data, you would use the
two URLs:
http://yourserver.com/servlet/Filter1//myinfo.xml
http://yourserver.com/servlet/Filter2//myinfo.xml

This gives you two different views of the data without modifying the original.

Dan

> I guess that my problem is that the style sheet is specified in the header
> of the xml document, and this means that without modifying the xml file
> there is only one view of the information.


What is your objection to

> Is there a way or technique which allows you to specify in a seperate
> document - 'use this xml document and render it with this style sheet'?
> eg forgive the syntax - myinfo_filter1.xml
> <xml:include select='test3.xml'>
> <xsl:include select="filter1.xsl>
>
>
>
>
>
> -----Original Message-----
> From: Marco.Mistroni@xxxxxxxxx [mailto:Marco.Mistroni@xxxxxxxxx]
> Sent: 10 September 1999 09:33
> To: xsl-list@xxxxxxxxxxxxxxxx
> Subject: RE: how to change xsl dynamically?
>
>
> hi,
> 	maybe i do not understand fully the question, but if
> 	the problem is to change xsl dynamically you could
> try to do like this:
> you write a common stylesheet in which you import another stylesheet
> the  name of this stylesheet is a param-variable, so that you can change it
> from
> for example a servlet.
> when you call for example the servlet, based on a value entered by the user
> you use
> the instruction setStylesheetParam() to set the name of the xsl stylesheet.
> Have i understood the problem correctly?
> best regards
> 			marco
>
> > -----Original Message-----
> > From: EXT Sam.Walker [mailto:Sam.Walker@xxxxxxxxxxxxxx]
> > Sent: 10. September 1999 10:35
> > To: xsl-list@xxxxxxxxxxxxxxxx
> > Subject: RE: how to change xsl dynamically?
> >
> >
> > I have been trying to do the same thing, but I haven't found
> > a way of doing
> > it other than by the use of server-side scripting which dynamically
> > generates the XML document header.
> > I think it seems a bit strange to have a fixed style sheet in an XML
> > document - how does this utilise the power of XML i.e. how
> > can you display
> > different views of an XML document other than by writing server side
> > applications or by modifying the XML header by hand? Is
> > anyone aware of a
> > technique for this? Ideally you should not have to use an
> > http server to
> > achieve this.
> >
> > --New Naive Idealistic XML User (or just Sam).
> >
> >
> >
> > -----Original Message-----
> > From: Michele Lee [mailto:mclee@xxxxxxxxx]
> > Sent: 08 September 1999 22:16
> > To: xsl-list@xxxxxxxxxxxxxxxx; Michele Lee
> > Subject: how to change xsl dynamically?
> >
> >
> >
> > Hi,
> >
> > I'm trying to call a different stylesheet (with the same xml
> > document) based
> > on a button click.  I know that Microsoft website has
> > examples of this, but
> > they seem to be Microsoft specific methods.  Is there a
> > generic way for
> > changing XSL dynamically?  In particular, I'm looking for
> > something that
> > will
> > work with both IE 5 and Netscape 5 (when it comes out).
> >
> > thanks!
> >
> > --Michele
> >
> >
> >  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> >
> >
> >  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> >
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>-- End of excerpt from Sam.Walker



-- 
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
<> Dan Machak                    <>  machak@xxxxxxxxxxxx  <>
<> MS T27A-1                     <>  650-604-2388 (VOICE) <>
<> NASA Ames Research Center     <>  650-604-3957 (FAX)   <>
<> Moffett Field, CA 94035-1000  <>                       <>
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>


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


Current Thread