Link to home
Start Free TrialLog in
Avatar of kpu8
kpu8Flag for United States of America

asked on

**Error '80004005' The stylesheet does not contain a document element. **

I'm getting the following error using XML, XSl within an ASP page:


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.

Any help as to the fix to this would be great:


Here's my xsl:

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" indent="yes" encoding="iso-8859-1"/>

<xsl:template match="/">
    <!--calling the listitem, quote, manager, jobtitle, subhead, subsubhead, para-->
    <xsl:apply-templates select="//listitem" mode="html"/>
    <xsl:apply-templates select="//quote" mode="html"/>
    <xsl:apply-templates select="//manager" mode="html"/>
    <xsl:apply-templates select="//jobtitle" mode="html"/>
    <xsl:apply-templates select="//subhead" mode="html"/>
    <xsl:apply-templates select="//subsubhead" mode="html"/>
        <xsl:apply-templates select="//para" mode="html"/>
            
</xsl:template>

<!--general template to facilitate proper xml element transformation-->

<xsl:template match="@* | node()" mode="html">
      <xsl:copy><xsl:apply-templates select="@* | node()" mode="html"/></xsl:copy>
</xsl:template>

<!--general template for tables-->

<xsl:template match="table">
       <TABLE>
           <TR>
               <xsl:for-each select="tgroup/colspec">
                   <TH>
                       <!--<xsl:value-of select="@colname"/>-->
                   </TH>
               </xsl:for-each>
           </TR>
           <xsl:for-each select="tgroup/tbody/row">
               <TR>
                   <xsl:for-each select="entry">
                       <TD>
                           <xsl:apply-templates/>
                       </TD>
                   </xsl:for-each>
               </TR>
           </xsl:for-each>
       </TABLE>
   </xsl:template>
   
    <xsl:template match="para">
       <p>
           <font face="Arial, MS Sans Serif, Helvetica" size="2">
               <xsl:apply-templates/>
           </font>
       </p>
   </xsl:template>

      <xsl:template match="listitem" mode="html">
            <ul type="square">
                  <li>
                        <font face="Arial, MS Sans Serif, Helvetica" size="2">
                              <xsl:apply-templates select="node()" mode="html" />
                        </font>
                  </li>
            </ul>
      </xsl:template>

      <xsl:template match="emphasis" mode="html">
            <xsl:variable name="style" select="@role"/>
                  <xsl:choose>
                        <xsl:when test="$style='bold'">
                              <b><xsl:apply-templates select="node()" mode="html" /></b>
                        </xsl:when>
                  <xsl:when test="$style='italic'">
                              <i><xsl:apply-templates select="node()" mode="html" /></i>
                  </xsl:when>
                        <xsl:when test="$style='bolditalic'">
                              <b><i><xsl:apply-templates select="node()" mode="html" /></i></b>
                  </xsl:when>
                        <xsl:otherwise>
                              <xsl:apply-templates select="node()" mode="html" />
                        </xsl:otherwise>
                  </xsl:choose>
      </xsl:template>

      <!--to stop para from being outputted as an element-->
      
            <xsl:template match="listitem/para" mode="html">
                  <xsl:apply-templates select="node()" mode="html" />
            </xsl:template>
      

      <xsl:template match="subhead" mode="html">
            <B>
                  <font face="Arial, MS Sans Serif, Helvetica" size="2">
            
                        <xsl:value-of select="node()"/>
                                                               
                  </font>
            </B>
       </xsl:template>
      
       <xsl:template match="subsubhead" mode="html">
            <B>
                  <font face="Arial, MS Sans Serif, Helvetica" size="2">
            
                        <xsl:value-of select="node()"/>
                                                               
                  </font>
            </B>
      </xsl:template>
               
    <xsl:template match="strategy" mode="html">
         
         <font face="Arial, MS Sans Serif, Helvetica" size="2">
         
                  <xsl:value-of select="node()"/>
                  
             </font>      
         
      </xsl:template>
      
      <xsl:template match="sup" mode="html">
         
     <sup>
         
                  <xsl:value-of select="node()"/>
                  
       </sup>      
         
      </xsl:template>
      
      <xsl:template match="sub" mode="html">
         
     <sub>
         
                  <xsl:value-of select="node()"/>
                  
       </sub>      
         
      </xsl:template>
      
      <xsl:template match="quote" mode="html">
      
            <font face="Arial, MS Sans Serif, Helvetica" size="2">
                  <xsl:apply-templates select="node()" mode="html" />
                        <br/>
            </font>

      </xsl:template>
      
        
   <xsl:template match="manager/para" mode="html">
            <br/>
                  <font face="Arial, MS Sans Serif, Helvetica" size="2">
                              
                        <xsl:value-of select="node()"/>
                        
                  </font>            
      </xsl:template>
      
      <xsl:template match="jobtitle" mode="html">
            <br/>
                  <font face="Arial, MS Sans Serif, Helvetica" size="2">
                              
                        <xsl:value-of select="node()"/>
                        
            </font>            
      </xsl:template>

