Solved

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

Posted on 2002-03-25
15
1,370 Views
Last Modified: 2013-11-19
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
0
Comment
Question by:kpu8
  • 9
  • 6
15 Comments
 
LVL 1

Author Comment

by:kpu8
ID: 6895147
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>


0
 
LVL 1

Author Comment

by:kpu8
ID: 6895148
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>


0
 
LVL 1

Author Comment

by:kpu8
ID: 6895150
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>


0
 
LVL 1

Author Comment

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

0
 
LVL 23

Expert Comment

by:b1xml2
ID: 6895471
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>


0
 
LVL 23

Expert Comment

by:b1xml2
ID: 6895474
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.

0
 
LVL 1

Author Comment

by:kpu8
ID: 6896348
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
%>
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 1

Author Comment

by:kpu8
ID: 6896360
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

%>


0
 
LVL 1

Author Comment

by:kpu8
ID: 6897101
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

%>


0
 
LVL 23

Expert Comment

by:b1xml2
ID: 6898099
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
%>
0
 
LVL 1

Author Comment

by:kpu8
ID: 6899150
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?

0
 
LVL 23

Expert Comment

by:b1xml2
ID: 6899165
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")
0
 
LVL 23

Accepted Solution

by:
b1xml2 earned 105 total points
ID: 6899178
also, if you store your xslt documents in one location like
http://www.myserver.com/xslt/,

then, you could use the following syntax (absolute path)
Server.MapPath("/xslt/testpub.xsl") which is different, very much so from Server.MapPath("xslt/testpub.xsl") which is relative.
0
 
LVL 1

Author Comment

by:kpu8
ID: 6899611
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
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 6900927
it always is the little things that complicates matters unfortunately... Glad to be of help =)
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now