HomeBlogPowerShell

XSLT processor with PowerShell

Here is a simple way to transform XML document with specified XSL in PowerShell. It is easy achieavable using the System.Xml.Xsl namespace of the .NET.

 

 

PARAM
(
    [Parameter(Mandatory = $true)]
    [ValidateNotNullOrEmpty()]
    [String]$XmlPath,
    
    [Parameter(Mandatory = $true)]
    [ValidateNotNullOrEmpty()]
    [String]$XslPath,
    
    [Parameter(Mandatory = $true)]
    [ValidateNotNullOrEmpty()]
    [String]$HtmlOutput
)

try
{
    $XslPatht = New-Object System.Xml.Xsl.XslCompiledTransform
    $XslPatht.Load($XslPath)
    $XslPatht.Transform($XmlPath, $HtmlOutput)
    
    Write-Host "Generated output is on path: $HtmlOutput"
}
catch
{
    Write-Host $_.Exception -ForegroundColor Red
}

 

We pass the path to the XML file and the path to the XSL file. Also the path where we want to save the transformed HTML file.
All validations for the parameters if they are null or empty are done by the PowerShell itself. For the moment there is no validation
if the paths are valid and if the files exists. It is ok because anyway the script will not complete as exepected with the check or without it.

 

Add comment


Security code
Refresh

Configure debugging environment for ARM in Ubuntu ...
Configure debugging environment for ARM in Ubuntu with Eclipse

Next article is how to configure SEGGER's J-Link debugger to debug the NuttX OS from Eclipse.  Here I'm going to describe the it using The J-Link hardware debugging Eclipse plug-in. [ ... ]

Building NuttX in Eclipse (Ubuntu)
Building NuttX in Eclipse (Ubuntu)

For me personally is more convenient to build the code directly from the IDE where I'm editing it so here is an article how to configure building of NuttX from Eclipse. I'm configuring [ ... ]

Install and configure NuttX ARM build environment ...
Install and configure NuttX ARM build environment in Linux

In this manual will see how to install and configure all the tools needed to build NuttX for ARM under Linux. The toolchain is the one comming with the Ubuntu itself (at least with the [ ... ]

LTCRabbit
LTCRabbit

The program provides quick access to some statistics from the LTCRabbit.com litecoin mining pool.  

Time Tracker
Time Tracker

Time Tracker is a tool to track the time that was spent for some task and how much this time costs. Features:
   - Set the complementary time
   - Set the rate per [ ... ]

Light Control
Light Control

App web site is now http://LightControl.us. Visit us there. Mobile application to control Philips Hue lights. So far it is only for Android. Features:
 - Easy and fast control [ ... ]

LTC: LKjqX7NipWXyPEkt3L3AwiRuCaw7h1hXLw
BTC: 1ApxQc2j4Wz3N7ei4XwYFTh6t4CeYMzbzZ

Go to top