PDA

Click to See Complete Forum and Search --> : server side xml transform thru xsl using asp



Mack
05-25-2001, 08:01 AM
<i>Sorry, there's not really a Flash side to this one, but it's interesting all the same and I guarantee you'll find the technique useful - even more so if we can get a solution...</i>

<b>HISTORY</b>

I have been using the following asp script ('transform.asp') to transform XML ('data.xml') thru XSL (stylesheet.xsl') into HTML on the server so as to avoid compatibility issues with non-XML supportive browsers:

'Load the XML
set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = false
xml.load(Server.MapPath("data.xml"))

'Load the XSL
set xsl = Server.CreateObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load(Server.MapPath("stylesheet.xsl"))

'Transform the file
Response.Write(xml.transformNode(xsl))


This works fine by returning standard html when specifying the namespace in the xsl stylesheet as follows:


<.x.s.l:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/WD-xsl">


BUT, I'm now attempting to use the newer and recommended w3c xsl standard to use <.x.s.l:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">. I have found articles re this on the Microsoft website at http://msdn.microsoft.com/library/default.asp?URL=/library/psdk/xmlsdk/xmlt7k18.htm which state that the CreateObject command should reference "Msxml2.DOMDocument". So I have updated my asp as follows:

'Load the XML
set xml = Server.CreateObject("Msxml2.DOMDocument")
xml.async = false
xml.load(Server.MapPath("data.xml"))

'Load the XSL
set xsl = Server.CreateObject("Msxml2.DOMDocument")
xsl.async = false
xsl.load(Server.MapPath("stylesheet.xsl"))

'Transform the file
Response.Write(xml.transformNode(xsl))

However this gives me the following error:

Server object error 'ASP 0177 : 800401f3'

Server.CreateObject Failed

xml/transform.asp, line 3

Invalid class string

<b>QUESTIONS</b>

1. Have I overlooked something obvious?
2. Is it something to do with the version of the MSXML parser running on the server?
3. Does anyone have any suggestions on the asp?

ps I had to edit this a few times to get the scripts to display - pls ignore the periods '.' in the xsl statement.
[Edited by Mack on 05-25-2001 at 08:14 AM]

mediastyle
05-25-2001, 01:59 PM
[QUOTE]
'Load the XML
set xml = Server.CreateObject("Msxml2.DOMDocument")
xml.async = false
xml.load(Server.MapPath("data.xml"))

'Load the XSL
set xsl = Server.CreateObject("Msxml2.DOMDocument")

However this gives me the following error:
Server object error 'ASP 0177 : 800401f3'
Server.CreateObject Failed
xml/transform.asp, line 3
Invalid class string
[QUOTE]


Hey are you shure the msxml2 is installed on your Server?! I think not. I think thats the reason, because
Server.CreateObject Failed
i had problem like this and i must install a update.

A other way.. check http://www.apache.org there you found wunderfull Servers that can XML and XSL to generate HTML..
best
stefan