[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: XSLT Templates in a Web Browser

Subject: RE: XSLT Templates in a Web Browser
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sun, 31 Dec 2006 15:28:58 -0000
xsl fo browser
In general the relationship of source documents to stylesheets is
many-to-many, and naming your source document within the stylesheet is just
as unsatisfactory as naming the stylesheet within the source document. If
you're going to use client-side transformation, it's best to control the
process from Javascript within your HTML pages, using an API such as Sarissa
to achieve cross-browser portability.

Michael Kay
http://www.saxonica.com/


> -----Original Message-----
> From: Thomas Stone [mailto:stonethomasjames@xxxxxxxxx] 
> Sent: 31 December 2006 09:37
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  XSLT Templates in a Web Browser
> 
>    This is a post of one way to test multiple XSLT templates 
> producing web browser output against a single source XML document.
> 
>    I am relatively new to XSLT, though I have been 
> programming since the Commodore 64.  While testing the 
> intricacies of the language, I primarily used it to transform 
> XML data into HTML output.  The XML document referenced an 
> XSTL stylesheet.  When I double-clicked on the .xml file, the 
> web browser found its associated XSLT stylesheet and 
> displayed the HTML output.  This really helped in getting 
> "hands-on" experience with instant feed-back.
> 
>    The least satifactory part of this process was having to 
> edit my XML document every time I wanted to display the data 
> differently - to change the <?xml-stylesheet type="text/xsl" 
> href="Transform.xml"?> line.  I an old control freak when it 
> comes to data files, and storing the desired "program" to run 
> against a data file INSIDE the data file just didn't feel 
> right.  The solution I came up with uses the document() function.
> 
>    The trick I found was to rename my XSLT stylesheet to .xml 
> so the browser will open it and look for an associated 
> stylesheet instead of opening the source XML document.  The 
> following is an example of my stylesheet.
> 
> <?xml version="1.0" encoding="iso-8859-1"?> <?xml-stylesheet 
> type="text/xsl" href="Transform.xml"?>
> 
> <xsl:stylesheet version="1.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>   <xsl:variable name="transform_document">Test.xml</xsl:variable>
>   
>   <xsl:template match="/">
>     <xsl:apply-templates 
> select="document($transform_document)" mode="document"/>
>   </xsl:template>
>   
>   <xsl:template match="/" mode="document">
>     <xsl:apply-templates />
>   </xsl:template>
> </xsl:stylesheet>
> 
> 
>    This makes my stylesheet its own stylesheet.  The document 
> I want it to transform is stored in a variablee near the top 
> of the sheet - in this case it is called "Test.xml".  If I 
> make a copy of this stylesheet, and change the 
> <?xml-stylesheet type="text/xsl" href="Transform.xml"?> line 
> to match the copy's name, I can make changes in the second 
> stylesheet and immediately compare the changes in resulting 
> HTML output against my original.  I did not have to edit my 
> XML document.
> 
>    A second benefit of this is that the source XML document 
> does not have to be named as .xml.  Virtual Reality Modeling 
> Language text content in an X3D file could be referenced by 
> changing the transform_document variable declaration to state 
> "HelloWorld.x3d".  An Excel document that has been saved in 
> XML format or the Open Office documents could be source 
> documents just as easily, showing the data in a web browser 
> instead of their native application.
> 
> --
> ___________________________________________________
> Search for products and services at:
> http://search.mail.com

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.