xml to html transformation fails

J

Jeff Gutsell

I'm trying to develop a system for transforming an xml file into two
different html pages via VBscript. My code fails but does not
generate any error messages. Here's my VBscript:
Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
xmlDoc.async=false
xmlDoc.load(Server.MapPath("toc.xml"))

set xslDoc = Server.CreateObject("Microsoft.XMLDOM")
xslDoc.async = false
xslDoc.load(Server.MapPath("toc.xsl"))

If xmlDoc.parseError.errorCode = 0 Then
Response.Write(xmlDoc.transformNode(xslDoc))
Else
response.write("Your data was not found.")
End If

When IE displays the web page that contains the above script, the only
thing in the html is "<?xml version="1.0" encoding="UTF-16"?><?xml
version="1.0" encoding="UTF-16"?>."
The strange thing is that my xml files use different encoding.

I've validated both toc.xml and toc.xsl, but could there still be a
problem there? I'm not sure what to try.

Here's the DTC from toc.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE toc [
<!ELEMENT toc (section+, page*)>
<!ELEMENT section (sectitle,page+,section*)>
<!ELEMENT sectitle (#PCDATA)>
<!ELEMENT page (pagurl,pagtitle)>
<!ELEMENT pagurl (#PCDATA)>
<!ELEMENT pagtitle (#PCDATA)>
]>
<toc>
....
Hope this helps.
BTW, if you feeel that this should be posted in a vbscript forum, my
apologies in advance.

Jeff
 
M

Martin Honnen

Jeff said:
I'm trying to develop a system for transforming an xml file into two
different html pages via VBscript. My code fails but does not
generate any error messages. Here's my VBscript:
Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
xmlDoc.async=false
xmlDoc.load(Server.MapPath("toc.xml"))

set xslDoc = Server.CreateObject("Microsoft.XMLDOM")
xslDoc.async = false
xslDoc.load(Server.MapPath("toc.xsl"))

If xmlDoc.parseError.errorCode = 0 Then
Response.Write(xmlDoc.transformNode(xslDoc))
Else
response.write("Your data was not found.")
End If

When IE displays the web page that contains the above script, the only
thing in the html is "<?xml version="1.0" encoding="UTF-16"?><?xml
version="1.0" encoding="UTF-16"?>."
The strange thing is that my xml files use different encoding.

Use
xmlDoc.transformNodeToObject xslDoc, Response
and the encoding problem goes away.
Microsoft has its own newsgroups on all sort of topics, including XML
and XSLT so you might want to try there (news.microsoft.com) next time.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,044
Members
48,769
Latest member
Clifft

Latest Threads

Top