On 12/09/2011 16:34, Emmanuel Bégué wrote:
> I just downloaded and tried Saxon-CE.
> I'm trying to apply a stylesheet to a part of the DOM. The use case is
> this: the user pastes rich text in a contentEditable element, and
> after pressing a button gets their text transformed in some other
> format (proprietary XML, or RTF, etc.)
> as parameters the source node and a stylesheet uri, and return either
> a nodeset or a string, according to the value of the method attribute
> of the output parameter of the stylesheet.
> This doesn't seem to be possible right now.
there are no real technical difficulties in providing one - though
designing a good API is always a challenge.
> I was able to have something working by providing a template name to
> the<script type="application/xslt+xml" language="xslt2.0"> element;
> this named template is actually empty so I don't understand why it's
I'm not sure I understand this point.
> In order to get something back from the transformation, it seems that
> one needs to use result-document with a target in the host page; this
> is a little counter-intuitive (would not be needed if the
> transformation could be called from a js function) but more
> importantly, it makes it difficult to test the transformation from
> outside the browser (where the target does not exist).
Testing is certainly a challenge. I'm currently testing stylesheets by
importing them into a host XSLT stylesheet that acts as the test driver,
capturing transformation results in variables. But I expect I'll be
using Selenium in due course.
> It also makes hard (impossible?) to access the result of the
> transformation before it is parsed by the browser?
> - in the use case described above, the transformation results in error
> if the source element contains a newline (Chrome) or a space
> (Firefox). The error is the same: "invalid character". Amazingly,
> Firefox does not recover from this error: the same error is thrown
> even if the offending characters are removed from the contentEditable
> element; in Chrome the error disappears if one deletes all newline
What exactly do you mean by "the source element" - where is the
offending space/newline? Is this basically a well-formedness error in
the XML source document? Saxon is very dependent on the browser for XML
parsing, so there may be limits on what can be achieved here - though it
does seem that Saxon has at least caught the exception.
> - would it be possible that errors do not pop alert boxes but console
> messages instead?
Yes, I'm very happy to listen to what's wanted here. I didn't use
console messages by default because it tends to mean that by default,
you see a blank screen with no output and no error messages.
> (If useful I can post a simple demo of what I'm trying to do).
> -- error when contentEditable contains a newline / space --
> Exception class client.net.sf.saxon.ce.trans.XPathException
> (NS_ERROR_DOM_INVALID_CHARACTER_ERR): String contains an invalid
> code: 5
> INDEX_SIZE_ERR: 1
> DOMSTRING_SIZE_ERR: 2
> HIERARCHY_REQUEST_ERR: 3
> WRONG_DOCUMENT_ERR: 4
> INVALID_CHARACTER_ERR: 5
> NO_DATA_ALLOWED_ERR: 6
> NO_MODIFICATION_ALLOWED_ERR: 7
> NOT_FOUND_ERR: 8
> NOT_SUPPORTED_ERR: 9
> INUSE_ATTRIBUTE_ERR: 10
> INVALID_STATE_ERR: 11
> SYNTAX_ERR: 12
> INVALID_MODIFICATION_ERR: 13
> NAMESPACE_ERR: 14
> INVALID_ACCESS_ERR: 15
> VALIDATION_ERR: 16
> TYPE_MISMATCH_ERR: 17
> DATA_CLONE_ERR: 25
> result: 2152923141
> filename: saxon-ce-alpha-0.3/DAC18FBF00BF32B86E60481CE0A93721.cache.html
> lineNumber: 2934
> columnNumber: 0
> inner: null
> data: null
> Doing More with Less: The Next Generation Virtual Desktop
> What are the key obstacles that have prevented many mid-market businesses
> from deploying virtual desktops? How do next-generation virtual desktops
> provide companies an easier-to-deploy, easier-to-manage and more affordable
> virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/
> saxon-help mailing list archived at http://saxon.markmail.org/