0

I am using an msxml 6.0 transform method under VBScript, on a more or less conventional XML document. The setup is like this:

Set objXSL = CreateObject("MSXML2.FreeThreadedDOMDocument.6.0") 
objXSL.setProperty "AllowDocumentFunction",True
objXSL.setProperty "AllowXsltScript",True
objXSL.resolveExternals = True
objXSL.async = false
objXSL.load(Server.MapPath("MyStylesheet.xsl"))
Set xslTemplate = CreateObject("MSXML2.XSLTemplate.6.0") 
xslTemplate.setProperty "AllowXsltScript", True
xslTemplate.stylesheet = objXSL
Set xslProc = xslTemplate.createProcessor()

Then after that I issue the transform() method command which requires an input and an output buffer, like,

xslProc.input = objXmlDomInput
xslProc.output = objXmlDomOutput
xslProc.transform()

Is there a way to tell transform() to use the same buffer for both the source and destination? The way it is now, your memory footprint is roughly double. This is causing trouble for me, with a semi large DOM in the result. It just seems inelegant to have to support two objects, when the Input one is basically a throwaway after transform() is done. Thank you, Stackoverflow readers!

Dave
  • 378
  • 4
  • 14
  • 2
    I am not sure how you expect that to work exactly, you want the transform to manipulate the input? As for having two DOMs in memory, do you need the result as a DOM at all or can't you simply directly write to the ASP response or a file stream? I am really no expert with VBScript, if you want the input to be released after having done the transformation, can't you put the code into a function with local variables returning only the result so that the input is available for garbage collection ones the function has been executed? – Martin Honnen Apr 17 '17 at 20:56
  • Hi Martin, I was actually trying to simplify the question down, the main point being you don't need the input whatsoever after the result is created in the output. Another point is I'm actually doing n- number of successive transforms in a loop, so the output from one step becomes the input to the next step. So you have to copy the output of step 1 over to become the input of step 2. It just seems like there's two objects around all the time when you're really after "the result." Maybe I am just stuck with this. – Dave Apr 17 '17 at 23:39
  • 1
    I have done a quick test with MSXML feeding the same DOM as input and output and it seems to handle it (I only tested with transformNodeToObject, not sure whether that makes a difference). I have also not checked whether that reduces memory consumption in any way or whether it just means that that use of the API works with an internal copy of the input to be able to create the output. – Martin Honnen Apr 18 '17 at 06:03
  • I will look into that, so thanks. I will report what I find out here if possible. That is a good clue, to use transformNoteToObject instead of basic transform, if that allows one to operate on one DOM only. I presume there are some internal copies or bits and pieces around, so it could be memory consumption is still at risk. – Dave Apr 18 '17 at 11:56

0 Answers0