In Classic ASP reading cXML Files, is it required to point your dtd link to local files?

241 Views Asked by At

Unfortunately, we've inherited an old Classic ASP site and are writing new code for a round trip punch-out site. Reading in the cXML file, we're continually erroring out on the 2nd line !DOCTYPE cXML SYSTEM "http://xml.../cXML.dtd.

If we capture the location of the dtd file and change it to a local file, i.e., file:///c:/....dtd it works. Is there no way to get this to work using the http location? I'd rather not store all the dtd file versions locally.

Our Code is:

    Dim olddtdvalue
    Dim newdtdvalue
    Dim xmlfilename
    olddtdvalue = "http://xml.cxml.org/schemas/cXML/"
    newdtdvalue = "file:///d:/Websites/FSIResponsive/cXML/"
    xmlfilename ="PORS_" & formatdatetime(now,vblongdate) & " " & replace(formatdatetime(now,vblongtime),":","_") &  ".xml"
    set fs=Server.CreateObject("Scripting.FileSystemObject") 
    set f=fs.CreateTextFile("d:\WebSites\FSIResponsive\cXML\InFiles\" & xmlfilename,true)
    f.write("remote host: " & request.ServerVariables("REMOTE_HOST") & vbcrlf & vbcrlf)
    totalBytes = Request.TotalBytes
    If totalBytes > 0 Then
        xml = Request.BinaryRead( totalBytes )
        for i = 1 to totalBytes
            xmlstr = xmlstr + String(1,AscB(MidB(xml, i, 1)))
        Next
        f.write(xmlstr)
        xml2 = xmlstr
        xml2 = Replace(xml2,olddtdvalue,newdtdvalue)
    End if
    Set xdoc = Server.CreateObject("Microsoft.XMLDOM")
'   Set xdoc = Server.CreateObject("MSXML2.DOMDocument.6.0")
    xdoc.ValidateOnParse = True
    xdoc.async = False
    xdoc.resolveExternals = True
'   response.write xml2 
    loadStatus = xdoc.loadXML(xml2)

As you can see, we've tried using MSXML2.DOMDocument.6.0, but that doesn't work either.

Thanks, Alan

Update: Here's the code I finally got working:

Dim xmlfilename
Dim URL
totalBytes = Request.TotalBytes
If totalBytes > 0 Then
    xml = Request.BinaryRead( totalBytes )
    for i = 1 to totalBytes
        xmlstr = xmlstr + String(1,AscB(MidB(xml, i, 1)))
    Next
    xml2 = xmlstr
End if
Set xdoc = Server.CreateObject("MSXML2.DOMDocument.6.0")
xdoc.setProperty "ServerHTTPRequest", True
xdoc.setProperty "ProhibitDTD",False
xdoc.resolveExternals = True
xdoc.ValidateOnParse = True
xdoc.async =  False
loadStatus = xdoc.LoadXML(xml2)

Alan

0

There are 0 best solutions below