The "transform()" function is not yet fully specified and it would be 
easy to temporarily add a third parameter to it to switch from URI to text.

As you mention it in your test case, another situation is whether the 
node for the stylesheet is a leaf or a sub-tree to be serialized and a 
fourth parameter could indicate this.

Currently, XSLTForms only supports a text result for the transformation 
and it can be used within a "setvalue" action. A sort of "loadXML" 
action could easily be added so the result will be loaded as a sub-tree.

What do you think?

Thanks!

-Alain

Le 15/07/2012 22:14, C. M. Sperberg-McQueen a écrit :
> 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.
>
>



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Xsltforms-support mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xsltforms-support

Reply via email to