binsaji
asked on
Microsoft.XMLDOM
Usign an ASP page I am generting an XML document and using XSL I want to display it. The xml is generated but I want to check whether it is properly generated or not . Is there any method to save teh xml from the XMLDOM?
Wehn i use the XSL file for presentation, I am getting 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.
Does anybody know the reason ?
Wehn i use the XSL file for presentation, I am getting 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.
Does anybody know the reason ?
The stylesheet may be empty, or it may not be a well-formed XML document, e.g. your XSL file is not properlly loaded or invalid
Check also that you're NOT using "Microsoft.XMLDOM" for the XML and XSL progID, and that you're not using the old WD-xsl namespace in your XSLT.
Use "Msxml2.DomDocument" or "Msxml2.DomDocument.4.0" for the XML and XSL objects, and your stylesheet root element should look like:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
Post your complete XSLT, along with the ASP code you're using, and we'll have a look.
As far as checking to see if the XML is generated or not, do this (JavaScript on the server, because friends don't let friend program in VBScript! ;^)
<%@language=JScript%>
<%
try
{
var xmlDoc = Server.CreateObject("Msxml 2.DomDocum ent");
xmlDoc.async = false;
xmlDoc.resolveExternals = false;
xmlDoc.validateOnParse = false;
xmlDoc.load(Server.MapPath ("/virtual /path/to/m yXml.xml") )
var err = xmlDoc.parseError
if (err.errorCode > 0)
{
Response.Write("<br>Error Parsing XML: <br>" + err.reason)
}
else
{
Response.ContentType = "text/xml";
xmlDoc.save(Response);
}
}
catch(e)
{
Response.Write("<br>Error with XML: <br>" + e.description)
}
%>
Regards,
Mike Sharp
Use "Msxml2.DomDocument" or "Msxml2.DomDocument.4.0" for the XML and XSL objects, and your stylesheet root element should look like:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
Post your complete XSLT, along with the ASP code you're using, and we'll have a look.
As far as checking to see if the XML is generated or not, do this (JavaScript on the server, because friends don't let friend program in VBScript! ;^)
<%@language=JScript%>
<%
try
{
var xmlDoc = Server.CreateObject("Msxml
xmlDoc.async = false;
xmlDoc.resolveExternals = false;
xmlDoc.validateOnParse = false;
xmlDoc.load(Server.MapPath
var err = xmlDoc.parseError
if (err.errorCode > 0)
{
Response.Write("<br>Error Parsing XML: <br>" + err.reason)
}
else
{
Response.ContentType = "text/xml";
xmlDoc.save(Response);
}
}
catch(e)
{
Response.Write("<br>Error with XML: <br>" + e.description)
}
%>
Regards,
Mike Sharp
ASKER
following is the asp file which is used to generate the xml
<% Option Explicit %>
<!--#include file="../../Includes/AIS_C onfigFile. asp"-->
<!--#include file="../../Includes/AIS_A uthenticat eUser.asp" -->
<%
Dim xsl
set xsl = Server.CreateObject ("Microsoft.XMLDOM")
xsl.async = false
xsl.load(Server.MapPath ("../XSL/GPList.xsl"))
Response.write (createXML( " ",NULL).transformNode(xsl) )
'createXML " ",NULL
%>
<BR>
<%
Function createXML(ScreenName, UserXML)
' connection
dim conAISdbConnection
Set conAISdbConnection = Server.CreateObject("ADODB .Connectio n")
conAISdbConnection.open(st rAISdbConn ectionStri ng)
'recordset
dim strsql
dim rsGp
strSql = "EXEC AIS_GET_GPLIST"
Set rsGp = Server.CreateObject ("ADODB.recordset")
Set rsGp =conAISdbConnection.Execut e(strSql)
'creating the XML tags
dim xml, xmlDocPage, xmlDocScreen, xmlHeading, xmlHeader, xmlList
set xml = CreateObject("Microsoft.XM LDOM")
set xmlDOCpage = xml.createElement("Page")
set xmlDOCScreen = xml.createElement("Screen" )
set xmlHeader = xml.createElement("Header" )
set xmlList = xml.createElement("List")
set xmlHeading = xml.createElement("Heading ")
xmlHeading.appendChild(xml .createTex tNode("GP List"))
xmlDOCScreen.appendChild(x mlHeading)
dim xmlTHead
Set xmlTHead = xml.createElement("THead")
xmlTHead.setAttribute "alias","GP_ID"
xmlTHead.appendChild(xml.c reateTextN ode("Id"))
xmlHeader.appendChild(xmlT Head)
Set xmlTHead = nothing
Set xmlTHead = xml.createElement("THead")
xmlTHead.setAttribute "alias","GP_CODE"
xmlTHead.appendChild(xml.c reateTextN ode("Code" ))
xmlHeader.appendChild(xmlT Head)
Set xmlTHead = nothing
Set xmlTHead = xml.createElement("THead")
xmlTHead.setAttribute "alias","GP_NAME"
xmlTHead.appendChild(xml.c reateTextN ode("Name" ))
xmlHeader.appendChild(xmlT Head)
Set xmlTHead = nothing
Set xmlTHead = xml.createElement("THead")
xmlTHead.setAttribute "alias","INITIALS"
xmlTHead.appendChild(xml.c reateTextN ode("Initi als"))
xmlHeader.appendChild(xmlT Head)
Set xmlTHead = nothing
Set xmlTHead = xml.createElement("THead")
xmlTHead.setAttribute "alias","GMC_NO"
xmlTHead.appendChild(xml.c reateTextN ode("GMC No"))
xmlHeader.appendChild(xmlT Head)
Set xmlTHead = nothing
Set xmlTHead = xml.createElement("THead")
xmlTHead.setAttribute "alias","RCN_NO"
xmlTHead.appendChild(xml.c reateTextN ode("RCN No"))
xmlHeader.appendChild(xmlT Head)
Set xmlTHead = nothing
Set xmlTHead = xml.createElement("THead")
xmlTHead.setAttribute "alias","PCT_CODE"
xmlTHead.appendChild(xml.c reateTextN ode("PCT Code"))
xmlHeader.appendChild(xmlT Head)
Set xmlTHead = nothing
Set xmlTHead = xml.createElement("THead")
xmlTHead.setAttribute "alias","PCG_CODE"
xmlTHead.appendChild(xml.c reateTextN ode("PCG Code"))
xmlHeader.appendChild(xmlT Head)
Set xmlTHead = nothing
xmlList.appendChild(xmlHea der)
dim xmlRow, xmlItem, strTemp
While(not rsGP.EOF)
Set xmlRow = xml.createElement("Row")
xmlRow.setAttribute "id", rsGp("AIS_GP_ID")
Set xmlItem = xml.createElement("Item")
xmlItem.setAttribute "alias","GP_ID"
strTemp = RsGp.Fields ("AIS_GP_ID").value
If IsNull(strTemp) then xmlItem.appendChild(xml.cr eateTextNo de("-a-")) _
else xmlItem.appendChild(xml.cr eateTextNo de(strTemp ))
xmlRow.appendChild(xmlItem )
Set xmlItem = nothing
Set xmlItem = xml.createElement("Item")
xmlItem.setAttribute "alias","GP_CODE"
strTemp = RsGp.Fields ("AIS_GP_CODE").value
If IsNull(strTemp) then xmlItem.appendChild(xml.cr eateTextNo de("-a-")) else xmlItem.appendChild(xml.cr eateTextNo de(strTemp ))
xmlRow.appendChild(xmlItem )
Set xmlItem = nothing
Set xmlItem = xml.createElement("Item")
xmlItem.setAttribute "alias","GP_NAME"
strTemp = RsGp.Fields ("GP_NAME").value
If IsNull(strTemp) then xmlItem.appendChild(xml.cr eateTextNo de("-a-")) else xmlItem.appendChild(xml.cr eateTextNo de(strTemp ))
xmlRow.appendChild(xmlItem )
Set xmlItem = nothing
Set xmlItem = xml.createElement("Item")
xmlItem.setAttribute "alias","INITIALS"
strTemp = RsGp.Fields ("AIS_GP_INITIALS").value
If IsNull(strTemp) then xmlItem.appendChild(xml.cr eateTextNo de("-a-")) else xmlItem.appendChild(xml.cr eateTextNo de(strTemp ))
xmlRow.appendChild(xmlItem )
Set xmlItem = nothing
Set xmlItem = xml.createElement("Item")
xmlItem.setAttribute "alias","GMC_NO"
strTemp = RsGp.Fields ("AIS_GP_GMC_NO").value
If IsNull(strTemp) then xmlItem.appendChild(xml.cr eateTextNo de("-a-")) else xmlItem.appendChild(xml.cr eateTextNo de(strTemp ))
xmlRow.appendChild(xmlItem )
Set xmlItem = nothing
Set xmlItem = xml.createElement("Item")
xmlItem.setAttribute "alias","RCN_NO"
strTemp = RsGp.Fields ("AIS_GP_RCN_NO").value
If IsNull(strTemp) then xmlItem.appendChild(xml.cr eateTextNo de("-a-")) else xmlItem.appendChild(xml.cr eateTextNo de(strTemp ))
xmlRow.appendChild(xmlItem )
Set xmlItem = nothing
Set xmlItem = xml.createElement("Item")
xmlItem.setAttribute "alias","PCT_CODE"
strTemp = RsGp.Fields ("AIS_GP_PCT_CODE").value
If IsNull(strTemp) then xmlItem.appendChild(xml.cr eateTextNo de("-a-")) else xmlItem.appendChild(xml.cr eateTextNo de(strTemp ))
xmlRow.appendChild(xmlItem )
Set xmlItem = nothing
Set xmlItem = xml.createElement("Item")
xmlItem.setAttribute "alias","PCG_CODE"
strTemp = RsGp.Fields ("AIS_GP_PCG_CODE").value
If IsNull(strTemp) then xmlItem.appendChild(xml.cr eateTextNo de("-a-")) else xmlItem.appendChild(xml.cr eateTextNo de(strTemp ))
xmlRow.appendChild(xmlItem )
Set xmlItem = nothing
xmlList.appendChild(xmlRow )
rsGP.MoveNext ()
wend
'xmlDOCpage.appendChild(xm lDOCScreen )
xmlDOCpage.appendChild(xml List)
dim ProcInstn, xslPI
set ProcInstn = xml.createProcessingInstru ction("xml ", "version='1.0'")
set xslPI = xml.createProcessingInstru ction("xml -styleshee t", "type='text/xsl' href='../XSL/GPList.xsl'")
xml.appendChild(ProcInstn)
xml.appendChild(xslPI)
xml.appendChild(xmlDOCpage )
'Response.Write xml.xml
response.write("<xmp>" & xml.xml & "</xmp>")
xml.save("sss.xml")
set createXML = xml
end function
%>
<% Option Explicit %>
<!--#include file="../../Includes/AIS_C
<!--#include file="../../Includes/AIS_A
<%
Dim xsl
set xsl = Server.CreateObject ("Microsoft.XMLDOM")
xsl.async = false
xsl.load(Server.MapPath ("../XSL/GPList.xsl"))
Response.write (createXML( " ",NULL).transformNode(xsl)
'createXML " ",NULL
%>
<BR>
<%
Function createXML(ScreenName, UserXML)
' connection
dim conAISdbConnection
Set conAISdbConnection = Server.CreateObject("ADODB
conAISdbConnection.open(st
'recordset
dim strsql
dim rsGp
strSql = "EXEC AIS_GET_GPLIST"
Set rsGp = Server.CreateObject ("ADODB.recordset")
Set rsGp =conAISdbConnection.Execut
'creating the XML tags
dim xml, xmlDocPage, xmlDocScreen, xmlHeading, xmlHeader, xmlList
set xml = CreateObject("Microsoft.XM
set xmlDOCpage = xml.createElement("Page")
set xmlDOCScreen = xml.createElement("Screen"
set xmlHeader = xml.createElement("Header"
set xmlList = xml.createElement("List")
set xmlHeading = xml.createElement("Heading
xmlHeading.appendChild(xml
xmlDOCScreen.appendChild(x
dim xmlTHead
Set xmlTHead = xml.createElement("THead")
xmlTHead.setAttribute "alias","GP_ID"
xmlTHead.appendChild(xml.c
xmlHeader.appendChild(xmlT
Set xmlTHead = nothing
Set xmlTHead = xml.createElement("THead")
xmlTHead.setAttribute "alias","GP_CODE"
xmlTHead.appendChild(xml.c
xmlHeader.appendChild(xmlT
Set xmlTHead = nothing
Set xmlTHead = xml.createElement("THead")
xmlTHead.setAttribute "alias","GP_NAME"
xmlTHead.appendChild(xml.c
xmlHeader.appendChild(xmlT
Set xmlTHead = nothing
Set xmlTHead = xml.createElement("THead")
xmlTHead.setAttribute "alias","INITIALS"
xmlTHead.appendChild(xml.c
xmlHeader.appendChild(xmlT
Set xmlTHead = nothing
Set xmlTHead = xml.createElement("THead")
xmlTHead.setAttribute "alias","GMC_NO"
xmlTHead.appendChild(xml.c
xmlHeader.appendChild(xmlT
Set xmlTHead = nothing
Set xmlTHead = xml.createElement("THead")
xmlTHead.setAttribute "alias","RCN_NO"
xmlTHead.appendChild(xml.c
xmlHeader.appendChild(xmlT
Set xmlTHead = nothing
Set xmlTHead = xml.createElement("THead")
xmlTHead.setAttribute "alias","PCT_CODE"
xmlTHead.appendChild(xml.c
xmlHeader.appendChild(xmlT
Set xmlTHead = nothing
Set xmlTHead = xml.createElement("THead")
xmlTHead.setAttribute "alias","PCG_CODE"
xmlTHead.appendChild(xml.c
xmlHeader.appendChild(xmlT
Set xmlTHead = nothing
xmlList.appendChild(xmlHea
dim xmlRow, xmlItem, strTemp
While(not rsGP.EOF)
Set xmlRow = xml.createElement("Row")
xmlRow.setAttribute "id", rsGp("AIS_GP_ID")
Set xmlItem = xml.createElement("Item")
xmlItem.setAttribute "alias","GP_ID"
strTemp = RsGp.Fields ("AIS_GP_ID").value
If IsNull(strTemp) then xmlItem.appendChild(xml.cr
else xmlItem.appendChild(xml.cr
xmlRow.appendChild(xmlItem
Set xmlItem = nothing
Set xmlItem = xml.createElement("Item")
xmlItem.setAttribute "alias","GP_CODE"
strTemp = RsGp.Fields ("AIS_GP_CODE").value
If IsNull(strTemp) then xmlItem.appendChild(xml.cr
xmlRow.appendChild(xmlItem
Set xmlItem = nothing
Set xmlItem = xml.createElement("Item")
xmlItem.setAttribute "alias","GP_NAME"
strTemp = RsGp.Fields ("GP_NAME").value
If IsNull(strTemp) then xmlItem.appendChild(xml.cr
xmlRow.appendChild(xmlItem
Set xmlItem = nothing
Set xmlItem = xml.createElement("Item")
xmlItem.setAttribute "alias","INITIALS"
strTemp = RsGp.Fields ("AIS_GP_INITIALS").value
If IsNull(strTemp) then xmlItem.appendChild(xml.cr
xmlRow.appendChild(xmlItem
Set xmlItem = nothing
Set xmlItem = xml.createElement("Item")
xmlItem.setAttribute "alias","GMC_NO"
strTemp = RsGp.Fields ("AIS_GP_GMC_NO").value
If IsNull(strTemp) then xmlItem.appendChild(xml.cr
xmlRow.appendChild(xmlItem
Set xmlItem = nothing
Set xmlItem = xml.createElement("Item")
xmlItem.setAttribute "alias","RCN_NO"
strTemp = RsGp.Fields ("AIS_GP_RCN_NO").value
If IsNull(strTemp) then xmlItem.appendChild(xml.cr
xmlRow.appendChild(xmlItem
Set xmlItem = nothing
Set xmlItem = xml.createElement("Item")
xmlItem.setAttribute "alias","PCT_CODE"
strTemp = RsGp.Fields ("AIS_GP_PCT_CODE").value
If IsNull(strTemp) then xmlItem.appendChild(xml.cr
xmlRow.appendChild(xmlItem
Set xmlItem = nothing
Set xmlItem = xml.createElement("Item")
xmlItem.setAttribute "alias","PCG_CODE"
strTemp = RsGp.Fields ("AIS_GP_PCG_CODE").value
If IsNull(strTemp) then xmlItem.appendChild(xml.cr
xmlRow.appendChild(xmlItem
Set xmlItem = nothing
xmlList.appendChild(xmlRow
rsGP.MoveNext ()
wend
'xmlDOCpage.appendChild(xm
xmlDOCpage.appendChild(xml
dim ProcInstn, xslPI
set ProcInstn = xml.createProcessingInstru
set xslPI = xml.createProcessingInstru
xml.appendChild(ProcInstn)
xml.appendChild(xslPI)
xml.appendChild(xmlDOCpage
'Response.Write xml.xml
response.write("<xmp>" & xml.xml & "</xmp>")
xml.save("sss.xml")
set createXML = xml
end function
%>
ASKER
Following is the XSL file
<?xml version = "1.0" ?>
<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0">
<xsl:import href = "../../XSL/AIS_List.xsl"/>
<xsl:template match = "/">
<xsl:apply-templates select = "Page"/>
</xsl:template>
<HTML>
<BODY>
<Table>
<TR>
<TD>
<xsl:value-of select = "List/Header/GP_ID"/>
</TD>
<TD>
<xsl:value-of select = "List/Header/GP_CODE"/>
</TD>
<TD>
<xsl:value-of select = "List/Header/GP_NAME"/>
</TD>
<TD>
<xsl:value-of select = "List/Header/Initials"/>
</TD>
<TD>
<xsl:value-of select = "List/Header/GMC_NO"/>
</TD>
<TD>
<xsl:value-of select = "List/Header/RCN_NO"/>
</TD>
<TD>
<xsl:value-of select = "List/Header/PCT_CODE"/>
</TD>
<TD>
<xsl:value-of select = "List/Header/PCG_CODE"/>
</TD>
</TR>
</Table>
</BODY>
</HTML>
<?xml version = "1.0" ?>
<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0">
<xsl:import href = "../../XSL/AIS_List.xsl"/>
<xsl:template match = "/">
<xsl:apply-templates select = "Page"/>
</xsl:template>
<HTML>
<BODY>
<Table>
<TR>
<TD>
<xsl:value-of select = "List/Header/GP_ID"/>
</TD>
<TD>
<xsl:value-of select = "List/Header/GP_CODE"/>
</TD>
<TD>
<xsl:value-of select = "List/Header/GP_NAME"/>
</TD>
<TD>
<xsl:value-of select = "List/Header/Initials"/>
</TD>
<TD>
<xsl:value-of select = "List/Header/GMC_NO"/>
</TD>
<TD>
<xsl:value-of select = "List/Header/RCN_NO"/>
</TD>
<TD>
<xsl:value-of select = "List/Header/PCT_CODE"/>
</TD>
<TD>
<xsl:value-of select = "List/Header/PCG_CODE"/>
</TD>
</TR>
</Table>
</BODY>
</HTML>
ASKER
Please change the asp file little bit to generate a dataset as ur own and then c. The program is generating th XML (I checked printing [XML object].XML. so I assume the problem is somewhere in the XSL.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Also, the XSLT you posted is not well formed. No closing stylesheet tag, for one. Also, this:
<xsl:import href = "../../XSL/AIS_List.xsl"/>
might be importing templates that are not well formed. Check the XSLT and all it's parts for well-formedness!
Regards,
Mike Sharp
<xsl:import href = "../../XSL/AIS_List.xsl"/>
might be importing templates that are not well formed. Check the XSLT and all it's parts for well-formedness!
Regards,
Mike Sharp