</xsl:stylesheet>


Here's my xml:

<?xml version='1.0?>
<textsection><quote><para>&quot;The document only says this is a test&quot</para></quote></textsection>

I can also post the asp subroutine if that will help

Thanks
Avatar of kpu8
kpu8
Flag of United States of America image

ASKER

Note xml is (copying into these little boxes I always miss something):

<?xml version='1.0'?>
<textsection><quote><para>&quot;The document only says this is a test&quot;</para></quote></textsection>


Avatar of kpu8

ASKER

Note xml is (copying into these little boxes I always miss something):

<?xml version='1.0'?>
<textsection><quote><para>&quot;The document only says this is a test&quot;</para></quote></textsection>


Avatar of kpu8

ASKER

Note xml is (copying into these little boxes I always miss something):

<?xml version='1.0'?>
<textsection><quote><para>&quot;The document only says this is a test&quot;</para></quote></textsection>


Avatar of kpu8

ASKER

and it looks like I need to not hit re-fresh 3 times :)

XML Document
============
<?xml version="1.0" encoding="iso-8859-1"?>
<textsection>
<quote>
<para>&quot;The document only says this is a test&quot;</para>
</quote>
</textsection>

XSLT Document
=============
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" indent="yes" encoding="iso-8859-1"/>

<xsl:template match="/">
<!--calling the listitem, quote, manager, jobtitle, subhead, subsubhead, para-->
<xsl:apply-templates select="//listitem" mode="html"/>
<xsl:apply-templates select="//quote" mode="html"/>
<xsl:apply-templates select="//manager" mode="html"/>
<xsl:apply-templates select="//jobtitle" mode="html"/>
<xsl:apply-templates select="//subhead" mode="html"/>
<xsl:apply-templates select="//subsubhead" mode="html"/>
<xsl:apply-templates select="//para" mode="html"/>
         
</xsl:template>

<!--general template to facilitate proper xml element transformation-->

<xsl:template match="@* | node()" mode="html">
<xsl:copy><xsl:apply-templates select="@* | node()" mode="html"/></xsl:copy>
</xsl:template>

<!--general template for tables-->

<xsl:template match="table">
<table>
<tr>
<xsl:for-each select="tgroup/colspec">
<th>
<!--<xsl:value-of select="@colname"/>-->
</th>
</xsl:for-each>
</tr>
<xsl:for-each select="tgroup/tbody/row">
<tr>
<xsl:for-each select="entry">
<td>
<xsl:apply-templates/>
</td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</xsl:template>
 
<xsl:template match="para">
<p>
<font face="Arial, MS Sans Serif, Helvetica" size="2">
<xsl:apply-templates/>
</font>
</p>
</xsl:template>

<xsl:template match="listitem" mode="html">
<ul type="square">
<li>
<font face="Arial, MS Sans Serif, Helvetica" size="2">
<xsl:apply-templates select="node()" mode="html" />
</font>
</li>
</ul>
</xsl:template>

<xsl:template match="emphasis" mode="html">
<xsl:variable name="style" select="@role"/>
<xsl:choose>
<xsl:when test="$style='bold'">
<b><xsl:apply-templates select="node()" mode="html" /></b>
</xsl:when>
<xsl:when test="$style='italic'">
<i><xsl:apply-templates select="node()" mode="html" /></i>
</xsl:when>
<xsl:when test="$style='bolditalic'">
<b><i><xsl:apply-templates select="node()" mode="html" /></i></b>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="node()" mode="html" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<!--to stop para from being outputted as an element-->
<xsl:template match="listitem/para" mode="html">
<xsl:apply-templates select="node()" mode="html" />
</xsl:template>
     

<xsl:template match="subhead" mode="html">
<b>
<font face="Arial, MS Sans Serif, Helvetica" size="2"><xsl:value-of select="node()"/></font>
</b>
</xsl:template>
     
<xsl:template match="subsubhead" mode="html">
<b>
<font face="Arial, MS Sans Serif, Helvetica" size="2"><xsl:value-of select="node()"/></font>
</b>
</xsl:template>
             
<xsl:template match="strategy" mode="html">
<font face="Arial, MS Sans Serif, Helvetica" size="2"><xsl:value-of select="node()"/></font>    
</xsl:template>
     
