xsl-list
[Top] [All Lists]

Re: XML allowing variable XSL application for browsers?

2005-04-21 00:00:11
a "start" template to
store each processors nuisances within an outside XML document that
contains the proper data values to be used instead of what would
normally be used, etc... By using the mode attribute of xsl:template

I just realized I combined two seperate ways of solving the same problem... 

e.g.  <xsl:variable name="vendor-usage"
select="document(concat(system-property(xsl:vendor)), '.xml')"/>

Would then provide a node-set contained withing a varaible that can be
used as a reference mechanism to determine whether or not something is
supported or possible workarounds for the particulars nuicances that
will cause you grief if your note paying attention.

By using the mode method you do have some advantages but so does this
last example so in many ways it will simply come down to preference
and style.



On 4/21/05, M. David Peterson <m(_dot_)david(_dot_)x2x2x(_at_)gmail(_dot_)com> 
wrote:
Whoa!  Thats a lot of disparate processes to invoke.  It seems this
should be a lot simpler and in fact, is. Chris Bayes shows you the
basics of  how to do this and then extends things into as a PowerToy
to dynamically swtich the stylesheets.

http://www.bayes.co.uk/xml/portal.aspx?page=/xml/index.xml&subpage=/xml/utils/multiple.xml

Using embedded PIs to determine the proper styesheet to use is by far
the easiest as it doesnt require any extra code in form of client-side
Javasript to initialize the transformation.  A great way to handle
both -- wait, Safari just got client-side XSLT so I guess that means
we need to start saying "A great way to handle all three" although I
here there's all sorts of Java hell breaking lose after the install of
the latest OSX release and as such creating a Monty Python-styled "RUN
AWAY" circus... Im sure they will fix that soon if not already so
using "all three" should be a safe usage bet.

Anyway, a great way to handle the differences between each of the
processors (MSXML, TransforMiiX, libxslt) is to use the xsl:vendor
function to determine which processor this is.  Embedded with a Choose
When Otherwise block will then allow you to use a "start" template to
store each processors nuisances within an outside XML document that
contains the proper data values to be used instead of what would
normally be used, etc... By using the mode attribute of xsl:template
and xsl:apply-templates you can easily "label" the entry template for
each processor without missing a beat in regards to a well designed,
template-based transformation process (using a named template would
require you to pass "/" as a parameter each  time which, depending on
the size of the tree, could become quite massive and as such drive
permonance of your application down.  Named-templates serve a very
important set of aspects in the world of XSLT development, but this
example isnt one them.

Hope this helps!

On 4/20/05, Aron Bock <aronbock(_at_)hotmail(_dot_)com> wrote:
John, here's one way to approach this:

1) send the browser an HTML document, with an embedded XML data island, and
multiple XSL islands, each corresponding to a transform.  They need not be
"embedded", but in many cases I prefer this.

2) in the body-load event, use client-side [java]script to apply one of the
XSLs to the XML and display

3) at server or client build a dropdown of other transforms ("views"); each
corresponds to an XSL island; when selected use script to apply the
corresponding XSL to the XML and redisplay.  All this happens without a
server round-trip.

See this link for starters: http://xmlfiles.com/xsl/xsl_client.asp .  Also
look into "Sarissa", which has been mentioned on this NG as a cross-browser
XML-related script library.

Regards,

--A

From: John <john-xsl-list(_at_)jpw3(_dot_)com>
Reply-To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] XML allowing variable XSL application for browsers?
Date: Wed, 20 Apr 2005 14:14:51 -0700

I have an XML file on a web server which references an XSL with code as
follows:

<?xml-stylesheet type="text/xsl" href="somefile.xsl"?>

When IE or Firefox requests this XML file, the browser detects the
stylesheet reference and applies it to the XML to transform it into HTML.
This works great, but what if I want to let the user choose from multiple
XSL files which can be applied to the same XML?  My first thought was URL
parameters (which I otherwise generally avoid), but I am not sure if there
is any URL parameter that can override the stylesheet referenced in the XML
file.  I was then thinking multiple XML files that basically contain the
XSL reference and an entity reference (keeping the XML in a separate file),
or using document() in the XSL files to open the content XML, but I would
prefer to avoid that if possible.

Does anyone have any recommendations, pros and cons of the various
techniques?

Thanks & regards,

   -John

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


_________________________________________________________________
Is your PC infected? Get a FREE online computer virus scan from McAfee(r)
Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--
<M:D/>

:: M. David Peterson ::
XML & XML Transformations, C#, .NET, and Functional Languages Specialist



-- 
<M:D/>

:: M. David Peterson ::
XML & XML Transformations, C#, .NET, and Functional Languages Specialist

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>