Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP XML Using ASP 3 and XML. See also the XML category for more XML discussions not relating to ASP. NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 2nd, 2007, 11:23 AM
Banned
Points: 1,561, Level: 16
Points: 1,561, Level: 16 Points: 1,561, Level: 16 Points: 1,561, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2005
Location: , , .
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
Default XML/XSLT Transform Error in ASP

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="/">
        [list]
            <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 XML
var xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = false
xml.load("xmldoc.xml")

//Load XSL
var xsl = Server.CreateObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load("xsldoc.xsl")

//Transform file
Response.Write(xml.transformNode(xsl))
%>

HTML output wanted:[list]
    <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.

KWilliams
  #2 (permalink)  
Old August 22nd, 2007, 09:57 PM
Registered User
 
Join Date: Aug 2007
Location: Hanalei, HI, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi KWilliams,

I know this is off topic, but did you ever find a solution to your "CSS 100% Height DIV Problem" located at:

http://p2p.wrox.com/topic.asp?TOPIC_ID=62110
  #3 (permalink)  
Old October 9th, 2007, 02:26 AM
Authorized User
 
Join Date: Oct 2007
Location: Everett, WA, USA.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try using the following code: (note the use of Server.MapPath())

VBScript
Code:
set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = false
xml.load(Server.MapPath("xmldoc.xml"))

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

Response.Write(xml.transformNode(xsl))

set xsl = nothing
set xml = nothing
JScript

Code:
//Load XML
var xml = Server.CreateObject("Microsoft.XMLDOM");
xml.async = false;
xml.load(Server.MapPath("xmldoc.xml"));

//Load XSL
var xsl = Server.CreateObject("Microsoft.XMLDOM");
xsl.async = false;
xsl.load(Server.MapPath("xsldoc.xsl"));

//Transform file
Response.Write(xml.transformNode(xsl));

xsl = null;
xml = null;

Hope that helps. :)


-Charles Forsyth



Similar Threads
Thread Thread Starter Forum Replies Last Post
Transform SQL server 2005 XML with xslt bonekrusher XSLT 0 July 11th, 2007 07:45 PM
How do I transform XSLT without the <?xml?> tag? nadavvin XSLT 4 June 10th, 2007 09:25 AM
Can 1 xslt transform an xml doc into 2 text files Raju Sarode XSLT 7 November 3rd, 2006 04:10 PM
Transform XML with XSLT in JavaScript Mozilla Spankmaster79 Javascript 3 January 18th, 2006 07:31 AM
XSLT read through XML to transform another XML dendenx2 XSLT 8 July 7th, 2005 08:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.