xsl-list
[Top] [All Lists]

Transform in-memory XML domDocument

2002-11-10 00:02:56
Where am I going wrong?
Using an ASP page and MSXML, I want to build an XML file listing
document in memory, and then simply transform it -(using a stylesheet
that merges all the filenames provided).
The file listing will work when output directly to the browser with the
command 'xmlDoc.save response', but I can't seem to style it before
output.
Surely there is a simple answer to a basic problem but I can't find an
example anywhere.
My lack of VBscript skills will no doubt account for the error.
 
Error message:
'Error Type:
Microsoft VBScript runtime (0x800A01F4)
Variable is undefined: 'xmlResponseDoc'
/CustomsXML/Serverside Revision II/test.asp, line 52'
 
The abbrev. ASP code FYI -
<%
Response.ContentType = "text/xml"

strRootPath = "xml/"

'Create xml document
Dim xmlDoc
Set xmlDoc = Server.CreateObject("Msxml2.DOMDocument.4.0")
 xmlDoc.async = false
Dim xmlPI, xmlElement, xmlAtt
'Set encoding of XML document
Set xmlPI = xmlDoc.appendChild(xmlDoc.createProcessingInstruction("xml",
"version='1.0' encoding='utf-8'"))
Set xmlDoc.documentElement = xmlDoc.createElement("xsl:output")
Set xmlAtt =
xmlDoc.documentElement.Attributes.setNamedItem(xmlDoc.createAttribute("m
ethod"))
xmlAtt.Value = ("'xml'")
'Create root element and set base attribute
Set xmlDoc.documentElement = xmlDoc.createElement("folder")
Set xmlAtt =
xmlDoc.documentElement.Attributes.setNamedItem(xmlDoc.createAttribute("l
ocation"))
xmlAtt.Value = strRootPath & strPath
'Reading subfolder and files
Dim objFileSystemObject, objDirectory, objSubDirectory, objFile
Set objFileSystemObject =
Server.CreateObject("Scripting.FileSystemObject")
Set objDirectory =
objFileSystemObject.GetFolder(Server.MapPath(strRootPath & strPath))
For Each objFile In objDirectory.Files
 'Create tree node
 Set xmlElement =
xmlDoc.documentElement.appendChild(xmlDoc.createElement("file"))
  'Make attribute "name" equal to file name
 Set xmlAtt =
xmlElement.Attributes.setNamedItem(xmlDoc.createAttribute("name"))
 xmlAtt.value = strRootPath & strPath & objFile.Name 
 Set xmlAtt =
xmlElement.Attributes.setNamedItem(xmlDoc.createAttribute("date"))
 xmlAtt.value = objFile.DatelastModified
Next

'---> no longer write directly to response stream 
'//xmlDoc.save response 
 
' --->create XSL object
Dim xslDoc
set xslDoc = Server.CreateObject("MSXML2.DomDocument.4.0")
 xslDoc.async = false
 xslDoc.load server.MapPath("customsnews_mergeDocs.xsl")

---> transform created Xml Document with Xsl doc.
xmlDoc.transformNodeToObject xslDoc, response --->'line 52, Error
message here.
 
%>
 
 
Damian Clark




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>