RE: [xsl] XSL Problem

Subject: RE: [xsl] XSL Problem
From: cknell@xxxxxxxxxx
Date: Wed, 07 Jul 2004 16:48:02 -0400
You will save yourself a great deal of headache if you download the Microsoft XML SDK help file. When several years ago I did what you are now doing I ran into the same problem, to wit, you are using the wrong COM object. Here is a sample from the help file to illustrate:

Dim xslt As New Msxml2.XSLTemplate40
Dim xslDoc As New Msxml2.FreeThreadedDOMDocument40
Dim xmlDoc As New Msxml2.DOMDocument40
Dim xslProc As IXSLProcessor
xslDoc.async = False
xslDoc.Load "sample.xsl"
Set xslt.stylesheet = xslDoc
xmlDoc.async = False
xmlDoc.Load "books.xml"
Set xslProc = xslt.createProcessor()
xslProc.input = xmlDoc
xslProc.addParameter "param1", "Hello"
MsgBox xslProc.output

Charles Knell
cknell@xxxxxxxxxx - email

-----Original Message-----
From:     retmmc <retmmc@xxxxxxxxxxxxx>
Sent:     Wed, 7 Jul 2004 14:48:08 -0500
To:       <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject:  [xsl] XSL Problem

To begin with, I'm fairly new (actually brand new) to XML/XSL programming.
I am trying to create an piece to display references, job aids and/or
glossary items for a topic in an eLearning event. The problem arises when I
try to transform my XML doc with an XSL stylesheet using VBScript/ASP.

In index.asp I have the following code:

    Dim objXML
    Dim objXSL
    Dim strLoId
    Dim strXMLFile
    Dim strXSLFile

    strXMLFile = "resources.xml"
    strXSLFile = "resources.xsl"
    strLoId = Request.QueryString("loid")

    'Instantiate the XMLDOM Object that will hold the XML file.
    set objXML = Server.CreateObject("Microsoft.XMLDOM")

    'Turn off asynchronous file loading.
    objXML.async = false

    'Load the XML file.

    'Instantiate the XMLDOM Object that will hold the XSL file.
    set objXSL = Server.CreateObject("Microsoft.XMLDOM")

    'Turn off asynchronous file loading.
    objXSL.async = false

    'Load the XSL file.

    'Use the "transformNode" method of the XMLDOM to apply the XSL
    'stylesheet to the XML document. Then the output is written to the

This produces the following error:
    msxml3.dll (0x80004005)
    The stylesheet does not contain a document element. The stylesheet may
be empty, or it may not be a well-formed XML document.

My test stylesheet code follows:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"

 <xsl:output method="html" />

 <xsl:template match="/">
    <title>Support Documents for <i>insert object name here</i></title>
    <link rel='stylesheet' type='text/css' href='ca2.css' />
    <xsl:apply-templates select="los" />

 <xsl:template match="los">
  <h1>Support Documents for <i>insert object name here</i></h1>
  <xsl:apply-templates select="lo" />

 <xsl:template match="lo">
  <h2>Matched LO</h2>
  <xsl:apply-templates select="references" />
  <xsl:apply-templates select="job_aids" />
  <xsl:apply-templates select="glossary" />
 <xsl:template match="references">
  <h3>Matched References</h3>
 <xsl:template match="job_aids">
  <h3>Matched Job Aids</h3>
 <xsl:template match="glossary">
  <h3>Matched Glossary</h3>

When I run my XML file with the following line:

    <?xml-stylesheet version="1.0" type="text/xsl" href="resource.xsl"?>

everything displays as planned.

I need to run this via the asp page so I can get the loid parameter from the
querystring to display the proper document links.

Any ideas?

Raymond Sugel Sr

Current Thread