Commit fa39b6b5 authored by Jérôme Chauveau's avatar Jérôme Chauveau
Browse files

premiers essais de pipeline xsl. #26

parent 45abccef
Loading
Loading
Loading
Loading
+33 −6
Changes for XML2HTMLPlugin.php: 33 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ class XML2HTMLPlugin extends GenericPlugin
    private function archiveView(string $filePath, int $submissionId, int $galleyId, string $op)
    {
        $htmlFile = XML2HTMLPlugin::getHTMLPathFromZipPath($filePath);
        $html = file_get_contents($htmlFile);
        $html = FALSE;//file_get_contents($htmlFile);
        //make transfo only if html does not exist
        if (!$html) {
            //get sources format from settings
@@ -204,13 +204,28 @@ class XML2HTMLPlugin extends GenericPlugin
    )
    {


        $xslFileName = strtolower($format) . '2html.xsl';
        ////// xslt transfo
        $xsltPath = dirname(__FILE__) . DIRECTORY_SEPARATOR . $xslFileName;
        // Load the XML source


        $xsltDir= dirname(__FILE__)
            . DIRECTORY_SEPARATOR
            . 'xsl'
            . DIRECTORY_SEPARATOR
            . strtolower($format)
            . DIRECTORY_SEPARATOR;

        $result = NULL;
        foreach (glob($xsltDir . "*.xsl") as $xsltPath) {

            $xml = new DOMDocument;
            if($result == NULL){
                // Load the XML source
                $xml->load($xmlFilePath);
            }
            else {
                //load previous xsl result
                $xml->loadXML($result);
            }

            $xsl = new DOMDocument;
            $xsl->load($xsltPath, LIBXML_DTDATTR);
@@ -218,9 +233,21 @@ class XML2HTMLPlugin extends GenericPlugin
            // Configure the transformer
            $proc = new XSLTProcessor;
            $proc->importStyleSheet($xsl); // attach the xsl rules

            //lang param
            $locale = AppLocale::getLocale();
            $proc->setParameter('', 'lang', $locale);
        return $proc->transformToXML($xml);

            try {
                $result = $proc->transformToXML($xml);
            }
            catch(Exception $e) {
                $result = NULL;
                var_dump($e);
            }

        }
        return $result;

    }

+16 −12
Changes for tei2html.xsl: 16 added lines, 12 removed lines.
Original line number Diff line number Diff line
@@ -14,8 +14,7 @@
    <!--doctype-system="http://www.w3.org/TR/html4/loose.dtd"-->
    <!--encoding="UTF-8"/>-->

    <xsl:output method="html"
        encoding="UTF-8" indent="no"/>
    <xsl:output method="html" encoding="UTF-8" indent="no"/>

    <xsl:strip-space elements="*"/>

@@ -330,7 +329,7 @@
        <div class="ab-book-meta-field">
            <!--            <node><xsl:copy-of select="current()"/></node>-->
            <xsl:if test="descendant::tei:dim[@type='pagination']/text() != ''">
                <xsl:text>Pagination : </xsl:text>
                <xsl:text>Pagination : </xsl:text>
                <xsl:value-of select="descendant::tei:dim[@type='pagination']"/>
            </xsl:if>
        </div>
@@ -418,7 +417,7 @@
    <xsl:template match="tei:label[ancestor::tei:div[@type='index']]">
        <xsl:apply-templates/>
        <xsl:if test="parent::tei:item[parent::tei:list[@type='level1']]">
            <span class="toggle-button"> [+]</span>
            <span class="toggle-button"> [+]</span>
        </xsl:if>
    </xsl:template>

@@ -530,7 +529,7 @@
                    <xsl:attribute name="onclick">
                        <xsl:value-of select='concat("openFigureWindow&#40;&apos;",parent::tei:figure/@xml:id,"&apos;&#41;")'/>
                    </xsl:attribute>
                <xsl:text>     ↗ </xsl:text>
                    <xsl:text>     ↗ </xsl:text>
                </a>
            </span>
        </label>
@@ -553,7 +552,7 @@
                    <xsl:attribute name="onclick">
                        <xsl:value-of select='concat("openFigureWindow&#40;&apos;",parent::tei:figure/@xml:id,"&apos;&#41;")'/>
                    </xsl:attribute>
                <xsl:text>     ↗ </xsl:text>
                    <xsl:text>     ↗ </xsl:text>
                </a>
            </span>
        </label>
@@ -650,8 +649,13 @@

    <!-- liste -->
    <xsl:template match="tei:list">
        <xsl:variable name="listType" select="if( @type = 'ordered' )
        then ( 'ol' ) else ( 'ul' )"/>
        <xsl:variable name="listType">
          <xsl:choose>
            <xsl:when test="@type = 'ordered'">ol</xsl:when>
            <xsl:otherwise>ul</xsl:otherwise>
          </xsl:choose>
        </xsl:variable>

        <xsl:variable name="attributeValue" select="replace(@rendition, '^#?list-', 'list-style-type:')"/>
        <xsl:element name="{$listType}">
            <xsl:attribute name="class" select="concat('index-',@type)"/>
@@ -694,13 +698,13 @@
        <xsl:choose>
            <xsl:when test="parent::tei:figure[@rend='inline']">
                <span class="{@notation}">
                    <xsl:copy-of select="concat('$$',node(),'$$')"/>
<!--                    <xsl:copy-of select="concat('$$',node(),'$$')"/>-->
                </span>
            </xsl:when>
            <xsl:otherwise>
                <div class="formula-tex">
                    <xsl:copy-of select="@*"/>
                    <xsl:copy-of select="concat('$$',node(),'$$')"/>
<!--                    <xsl:copy-of select="@*"/>-->
<!--                    <xsl:copy-of select="concat('$$',node(),'$$')"/>-->
                </div>
            </xsl:otherwise>
        </xsl:choose>
@@ -708,7 +712,7 @@

    <xsl:template match="*[namespace-uri()='http://www.w3.org/1998/Math/MathML']">
        <xsl:element name="{local-name()}">
            <xsl:copy-of select="@* except(@display)"/>
<!--            <xsl:copy-of select="@* except(@display)"/>-->
            <xsl:apply-templates select="node()"/>
        </xsl:element>
    </xsl:template>
+0 −0

File moved.