<xsl:template match="sup" mode="html">
<sup><xsl:value-of select="node()"/></sup>    
</xsl:template>
     
<xsl:template match="sub" mode="html">
<sub><xsl:value-of select="node()"/></sub>    
</xsl:template>
     
<xsl:template match="quote" mode="html">
<font face="Arial, MS Sans Serif, Helvetica" size="2">
<xsl:apply-templates select="node()" mode="html" />
<br/>
</font>
</xsl:template>
     
<xsl:template match="manager/para" mode="html">
<br/>
<font face="Arial, MS Sans Serif, Helvetica" size="2">
<xsl:value-of select="node()"/>
</font>          
</xsl:template>
     
<xsl:template match="jobtitle" mode="html">
<br/>
<font face="Arial, MS Sans Serif, Helvetica" size="2">
<xsl:value-of select="node()"/>
</font>          
</xsl:template>

</xsl:stylesheet>


HTML Output
===========
<font face="Arial, MS Sans Serif, Helvetica" size="2">
<para>"The document only says this is a test"</para>
<br>
</font>
<para>"The document only says this is a test"</para>


Notes
=====
1. The problem is that on the client-side, it is loading the resulting output from the transformation as an XML Document.

2. By default the mime type used by ASP is "text/html". You have a directive:
Response.ContentType = "text/xml"
Change That to:
Response.ContentType = "text/html" OR comment out the directive that is causing to be mistaken as XML Output.

Since the HTML output as shown above has two nodes at the root level, the data is invalid as an XML Document

3. Although it appears that you are doing this as a test, you might have totally misunderstood the element transformation technique.

Avatar of kpu8

ASKER

Putting the contenttype to text/html gave me the same error - I'll fill in some more pieces - here's my call to a subroutine which is on my main ASP page - the subroutine is in a include file and is the only routine in that file:

<%fundmgmtpersp(rsPersp.Fields("XML_DATA").Value)%>

Here is the subroutine:

<%
sub fundmgmtpersp(xml_data)

          Dim xmlDoc, xslDoc
                    Set xmlDoc = Server.CreateObject("MSXML2.DOMDocument")
                    Set xslDoc = Server.CreateObject("MSXML2.DOMDocument")
                                       
                              xmlDoc.loadXML (("<text>") & xml_data  & ("</text>"))
                              xslDoc.load (Server.MapPath("testpub.xsl"))
                             
                              Response.Write xmlDoc.TransformNode(xslDoc)

set xmlDoc = Nothing
set xslDoc = Nothing

end sub
%>
Avatar of kpu8

ASKER

Also, please be advised that I'm pulling this data from the db so each chunk of data doesn't have the standard xml version = 1.0 at the top it starts at <textsection>
I merely plugged that in since I thought the problem was with the xsl:

Now if I have this piece of code all in one file - I get the correct Transformation using Response.Write xmlDoc.TransformNode(xslDoc):

<%@LANGUAGE = VBSCRIPT%>

<!--#include virtual="/ffw/share/adovbs.inc"-->

<%
Dim p1(2), dbObj, rsPersp

Dim xmlDoc, xslDoc

'  Database object
Set dbObj = Server.CreateObject("comobject.ishere")
     '  p1:  Parameters for XML_QUERY_TEXT query
     '  0:  fmp string
     '  1:  Basket ID

fmp = "the data"
     
     set p1(0) = Server.CreateObject ("ADODB.Parameter")
     p1(0).Value = CStr(fmp)
     p1(0).Type = adBStr

id = "91"
     
     set p1(1) = Server.CreateObject ("ADODB.Parameter")
     p1(1).Value = id
     p1(1).Type = adInteger

Set rsPersp = dbObj.GetRecordSet("XML_QUERY_TEXT", p1)
Set xmlDoc = Server.CreateObject("MSXML2.DOMDocument")
Set xslDoc = Server.CreateObject("MSXML2.DOMDocument")
xmlDoc.loadXML (("<text>") & (rsPersp.Fields("XML_DATA").Value) & ("</text>"))
xslDoc.Load (Server.MapPath("testpub.xsl"))
Response.Write xmlDoc.TransformNode(xslDoc)
set p1(0) = nothing
set p1(1) = nothing
Set xmlDoc = Nothing
Set xslDoc = Nothing

%>


Avatar of kpu8

ASKER

Also, please be advised that I'm pulling this data from the db so each chunk of data doesn't have the standard xml version = 1.0 at the top it starts at <textsection>
I merely plugged that in since I thought the problem was with the xsl:

Now if I have this piece of code all in one file - I get the correct Transformation using Response.Write xmlDoc.TransformNode(xslDoc):

<%@LANGUAGE = VBSCRIPT%>

