RE: XML/XSL parsers

Subject: RE: XML/XSL parsers
From: Guy_Murphy@xxxxxxxxxx
Date: Fri, 12 Feb 1999 09:56:55 +0000
Hi Craig.

I have fielded the question with a couple of people, and in each case I
found that the problem was they had the answer, but where looking for the
catch. There is little documentation on this matter because there is little
to document :)

In order to process XSL on IIS you should ideally have IE5 installed on the
server, but you can simply copy across the parsers DLL and register it on
the server. Decoupling the parser in this way is unsupported with IE5b2
(although MS say it will be supported for the gold release), but I have
heard of no adverse consequence of doing so.

Given that you now have the parser on your server, and that IIS is setup to
process ASP as normal, the examples on the MS site are all you need.

Note the scripted process is the same on the server as it is on the client
except that obviously you write out the result with Response.Write rather
than Document.Write

If it provides any further help I've pasted bellow an example of an ASP
page I use which detects whether IE4 or IE5 is accessing the site, if it's
IE4 the transformation is performed on the server, if IE5 the client.

Good luck
     Guy.
<!--
     File:          load.asp
     Browser:  IE4sp1
     Author:        Guy J Murphy
     Creation: 09/12/98
     Update:        n/a

     Generic load and transformer for XML and XSL files.

     Please consult:-
                         "htm/convensions.htm"     ...for coding
conventions
                         "htm/issue.htm"           ...for known outstanding
 issues
                         "htm/readme.htm"          ...for general issues
                         "htm/dependancies.htm"    ...installation issues

     To Do:-
                         [1]  ...Write the above readmes at some point
-->

<%@ LANGUAGE = JScript %>
<!--#include file="../inc/constants.inc"-->
<%
          var data = Request('data');
          var style = Request('style');
          var side = Request('side');

     // Sniff the client
     var client = new String(Request.ServerVariables("HTTP_USER_AGENT"));
     var version = client.split(";");

     if (version[1] == ' MSIE 5.0b2') {
          // transform on the client
          %>
               <html>
                    <head>
                         <title>LiveIntranet XML Experiment</title>
                    </head>
                    <script type="text/JScript">
                         var ROOT = '<%= ROOT %>';

                         // Error formatting function:
                         function reportError(where, error) {
                              document.write("<font face=Arial><B>Error
loading '" + where + "'</B></font> <BLOCKQUOTE><XMP>" + error.reason +
"</XMP></BLOCKQUOTE>");
                         return;
                         }

                         // Load the XML
                         var xmlDoc = new
ActiveXObject("Microsoft.XMLDOM");
                         xmlDoc.async = false;
                         xmlDoc.load('<%= ROOT+data+'?side='+side %>');

                         if (xmlDoc.parseError.errorCode != 0) {
                              reportError('<%= ROOT+data %>',
xmlDoc.parseError);
                         } else {
                              // Load the stylesheet
                              var xslMain = new
ActiveXObject("Microsoft.XMLDOM");
                              xslMain.async = false;
                              xslMain.load('<%= ROOT+style %>');

                              if (xslMain.parseError.errorCode != 0) {
                                   reportError('<%= ROOT+style %>',
xmlDoc.parseError);
                              }

                              // Process it
                              var result = xmlDoc.transformNode(xslMain);
                         }

                         document.write(result);
                    </script>
               </html>

          <%
     } else {

          // transform on the server

          // Error formatting function:
          function reportError(where, error) {
               Response.Write('<p>Data: '+ROOT+data+'</p>');
               Response.Write('<p>Style: '+ROOT+style+'</p>');
               Response.Write('<font face=Arial><B>Error loading "' + where
 + '"</B></font> <BLOCKQUOTE><XMP>' + error.reason +
'</XMP></BLOCKQUOTE>');
          }

          // Load the XML
          //Response.Write('<p>Data:
'+ROOT+data+'?side='+Request('side')+'</p>');
          //Response.Write('<p>Style: '+ROOT+style+'</p>');

          var xmlDoc = Server.CreateObject("Microsoft.XMLDOM");
          xmlDoc.async = false;
          try {
               xmlDoc.load(ROOT+data+'?side='+side);
          } catch (err) {
               Response.Write('Failed to load XML doc...'+ROOT+data);
          }

          if (xmlDoc.parseError.errorCode != 0) {
               reportError(data, xmlDoc.parseError);
          } else {
              var xslMain = Server.CreateObject("Microsoft.XMLDOM");
          xslMain.async = false;
          xslMain.load(ROOT+style);

              if (xslMain.parseError.errorCode != 0) {
                reportError(style, xmlDoc.parseError);
              }
               else
               {
                    // Process it
                   var result = xmlDoc.transformNode(xslMain);
               }
          }
     }
%>

<% Response.Write(result); %>





xsl-list@xxxxxxxxxxxxxxxx on 02/11/99 09:48:07 PM

To:   xsl-list@xxxxxxxxxxxxxxxx
cc:    (bcc: Guy Murphy/UK/MAID)
Subject:  RE: XML/XSL parsers




Quick newbie question.  Is there a site or page describing the process
to add the control to IIS and possibly has some example .asp pages for
it's use.  I have viewed the server-side demo and other assorted demos
on Microsoft's site, but I haven't really found great documentation on
the server set-up.  Thanks.
Craig E. Hohlbein
Software Engineer
Sequoia Software
e: craigh@xxxxxxxxxxxxx
p: 410.715.0206
-----Original Message-----
From: Mark Birbeck [mailto:Mark.Birbeck@xxxxxxxxxxxxx]
Sent: Thursday, February 11, 1999 11:30 AM
To: 'xsl-list@xxxxxxxxxxxxxxxx'
Subject: RE: XML/XSL parsers

> As I have not yet taught myself Java I have done most of my
> XML/xsl work
> with IE5beta. However, before I load anything onto a web site
> I have to
> allow for other browsers. Can anyone suggest where I can find
> a stand-alone
> (exe) parser that I can use with other browsers (or
> versions). Everything I
> have found seems to be java source code.
Obviously depends on your server, but if it's IIS then have you
considered putting the IE5 control onto the server? We've got it going
here quite nicely. The script checks for IE5 browsers, and sends the
XML/XSL separate if it is. Otherwise it merges the XML and XSL.
If the data is not that dynamic - say the XML pages are not coming from
a database, or the data changes infrequently, then you can speed up the
whole process by using Content Replication from Site Server to take a
snapshot of the site. This is the same as what your EXE would achieve,
but a bit more flexible, I think.
Mark Birbeck
Managing Director
Intra Extra Digital Ltd.
39 Whitfield Street
London
W1P 5RE
w: http://www.iedigital.net/
t: 0171 681 4135
e: Mark.Birbeck@xxxxxxxxxxxxx

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

 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