Jump to content

XML/XSLT Transform Error in ASP

Recommended Posts

I'm in the process of migrating my site from classic ASP to ASP.NET 2.0, but I need to use some of the classic ASP apps until this process is complete. I'm trying to use a XML/XSLT transformation within an ASP doc (w/JScript syntax), but I'm getting an error. This setup works fine in my ASP.NET page, and I know that the XSLT doc is proper, so I'm thoroughly confused. I've included code for all of the referenced pages below, and all of these files are located in the same directory on my machine. If anyone can let me know what I'm doing wrong, that would be great. Thanks.xmldoc.xml:<?xml version="1.0" encoding="UTF-8"?><xmldoc> <section> <title>Page 1</title> <url>page1.asp</url> </section> <section> <title>Page 2</title> <url>page2.asp</url> </section></xmldoc>xsldoc.xsl:<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <ul> <xsl:for-each select="xmldoc/section"> <li><a href="{url}"><xsl:value-of select="title" /></a></li> </xsl:for-each> </ul> </xsl:template></xsl:stylesheet>aspdoc.asp (JScript syntax):<%//Load XMLvar xml = Server.CreateObject("Microsoft.XMLDOM")xml.async = falsexml.load("xmldoc.xml") //Load XSLvar xsl = Server.CreateObject("Microsoft.XMLDOM")xsl.async = falsexsl.load("xsldoc.xsl") //Transform fileResponse.Write(xml.transformNode(xsl))%>HTML output wanted:<ul> <li><a href="page1.asp">Page 1</a></li> <li><a href="page2.asp">Page 2</a></li></ul>Error message:msxml3.dll error '80004005'The stylesheet does not contain a document element. The stylesheet may be empty, or it may not be a well-formed XML document.

Link to post
Share on other sites

As far as I was able to read here, it seems a BOM could be the reason, though I personally doubt that, as you're migrating from ASP to ASP.NET 2.0, not the other way around, and this problem exists with old XSLT processors, not new ones. Actually, it may still be that, because as that page says, BOM is not allowed by spec, so the newer version might have become more conformant.OK. Enough "bla bla". A possible solution: open the file in any editor, ideally some more sophisticated one like Dreamwaver and resave the XSLT without a BOM.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...