Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 20th, 2005, 08:48 AM
Jeff Gutsell
Guest
 
Posts: n/a
Default xml to html transformation fails

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
  #2  
Old July 20th, 2005, 08:48 AM
Martin Honnen
Guest
 
Posts: n/a
Default Re: xml to html transformation fails



Jeff Gutsell wrote:
[color=blue]
> 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.[/color]

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.

--

Martin Honnen
http://JavaScript.FAQTs.com/
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles