This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: XML to XML to HTML Transformation using file protocol


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]