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

Re: XML to XML to HTML Transformation using file proto

Subject: Re: XML to XML to HTML Transformation using file protocol
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 17 Dec 2001 22:18:17 +0000
xml to html transformation
Hi Rich,

> Problem is going from 'testtoXML.xsl' to 'testtoHTML.xsl'. The
> archive shows a similar question that doesn't fix my problem. This
> must be accomplished with an client based XSLT processor(i.e. IE6 or
> IE5.x w/MSXML3). Please help!

Once Internet Explorer has activated its automatic transformation
(looking at the xml-stylesheet PI and using the stylesheet that it
indicates), the browser views whatever the transformation has
generated as HTML. It does not try to parse the result as XML again,
does not read any xml-stylesheet processing instruction you include,
and doesn't even apply the default stylesheet that gives you the nice
tree structure you usually get when you open a saved XML file.

So if you want to do a two-step transformation on the client, you have
to write the script to run it. Something like:

  function createDocumentObject() {
    var DOM = new ActiveXObject('MSXML2.FreeThreadedDOMDocument');
    DOM.async = false;
    DOM.validateOnParse = false;
    DOM.preserveWhiteSpace = true;
    return DOM;
  }

  // Create Document objects
  var xml1DOM = createDocumentObject();
  var xsl1DOM = createDocumentObject();
  var xml2DOM = createDocumentObject();
  var xsl2DOM = createDocumentObject();
     
  // Load XML and stylesheet documents
  xmlDOM.load('test.xml');
  xsl1DOM.load('testtoXML.xsl');
  xsl2DOM.load('testtoHTML.xsl');

  // Run the first transformation
  var xsl1Template = new ActiveXObject('MSXML2.XSLTemplate');
  xsl1Template.stylesheet = xsl1DOM;
  var xsl1Processor = xsl1Template.createProcessor();
  xsl1Processor.input = xml1DOM;
  xsl1Processor.output = xml2DOM;
  xsl1Processor.transform();

  // Run the second transformation
  var xsl2Template = new ActiveXObject('MSXML2.XSLTemplate');
  xsl2Template.stylesheet = xsl2DOM;
  var xsl2Processor = xsl2Template.createProcessor();
  xsl2Processor.input = xml2DOM;
  xsl2Processor.transform();

  // Write the resulting HTML to the document
  document.write(xsl2Processor.output);

But probably you should put some error catching in there.

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


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


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-2013 All Rights Reserved.