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

RE: Problem on: Cascading xslts on browsers - scriptin

Subject: RE: Problem on: Cascading xslts on browsers - scripting by DOM level 2
From: Américo Albuquerque <aalbuquerque@xxxxxxxxxxxxxxxx>
Date: Wed, 11 Dec 2002 16:58:24 -0000
f5078f32 c551 11d3 89b9 0000f81fe221
Hi.
This is the page I use to see the transformation. It uses a directory
system but you can change it to your needs.
It uses the msxml3sp2.cab to install the MSXML parser and use the OBJECT
tag to create the objects (instead of ActiveXObject). It uses the file
input.xml as input and transform.xsl or transform.xslt as the stylesheet
file (you can change the names in the corresponding OBJECT tag). I also
use the defaultss.xsl stylesheet to see the result tree but you can do
without that if you want to.

The directory structure that I use is:
<Main Directory>
   <Sub Directory where the files are>
      - Copy of ../index.html
      - input.xml
      - transform.xsl
   </Sub Directory>
   - index.html
   - msxml3sp2.cab (just in case I need it)
   - defaultss.xsl
</Main Directory>

Hope that this helps you.

--- index.html ---
<html>
 <head>
 <title>HTML Transform</title>
 </head>
 
 <body>
 <object id=doc
         classid="clsid:f5078f32-c551-11d3-89b9-0000f81fe221"
         codebase="../msxml3sp2.cab#version=8,20,8730,4"
         type="application/x-oleobject"
         style="display: none">
 </object>
 <object id=stl
         classid="clsid:f5078f32-c551-11d3-89b9-0000f81fe221"
          codebase="../msxml3sp2.cab#version=8,20,8730,4"
         type="application/x-oleobject"
         style="display: none">
 </object>
 <object id=res
         classid="clsid:f5078f32-c551-11d3-89b9-0000f81fe221"
          codebase="../msxml3sp2.cab#version=8,20,8730,4"
         type="application/x-oleobject"
         style="display: none">
 </object>
 <object id=xsl
         classid="clsid:f5078f32-c551-11d3-89b9-0000f81fe221"
           codebase="../msxml3sp2.cab#version=8,20,8730,4"
         type="application/x-oleobject"
         style="display: none">
 </object>
 
 <script language=javascript>
 try {
  doc.async = false;
  doc.load("input.xml");
  if(doc.parseError.errorCode!=0) {
   document.write("<b>****** Document(input.xml) ******</b><br>");
   document.write("<b>Error:</b> " + doc.parseError.errorCode + "<br>");
   document.write(doc.parseError.reason + "<br>");
   document.write("<b>Source:</b> " + doc.parseError.srcText + "<br>");
  }
 } catch(e) {
  document.write("<b>****** Document ******</b><br>");
  document.write("<p>");
  var text = "";
  for(var i in e) {
   text += i + ": " + eval("e." + i) + "<br>";
  }
  document.write(text + "</p>");
 }
 
 try {
  stl.async = false;
  stl.validateOnParse = false;
  if(!stl.load("transform.xslt"))
   stl.load("transform.xsl");
  if(stl.parseError.errorCode!=0) {
   document.write("<b>****** Stylesheet(transform.xsl(t))
******</b><br>");
   document.write("<b>Error:</b> " + stl.parseError.errorCode + "<br>");
   document.write(stl.parseError.reason + "<br>");
   document.write("<b>Source:</b> " + stl.parseError.srcText + "<br>");
  }
 } catch(e) {
  document.write("<b>****** Stylesheet ******</b><br>");
  document.write("<p>");
  var text = "";
  for(var i in e) {
   text += i + ": " + eval("e." + i) + "<br>";
  }
  document.write(text + "</p>");
 }
 
 try {
  res.async = false;
  res.validateOnParse = true;
  doc.transformNodeToObject(stl,res);
  if(doc.parseError.errorCode!=0) {
   document.write("<b>****** Document(input.trasformNodeToObject)
******</b><br>");
   document.write("<b>Error:</b> " + doc.parseError.errorCode + "<br>");
   document.write(doc.parseError.reason + "<br>");
   document.write("<b>Source:</b> " + doc.parseError.srcText + "<br>");
  }
  if(res.parseError.errorCode==-1072896682) {
   try {
    document.write("<div style='border: 1px solid #414649; padding:
3px;'>");
    document.write("<div style='color: #A53131; background-color:
#FFC600;'><b>****** Text Result ******</b></div>");
    document.write("<pre style='font-size: 12px'>");
    document.write(doc.transformNode(stl));
    document.write("</pre>");
    document.write("</div>");
    document.write("<hr color=#A53131>");
   } catch(e) {
    document.write("<b>****** Result ******</b><br>");
    document.write("<p>");
    var text = "";
    for(var i in e) {
     text += i + ": " + eval("e." + i) + "<br>";
    }
   }
  }
  if(res.parseError.errorCode!=0) {
   document.write("<b>****** Result(transformNodeToObject)
******</b><br>");
   document.write("<b>Error:</b> " + res.parseError.errorCode + "<br>");
   document.write(res.parseError.reason + "<br>");
   document.write("<b>Source:</b> " + res.parseError.srcText + "<br>");
  }
  document.write(res.xml);
 } catch(e) {
  document.write("<b>****** Result ******</b><br>");
  document.write("<p>");
  var text = "";
  for(var i in e) {
   text += i + ": " + eval("e." + i) + "<br>";
  }
  document.write(text + "</p>");
 }
 
 try {
  xsl.async = false;
  if(!xsl.load("defaultss.xsl"))
   xsl.load("../defaultss.xsl");
  if(xsl.parseError.errorCode!=0) {
   document.write("<b>****** Stylesheet(defaultss.xsl) ******</b><br>");
   document.write("<b>Error:</b> " + xsl.parseError.errorCode + "<br>");
   document.write(xsl.parseError.reason + "<br>");
   document.write("<b>Source:</b> " + xsl.parseError.srcText + "<br>");
  }
 } catch(e) {
  document.write("<b>****** Stylesheet ******</b><br>");
  document.write("<p>");
  var text = "";
  for(var i in e) {
   text += i + ": " + eval("e." + i) + "<br>";
  }
  document.write(text + "</p>");
 }
 
 try {
  document.write("<hr color=#a52a2a width=90%>");
  document.write("<table width=100%>");
  document.write("<tr>");
  document.write("<td width=50% valign=top>");
  try {
   document.write(doc.transformNode(xsl));
  } catch(e) {
   document.write("<pre>");
   document.write(doc.xml.replace(/</g,"&lt;"));
   document.write("</pre>");
  }
  document.write("</td>");
  document.write("<td width=50% valign=top>");
  try {
   document.write(res.transformNode(xsl));
  } catch(e) {
   document.write("<pre>");
   document.write(res.xml.replace(/</g,"&lt;"));
   document.write("</pre>");
  }
  document.write("</td>");
  document.write("</tr>");
  document.write("</table>");
 } catch(e) {
  document.write("<b>****** Display ******</b><br>");
  document.write("<p>");
  var text = "";
  for(var i in e) {
   text += i + ": " + eval("e." + i) + "<br>";
  }
  document.write(text + "</p>");
 }
 </script>
 </body>
</html>


-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Braumüller,
Hans
Sent: quarta-feira, 11 de Dezembro de 2002 8:08
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Problem on: Cascading xslts on browsers - scripting
by DOM level 2


Hello,

regarding

<snip>
Are there any standards-in-progress for controlling
the XSLT processor more fully from a browser?
</snip>

i am convinced, that it must be a way to do this by javascript using the
DOM Level 2 interface, loading the xsl und xml document in the cache,
and transformed it again from the outputted html.

like pseudocode:

xmlDoc = document.XMLDocument;
xslDoc = document.XSLDocument;

and then

page.innerHTML = xmlDoc.documentElement.transformNode(xslDoc);

but Mozilla don´t know about this document.XSLDocument and transformNode
methods.

It could be great, if anyone could forward me a tip. At this state i am
only able to do a transformation again with IE6, so i suspect, that i am
not using DOM Level 2, but ActiveX, with the above methods.

Greetings,

Hans Braumüller 
-- + -- 
Mail Art Not War
http://crosses.net

 


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


 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.