View Single Post
  #3  
Old 11-24-2006, 11:42 AM
kevina kevina is online now
Registered User
 
Join Date: 03-26-2003
Posts: 825
The Transform XML Log action is written specifically for transforming Visual Build Professional log files, so it probably isn't entirely appropriate for your particular use (the last tab is specific to the xml log format of Visual Build Professional).

Yours is the first request we've received for the ability to more generically transform xml (using dynamic parameter values) but it is a good one which we will consider directly supporting in a future version of Visual Build Professional.

In the meantime, you could use something like the code below as a VBScript function (untested) to do the transform:

Code:
Function TransformXML(xmlFileName, xslFileName, outFileName, parameterNamesValues)
	' pass the parameters as "Name1|Value1,Name2|Value2" etc
	
	Set xml = CreateObject("MSXML2.DOMDocument")
   	xml.async = False
	xml.load xmlFileName

	Set xsl = CreateObject("MSXML2.DOMDocument")
	xsl.async = False
	xsl.load xslFileName

	Set xslt = CreateObject("MSXML2.XSLTemplate")
	Set xslt.stylesheet = xsl
	Set xslProc = xslt.createProcessor()
	xslProc.input = xml
	
	parameters = Split(parameterNameValues, ",")
	If IsArray(parameters) Then
		For i = LBound(parameters) To UBound(parameters)
			param = Split(parameters(i), "|")
			xslProc.addParameter param(0), param(1)
		Next
	End If
	
	xslProc.transform
	Set fout = vbld_FSO.CreateTextFile(outFileName)
	fout.Write xslProc.output
	fout.Close
	
End Function
You could add the above function (untested) as a project or global function, then invoke it in a Run Script step with something like this:

Code:
   TransformXML "xmlfilename", "xslFileName", "outFileName", "param1Name|param1Value,param2Name|param2Value"
You can substitute %MACRONAME% for any of these values in the Run Script step

See the following urls for more info on the above function:
http://msdn.microsoft.com/library/de...25391bbc10.asp
http://p2p.wrox.com/topic.asp?TOPIC_ID=11225
Reply With Quote