#1
|
|||
|
|||
Transform XML log action-pass xslt parameters
I need to transform a xml file-therefore I created a 'Transform XML log' action.
In the Transform tab i have put: -Input file ->xml to be transformed (full path) -XSLT stylesheet->xslt file (full path) -Output file->the file resulting after the style was applied(full path) But xslt file takes 2 parameters -testassembly and profiledassembly: <xsl:param name="testassembly" /> <xsl:param name="profiledassembly"/> How can I pass these 2 params into VBP action? I do not see any place for setting xslt parameters. Basically I need to implement into VBP this NANT task: <style style="xsl\AddCoveredAssembly.xslt" in="${ncover.index}" out="${ncover.index}.tmp"> <parameters> <parameter name="testassembly" value="${testassembly}"/> <parameter name="profiledassembly" value="${profiledassembly}"/> </parameters> </style> |
#2
|
|||
|
|||
Could someone pls help me with this...
I need to solve it urgently!!! |
#3
|
|||
|
|||
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 Code:
TransformXML "xmlfilename", "xslFileName", "outFileName", "param1Name|param1Value,param2Name|param2Value" 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 |
#4
|
|||
|
|||
Thanks a lot for your answer.I already found an workaround-I created a 'Run Program' action where I run a XSLT command line processor made by Microsoft:
msxsl.exe "source.xml" "style.xslt" -o"result.html" "param1=value1" "param2"="value2". The only problem is I need to install this msxsl.exe on my box,normally I would like to use only VisBuild for such a thing. The solution proposed by you with VBScript is helpful as well. However-if this action would be implemented in a future release of VBP-it would be great!! I think you need just to change a little that 'Transform XML log' action in order to accept parameters. I used that action for other XSLT transforming and it was ok-of course that XSLT didn't need parameters. |
#5
|
|||
|
|||
I will also vote for a builtin XSLT action.
One thing to consider is to also pass a "MODE" setting to the XSLT processor in addition to the standard parameters. Most of my XSLT templates makes use of "MODE" attribute and I don't know how I managed without it. Another idea to consider is that parameters can be of type IDispatch. You could for example supply access to your "DOM" for XSLT code to use. I can provide some examples if needed. |
#6
|
|||
|
|||
I'd vote for an xslt action too.
|
#7
|
|||
|
|||
#8
|
|||
|
|||
I don't want to transform the build log though. I have a generated XML file that needs to be converted.
|
#9
|
|||
|
|||
You don't have to transform the build log file.
http://www.kinook.com/VisBuildPro/Ma...ansformtab.htm |
|
|