diff options
-rwxr-xr-x | update.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/update.php b/update.php new file mode 100755 index 0000000..1a5233b --- /dev/null +++ b/update.php @@ -0,0 +1,37 @@ +#!/usr/bin/env php +<?php + +$input = 'LIKAT Publications.xml'; +$output = 'dbxml_new.xml'; + +/* Check filetime and do import only if the input xml was updated */ +if (filemtime($input) <= filemtime($output)) + exit; + +$xml = new DOMDocument(); +$xml->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); +$step3 = preg_replace('#<([^>]*)/>#', '<\1></\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 */ |