Пример #1
0
 public function let()
 {
     $this->xml = XMLString::fromString('<?xml version="1.0"?><hello-world><greeter>An XSLT Programmer</greeter><greeting>Hello, World!</greeting></hello-world>');
     $this->xsl = XSLString::fromString('<?xml version="1.0"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/hello-world"><HTML><HEAD><TITLE></TITLE></HEAD><BODY><H1><xsl:value-of select="greeting"/></H1><xsl:apply-templates select="greeter"/></BODY></HTML></xsl:template><xsl:template match="greeter"><DIV>from <I><xsl:value-of select="."/></I></DIV></xsl:template></xsl:stylesheet>');
     $this->output = '<HTML><HEAD><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><TITLE></TITLE></HEAD><BODY><H1>Hello, World!</H1><DIV>from <I>An XSLT Programmer</I></DIV></BODY></HTML>';
     $this->beConstructedWith($this->xml, $this->xsl);
 }
Пример #2
0
 public function getXML()
 {
     return XMLString::fromString($this->xml);
 }
 public function let()
 {
     $this->xml = XMLString::fromString(file_get_contents(dirname(__FILE__) . '/../../../tests/fixtures/jats/00288-vor.xml'));
     $this->output = file_get_contents(dirname(__FILE__) . '/../../../tests/fixtures/bib/00288-vor.bib');
     $this->beConstructedWith($this->xml);
 }
Пример #4
0
    require $autoload;
}
if (is_file($autoload = __DIR__ . '/../vendor/autoload.php')) {
    require $autoload;
} elseif (is_file($autoload = __DIR__ . '/../../../autoload.php')) {
    require $autoload;
} else {
    fwrite(STDERR, 'You must set up the project dependencies, run the following commands:' . PHP_EOL . 'curl -s http://getcomposer.org/installer | php' . PHP_EOL . 'php composer.phar install' . PHP_EOL);
    exit(1);
}
$xml = '';
while (($buffer = fgets(STDIN)) !== FALSE) {
    $xml .= $buffer;
}
if (!empty($xml)) {
    $xmlstring = \eLifeIngestXsl\ConvertXML\XMLString::fromString($xml);
    $convertxml = new \eLifeIngestXsl\ConvertXMLToHtml($xmlstring);
    $sections = ['//h1[contains(concat(" ", normalize-space(@class), " "), " page-title ")]' => $convertxml->getTitle(), '//*[@id="abstract"]/div' => $convertxml->getAbstract(), '//*[@id="digest"]/div' => $convertxml->getDigest(), '//*[@id="main-text"]/div' => $convertxml->getMainText(), '//*[@id="references"]/div' => $convertxml->getReferences(), '//*[@id="acknowledgements"]/div' => $convertxml->getAcknowledgements(), '//*[@id="decision-letter"]/div' => $convertxml->getDecisionLetter(), '//*[@id="author-response"]/div' => $convertxml->getAuthorResponse()];
    $excludes = ['//*[contains(concat(" ", normalize-space(@class), " "), " author-list-full ")]', '//*[contains(concat(" ", normalize-space(@class), " "), " elife-article-indicators ")]', '//*[contains(concat(" ", normalize-space(@class), " "), " panel-region-content-top ")]', '//*[contains(concat(" ", normalize-space(@class), " "), " pane-panels-ajax-tab-tabs ")]', '//*[contains(concat(" ", normalize-space(@class), " "), " author-list ")]', '//*[contains(concat(" ", normalize-space(@class), " "), " elife-institutions-list ")]', '//*[contains(concat(" ", normalize-space(@class), " "), " pane-elife-article-doi ")]', '//*[contains(concat(" ", normalize-space(@class), " "), " pane-elife-article-toolbox ")]', '//*[contains(concat(" ", normalize-space(@class), " "), " pane-elife-article-jumpto ")]', '//*[contains(concat(" ", normalize-space(@class), " "), " pane-elife-article-categories ")]'];
    $dom_template = new DOMDocument();
    $dom_template->loadHTMLFile(__DIR__ . '/elife-research-article.tpl.html');
    $html_prefix = '<meta http-equiv="content-type" content="text/html; charset=utf-8">';
    $wrapper = 'wrapper';
    foreach ($sections as $xpath_query => $html) {
        if (!empty($html)) {
            $xpath = new DOMXpath($dom_template);
            $elements = $xpath->query($xpath_query);
            if ($elements->length) {
                $replace_node = $elements->item(0);
                $replace_dom = new DOMDocument();
                $replace_dom->loadHTML($html_prefix . '<' . $wrapper . '>' . $html . '</' . $wrapper . '>');
 private function setupXML($filename = '00288-vor')
 {
     $xml = XMLString::fromString(file_get_contents(dirname(__FILE__) . '/../../../tests/fixtures/jats/' . $filename . '.xml'));
     $this->beConstructedWith($xml);
 }
Пример #6
0
 protected function getActualHtml($file)
 {
     return new ConvertXMLToHtml(XMLString::fromString(file_get_contents($this->jats_folder . $file . '.xml')));
 }