<!--#include virtual="/ffw/share/adovbs.inc"-->

<%
Dim p1(2), dbObj, rsPersp

Dim xmlDoc, xslDoc

'  Database object
Set dbObj = Server.CreateObject("comobject.ishere")
     '  p1:  Parameters for XML_QUERY_TEXT query
     '  0:  fmp string
     '  1:  Basket ID

fmp = "the data"
     
     set p1(0) = Server.CreateObject ("ADODB.Parameter")
     p1(0).Value = CStr(fmp)
     p1(0).Type = adBStr

id = "91"
     
     set p1(1) = Server.CreateObject ("ADODB.Parameter")
     p1(1).Value = id
     p1(1).Type = adInteger

Set rsPersp = dbObj.GetRecordSet("XML_QUERY_TEXT", p1)
Set xmlDoc = Server.CreateObject("MSXML2.DOMDocument")
Set xslDoc = Server.CreateObject("MSXML2.DOMDocument")
xmlDoc.loadXML (("<text>") & (rsPersp.Fields("XML_DATA").Value) & ("</text>"))
xslDoc.Load (Server.MapPath("testpub.xsl"))
Response.Write xmlDoc.TransformNode(xslDoc)
set p1(0) = nothing
set p1(1) = nothing
Set xmlDoc = Nothing
Set xslDoc = Nothing

%>


Implement the following:
========================
<%fundmgmtpersp(rsPersp.Fields("XML_DATA").Value)%>
<%
Sub fundmgmtpersp(xml_data)
Dim xmlDoc, xslDoc
Set xmlDoc = Server.CreateObject("MSXML2.DOMDocument")
Set xslDoc = Server.CreateObject("MSXML2.DOMDocument")
'synchronous loading when loading from web server
xmlDoc.async = False : xslDoc.async = False
xmlDoc.loadXML "<text>" & xml_data  & "</text>"
xslDoc.load Server.MapPath("testpub.xsl")
If xmlDoc.parseError.errorCode = 0 And xslDoc.parseError.errorCode = 0 Then
     Response.Write xmlDoc.TransformNode(xslDoc)
Else
     'single line
     If xmlDoc.parseError.errorCode <> 0 Then errorinLoading("Error In Loading XML Tree",xmlDoc.parseError)
     'single line
     If xslDoc.parseError.errorCode <> 0 Then errorinLoading("Error In Loading XSLT Tree",xslDoc.parseError)
End If
Set xmlDoc = Nothing
Set xslDoc = Nothing
End Sub

'xml error handling routine
Sub errorInLoading(ByVal szMsg, ByRef oParse)
     Response.Write "<div>" & szMsg & "</div>"
     Response.Write "<div>Error Number: " & oParse.errorCode & "</div>"
     Response.Write "<div>Reason: " & oParse.reason & "</div>"
     Response.Write "<div>Line: " & oParse.line & "</div>"
     Response.Write "<div>LinePos: " & oParse.linepos & "</div>"
     Response.Write "<div>FilePos: " & oParse.filepos & "</div>"
End Sub
%>
Avatar of kpu8

ASKER

Ok thanks - that get's me a step further the error I get is:

Error In Loading XSLT Tree
Error Number: -2146697210
Reason: The system cannot locate the object specified.
Line: 0
LinePos: 0
FilePos: 0

Also just an FYI since we were using subs I changed these lines:

If xmlDoc.parseError.errorCode <> 0 Then errorinLoading("Error In Loading XML Tree",xmlDoc.parseError)
    'single line
    If xslDoc.parseError.errorCode <> 0 Then errorinLoading("Error In Loading XSLT Tree",xslDoc.parseError)

to just:

If xmlDoc.parseError.errorCode <> 0 Then errorinLoading "Error In Loading XML Tree",xmlDoc.parseError
    'single line
    If xslDoc.parseError.errorCode <> 0 Then errorinLoading"Error In Loading XSLT Tree",xslDoc.parseError

Since ASP said I could have parens when calling a sub
which I could've sworn I've done before?

Find out what this resolves to.
Server.MapPath("testpub.xsl").

If it is the wrong path, and your app allows for parent paths (by default) then, for e.g. Server.MapPath("../xslt/testpub.xsl")
ASKER CERTIFIED SOLUTION
Avatar of b1xml2
b1xml2
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kpu8

ASKER

Thank you for all your help - it was a fix to
Server.MapPath("/xslt/testpub.xsl")

jeez I didn't see that - it's always the little things isn't it - kind of like when I use to program in C and C++ and got bit by { a zillion times  

At any case thanks - this gives me a great working beta which will go to a live site soon utilizing xml
it always is the little things that complicates matters unfortunately... Glad to be of help =)