#!/usr/bin/php
<?php

    if ( FALSE===($xp=new XSLTProcessor()) ) { print "unable to create xslt engine"; return FALSE; }

    $text=file_get_contents( $argv[1] );

    // Load the XML source
    $xml=new DOMDocument;
    //$xml->loadXML($text);
    $xml->loadHTML($text);

    // then load the XSL stylesheet
    $xsl=new DOMDocument;
    $xsl->resolveExternals = TRUE;
    $xsl->substituteEntities = TRUE;
    $xsl->load('extractmirrors.xsl');

    // attach the stylesheet
    $xp->importStyleSheet($xsl);

    $list=$xp->transformToXML($xml);

    $echo $list;
?>
