open-editions / corpus-joyce-portrait-TEI

The Open Scholarly Edition of James Joyce's A Portrait of the Artist as a Young Man
GNU General Public License v3.0
20 stars 20 forks source link

XSLT not working on Chrome #47

Closed JonathanReeve closed 7 years ago

JonathanReeve commented 7 years ago

The prototype transformation on github.io works fine on Firefox, but fails to transform correctly on Chrome and similar WebKit-based browsers. Chrome complains that "This XML file does not appear to have any style information associated with it. The document tree is shown below."

This is very likely due to an XSL issue, since XSL complains that:

runtime error: file portrait.xsl line 98 element attribute
xsl:attribute: Cannot add attributes to an element if children have been already added to the element.
tcatapano commented 7 years ago

This is because the template at line 97 matches at line 132 in the source on

<lg type="song">
            <l>O, the wild rose blossoms</l> 
            <l>On the little green place.</l> 
        </lg>

and the first thing it does is to create an attribute node, but this is illegal at this point, because an attriibute node has to precede any child element nodes of a parent element node. Could the template be changed to something like:

<div>
<xsl:attribute name="class">
        <xsl:value-of select="@type"/>
    </xsl:attribute>
    <p class="lg">
        <xsl:apply-templates select="@type | node()"/>
    </p>
</div>
</xsl:template>
tcatapano commented 7 years ago

Actually, if you just remove lines 98-100 of portrait.xsl, it should work.

JonathanReeve commented 7 years ago

Thanks for this! That got the XML transforming properly on the command-line, using xsltproc. I still can't get portrait.xml transforming directly in Chrome, but this at least allows me to generate an HTML file that I can use as a prototype page for now. Now http://jonathanreeve.github.io/corpus-joyce-portrait-TEI/index.html works. I made a Makefile to run the XSLT using xsltproc.

tcatapano commented 7 years ago

Yes, I've been looking into it and it looks like it is a Chrome thing. It may have to do with Github serving the xml with the mimetype application/xml for which Chrome will not execute the stylesheet (it may with text/xml). Or it could be a security issue about not executing a remote stylesheet in the brower. Not exactly sure.

On Tue, Sep 20, 2016 at 12:43 PM, Jonathan Reeve notifications@github.com wrote:

Thanks for this! That got the XML transforming properly on the command-line, using xsltproc. I still can't get portrait.xml transforming directly in Chrome, but this at least allows me to generate an HTML file that I can use as a prototype page for now. Now http://jonathanreeve.github.io/corpus-joyce-portrait-TEI/index.html works. I made a Makefile to run the XSLT using xsltproc.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/JonathanReeve/corpus-joyce-portrait-TEI/issues/47#issuecomment-248359435, or mute the thread https://github.com/notifications/unsubscribe-auth/AA7A8k0q5wQ9ITMSjS2dL_eJWfvVVF2jks5qsA0WgaJpZM4KADUj .

JonathanReeve commented 7 years ago

I've moved the prototype transformed edition to Netlify, here: https://joyce-portrait.netlify.com/. It'll automatically run make, using the Makefile, on each commit, and show the resulting index.html. This effectively meas we don't have to maintain a gh-pages branch, or worry about how XSL works on the client side. Closing this issue.