Skip to content

Instantly share code, notes, and snippets.

@bozhink
Created March 15, 2014 11:46
Show Gist options
  • Save bozhink/9565775 to your computer and use it in GitHub Desktop.
Save bozhink/9565775 to your computer and use it in GitHub Desktop.
Command line XSL Transformation using PHP
#!/usr/bin/php
<?php
if (empty($argv[1]) || empty($argv[2])) { die ("Usage: $argv[0] <xml-file> <xsl-file>\n"); }
$xmlFile = $argv[1];
$xslFile = $argv[2];
$dom = new domDocument();
$dom->load($xslFile);
$proc = new xsltprocessor;
$xsl = $proc->importStylesheet($dom);
$xml = new domDocument();
$xml->load($xmlFile);
$string = $proc->transformToXml($xml);
echo $string;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment