Re: [Xsltforms-support] applying a stylesheet in an instance to data in an instance
Brought to you by:
alain-couthures
From: C. M. Sperberg-M. <cm...@bl...> - 2012-07-15 20:14:36
|
On Jul 12, 2012, at 3:15 PM, C. M. Sperberg-McQueen wrote: > In a form I'm working on, I'd like to apply a stylesheet located in a > document instance (instance('filter') to an input document located in > another instance (instance('userdoc')). For others interested in this topic, I should record that this is in fact possible and a simple extension function does the job. A number of test cases that demonstrate the use of transform() and an extension function for instance-based XSLT transforms can be found at http://blackmesatech.com/2012/07/testcase/transform/index.xml Michael Sperberg-McQueen > ... > So I wrote an extension function that looks like this: > > function bmt_applyxslt_ns_s(nsXML, sXSLT) { > if (arguments.length !== 2) { > throw XsltForms_xpathFunctionExceptions.transformInvalidArgumentsNumber; > } > return nsXML.length === 0? "" : XsltForms_browser.transformText(XsltForms_browser.saveXML(nsXML[0]), sXSLT, true); > } > > This is almost verbatim the same as the source code for transform(), > except for the argument names and 'true' instead of 'false' in the > third argument. This code appears to work correctly, given a good stylesheet. > I register the function with XSLTforms in the usual way. > > <xf:setvalue > ref="instance('userout')/self::data" > value="bmt:s_applyxslt_ns_s(instance('userdoc'), serialize(instance('filter')))"/> > > The form loads as expected and the function seems to be called > without incident and without error messages (and alert messages > confirm that the arguments look pretty much as I expect them to look). > But the result is consistently not the output I expect from the stylesheet, > but a document which reads in its entirety: > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> > <head><title></title></head> > <body> > <pre></pre> > </body> > </html> > > Anyone have a clue? Anyone have a better (or just different) way to go about > this? This appears to be Safari's way of signaling an error of some kind in the execution of the XSLT transform. -- **************************************************************** * C. M. Sperberg-McQueen, Black Mesa Technologies LLC * http://www.blackmesatech.com * http://cmsmcq.com/mib * http://balisage.net **************************************************************** |