Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Saxon-CE engine does not perform serialization. #6

Open
mrft opened this issue May 20, 2015 · 7 comments
Open

The Saxon-CE engine does not perform serialization. #6

mrft opened this issue May 20, 2015 · 7 comments

Comments

@mrft
Copy link

mrft commented May 20, 2015

At the Restrictions page, I read:

The Saxon-CE engine does not perform serialization. This means that the attribute disable-output-escaping is ignored. It also means that no meta attributes are inserted into HTML or XHTML output, and no escaping of URI-valued attributes takes place.

And of course my stylesheet relies on disable-output-escaping="yes".

Any plans on adding serialization?

Also something like

  <xsl:output cdata-section-elements="div" />

seems to be unsupported, so no workaround possible?

@michaelhkay
Copy link
Member

Other browser-based XSLT engines, e.g. Mozilla, have the same restriction. It’s the whole essence of Saxon-CE that it makes updates to the HTML DOM (a tree of nodes), not to the lexical HTML of the page. So no, we have no plans to change this.

Using disable-output-escaping is usually not the best way to solve your problem. What problem are you trying to solve with it?

Michael Kay
Saxonica

On 20 May 2015, at 16:44, mrft [email protected] wrote:

At the Restrictions http://www.saxonica.com/ce/user-doc/1.1/index.html#!conformance/restrictions page, I read:

The Saxon-CE engine does not perform serialization. This means that the attribute disable-output-escaping is ignored. It also means that no meta attributes are inserted into HTML or XHTML output, and no escaping of URI-valued attributes takes place.
And of course my stylesheet relies on disable-output-escaping="yes".

Any plans on adding serialization?


Reply to this email directly or view it on GitHub #6.

@mrft
Copy link
Author

mrft commented May 20, 2015

I am turning an xml-file containing 'my-own-xml' mixed with html parts into a standalone html-file that contains a working 'application' containing a lot of javascript.

This javascript is added into the xslt stylesheet inside CDATA sections, but when it comes out, it should still stay unescaped, or all of the javascript will fail.

I wanted to create an editor inside a webpage that would help users create this xml-file, and then be able to 'compile' and test it, right in an iframe in the same browser-window.
So it seems I am still unable to create an editor that runs completely in-the-browser (and that could ideally allow you to save the created files to dropbox or google drive instantly). I found out today that it's very easy to wrap saxon inside a java applet, but that seems a no-go since chrome has dropped support for NPAPI plugins.

Quite frustrating. I understand that your vision on what this project is suited for is different, but I am just looking to find a way to do full XSLT2.0 transformations inside the browser, including serialization.

(This 'my-own-xml' is basically a way to describe different types of interactive questions that can be run inside a webbrowser, like gap, multiple-choice, but also drag-sort, drag-match etc. questions. Answers can be sent to the server, and this currently works like the scorm2004 standard. The fact that it can be mixed with html, allows users to basically plug anything they want into these questions, like text, tables, images, svg code, whatever, without having to code anything. My vision is that picking a region on an image is just as much a multiple choice question, as picking a word in a sentence or picking something from a list of options. The code is the same, only the markup is a bit different. Also if I want to support a new LMS API for sending the answers to the server, like for instance TinCanAPI, I just have to change the javascript inside the xslt, and regenerate the html, but the source xml containing the question doesn't have to change. Same thing if the layout changes drastically, the question will still be the same, but the end-result might look very different, so I could do way more drastic changes than just css changes).

@mrft
Copy link
Author

mrft commented May 24, 2015

One more question: after the transformToDocument call, one gets a result document.

Does this contain enough information to do the serialization?
Could I write a serialization function myself, or is the necessary information to know how something should be serialized not even available in this data structure?

If that information is not there, would you be able (and willing) to add it, making it possible for someone else to write a serialization that can be run inside the browser?

Or would there be another way to solve the problem I have (maybe using features of this library that I am not aware of)?

@michaelhkay
Copy link
Member

It’s certainly possible to write your own serializer. A simple serializer can even be written in XSLT itself.

A paramount objective for Saxon-CE is to minimize the size of the library, so any serializer would need to be implemented as a separate and optional library.

Michael Kay
Saxonica

On 24 May 2015, at 11:31, mrft [email protected] wrote:

One more question: after the transformToDocument call, one gets a result document.

Does this contain enough information to do the serialization?
Could I write a serialization function myself, or is the necessary information to know how something should be serialized not even available in this data structure?

If that information is not there, would you be able (and willing) to add it, making it possible for someone else to write a serialization that can be run inside the browser?

Or would there be another way to solve the problem I have (maybe using features of this library that I am not aware of)?


Reply to this email directly or view it on GitHub #6 (comment).

@mrft
Copy link
Author

mrft commented May 24, 2015

The question I actually wanted to ask was: 'does the result document that is produced by transformToDocument contain all information necessary to do the serialization (like disable-output-escaping="yes")'.

Your answer seems to suggest that that is the case. Could you tell me where in the result tree I should look (what property?).

Thanks.

@pgfearo
Copy link

pgfearo commented May 25, 2015

I posted code for a very basic XML serializer (that works with the result-document) coded in JavaScript at: https://saxonica.plan.io/boards/1/topics/5915

This code only handles global namespace declarations that must be set in a JS literal object, it was written to overcome issues with iOS Safari's handling of XML namespaces.

If you have special serialization needs for Saxon-CE, you could possibly use this code as a starting point.

@mrft
Copy link
Author

mrft commented May 25, 2015

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants