Kinook Software Forum

Kinook Software Forum (https://www.kinook.com/Forum/index.php)
-   [VBP] General Discussion (https://www.kinook.com/Forum/forumdisplay.php?f=2)
-   -   Transform XML log action-pass xslt parameters (https://www.kinook.com/Forum/showthread.php?t=2176)

teognost 11-23-2006 11:33 AM

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:



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:

teognost 11-24-2006 04:29 AM

Could someone pls help me with this...
I need to solve it urgently!!!

kevina 11-24-2006 12:42 PM

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

teognost 11-24-2006 01:47 PM

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.

Francois 12-07-2006 04:06 AM

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.

Hess_Joel 12-21-2009 10:48 AM

I'd vote for an xslt action too.

kinook 12-21-2009 10:53 AM

http://www.kinook.com/VisBuildPro/Ma...ogparamtab.htm

http://www.kinook.com/Forum/showthre...?threadid=2411

Hess_Joel 12-21-2009 10:56 AM

I don't want to transform the build log though. I have a generated XML file that needs to be converted.

kinook 12-21-2009 11:00 AM

You don't have to transform the build log file.
http://www.kinook.com/VisBuildPro/Ma...ansformtab.htm


All times are GMT -5. The time now is 06:12 PM.


Copyright © 1999-2023 Kinook Software, Inc.