• flipflap

    This is a somewhat delayed reply and I would like to apologise for that.

    Thank you all for your very helpful suggestions. I have solved the problem - and in more than one way.

    Using WKWebView, as per the suggestion above, I was able to run SaxonCE and pass out the results via a callback handler.

    I also managed to work out the correct URL construction to use a 'requests' POST to the oxgarage site.

    Finally, I used the WKWebView python to generate book covers automatically and take JPEG screenshots of them to be used in the EPUB books. Please see the linked images of an example EPUB book I produced using pythonista.

    Once again, thank you for your assistance.

    Images:

    https://ibb.co/68mnWtM
    https://ibb.co/nbRPhfj

    posted in Pythonista read more
  • flipflap

    @sociallydistant thank you!

    Ok, then. I have made some progress. It seems that using Saxon CE allows the transformation to be applied successfully to a test file. I have an html page with javascript in it that replaces the same page’s contents with the XSLT result. I ran this outside of Pythonista. So the next step would be to control this process from Pythonista, read off the results there and then construct the EPUB. I’m not yet sure how to proceed. I need something within the python environment that will execute javascript and allow access to what it produces. Using bottle perhaps?

    My fallback option is to parse the tei xml in Python and transform it that way.

    Thanks again!

    posted in Pythonista read more
  • flipflap

    This is currently stalled. I don't have access to a desktop computer atm and I'm not sure how to conpile xsl to SEF on the phone. The Saxon-JS documentation states that a javascript xsl compiler is included, but, if I'm reading this correctly, it doesn't help me because it cannot generate the SEF or SEF.JSON file. I had wondered if the result of compilation could be passed on immediately without writing out a file, but I suspect it can't (I'm not completely sure).

    I tried using transformToFragment, but it returned null. I think the problem is (possibly) that it doesn't support XSLT 2.0. Perhaps XSLT 1.0 files would suffice to perform the transform. I haven't yet been able to Google up such files, but I'll try again later.

    posted in Pythonista read more
  • flipflap

    I have to confess that I’m not very knowledgeable about javascript etc., although I have dabbled with it occasionally. I was considering using XSLTProcessor.transformToFragment() . Is that the right approach? Can I use the load method you suggest to get access to a node reference to pass to the above?

    I had considered the requests idea before, but the ox garage site has a javascript convert button. According to some comments on stackexchange, that can be awkward to deal with (can be handled with Selenium, but there are problems getting it working on ios - needs a browser driver).

    Cheers!

    posted in Pythonista read more
  • flipflap

    Thank you for the replies. I had previously looked into using JavaScript to carry out the transformation. However, the example I saw relied on the necessary files being served up by a server, which I don’t have access to atm. Further, it is said that JavaScript in-browser requires user interaction to load local files and that’s something I’d like to avoid.

    I also noticed that Pythonista has a web server library, but I wasn’t able to get to get a server response when running the included test() function (and I’m not sure it can run concurrently with the other stuff I want to do given the iOS limitations on fork/background processing etc.).

    posted in Pythonista read more
  • flipflap

    Thank you for the suggestion. It's under consideration. Other ideas also welcome.

    posted in Pythonista read more
  • flipflap

    Good morning.

    I would like to convert some documents from the Perseus Library into EPUB format. The documents have been made available in TEI XML format, e.g.:

    https://github.com/PerseusDL/canonical-latinLit

    As I understand it, the conversion can be achieved by applying an XSL Transformation. There is a site set up for this, which is fine for a small number of documents, but not especially efficient for more than that:

    https://oxgarage.tei-c.org/

    So I had wondered if I could do something with Pythonista. However, it seems that every approach I consider is thwarted in some way. For example, the libxml library has XSLT functions, but the library is not included with Pythonista and is not pure python.

    I wonder if someone could suggest something that would work.

    Thank you.

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!