0

The Setup

I am using Flask in debug mode on my local machine & Google Chrome to check on my routes.

The Goal

I would like to render an XML response using this xml stylesheet. The response (incl. the xml-stylesheet tag) looks as follows (checking source in Google Chrome):

<?xml version="1.0" ?><?xml-stylesheet type="text/xsl" href="127.0.0.1:8887/oaitohtml.xsl"?><OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">
  <responseDate>2020-06-27T17:54:43Z</responseDate>
  <request verb="Identify">base_url</request>
  <Identify>
    <repositoryName>the_project</repositoryName>
    <baseURL>base_url</baseURL>
    <protocolVersion>2.0</protocolVersion>
    <adminEmail>contact@something.com</adminEmail>
    <earliestDatestamp>2011-01-01T00:00:00Z</earliestDatestamp>
    <deletedRecord>persistent</deletedRecord>
    <granularity>YYYY-MM-DDThh:mm:ssZ</granularity>
    <compression>gzip</compression>
    <compression>deflate</compression>
  </Identify>
</OAI-PMH>

What Goes Wrong?

However, when looking at the route in Google Chrome (localhost:5000/oai) in my case, I get only raw text output:

2020-06-27T18:01:41Z base_url the_project base_url 2.0 contact@something.com 2011-01-01T00:00:00Z persistent YYYY-MM-DDThh:mm:ssZ gzip deflate

What I Tried

I read that google does not allow reading files from files (e.g. having it in my static folder) due to security reasons, hence I tried to serve the file via Web Server for Chrome plugin. When I go to 127.0.0.1:8887/oaitohtml.xsl, I can indeed see the stylesheet.

What am I missing to make this work?

Cheers!

Matt
  • 435
  • 4
  • 17
  • 1
    Where do you expect `href="127.0.0.1:8887/oaitohtml.xsl"` to load the file from? Isn't there some protocol `href="http://127.0.0.1:8887/oaitohtml.xsl"` missing? And use F12 or any other way to open Chrome's developer console and check for any warning or messages related to not loading the XSLT. I am not sure where you load the XML from but if you load the XML from the file system I doubt that the browser allows pulling the XSLT over HTTP(S) from a server. You would need to load both files from the same origin and in Chrome, recent Mozilla, new Edge `xml-stylesheet` pi only works over HTTP(S). – Martin Honnen Jun 27 '20 at 18:19
  • I did use before actually. Both, the version loading from the /static folder and via 127.0.0.1:8887/oaitohtml.xsl load the xsl file from my local file system. I am using a third-party library to create the XML response in code (they use lxml) actually without the use of Flask Templates or whatsoever. – Matt Jun 27 '20 at 18:29
  • 2
    Chrome has not allowed file based `xml-stylesheet` for years, Mozilla has disallowed it some months ago in an attempt to fix an exploit. Both use to show a warning or error message in the console so check there. And I would expect HTTP based loading to work as long as the same origin policy requirements are met. – Martin Honnen Jun 27 '20 at 18:32

0 Answers0