#!/usr/bin/env php load($input); /* TODO Check whether the input xml is valid – if not it is probably changed currently. * Add 5min timeout and try again */ $preprocess = new DOMDocument(); $preprocess->load('convert-style-to-html.xsl'); $process = new DOMDocument(); $process->load('endnote-to-dbxml.xsl'); $proc1 = new XSLTProcessor(); $proc1->importStyleSheet($preprocess); $proc2 = new XSLTProcessor(); $proc2->importStyleSheet($process); $step1 = $proc1->transformToDoc($xml); $step2 = $proc2->transformToXML($step1); /* * LOAD XML has bugs (NULL columns) when there are empty, self closing tags like * Replace those with <title> */ $step3 = preg_replace('#<([^>]*)/>#', '<\1>', $step2); file_put_contents($output, $step3); /* TODO: Issue the mysql command directly from php */ /* TODO: Write mail, add exception handler and write mail on error as well */