• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1508
  • Last Modified:

**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
0
kpu8
Asked:
kpu8
  • 9
  • 6
1 Solution
 
kpu8Author Commented:
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
 
kpu8Author Commented:
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
 
kpu8Author Commented:
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

0
 
b1xml2Commented:
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
 
b1xml2Commented:
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
 
kpu8Author Commented:
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
 
kpu8Author Commented:
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
 
kpu8Author Commented:
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
 
b1xml2Commented:
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
 
kpu8Author Commented:
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
 
b1xml2Commented:
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
 
b1xml2Commented:
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
 
kpu8Author Commented:
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
 
b1xml2Commented:
it always is the little things that complicates matters unfortunately... Glad to be of help =)
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 9
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now