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')).
It doesn't seem to be working, and I wonder if anyone here can see
what I'm doing wrong.
I've studied the code for the existing transform() function, which accepts
a node set and a URI and then calls XsltForms_browser.transformText
with that same node set, that same URI, and a flag to signal that the
second argument is a URI and not a literal string containing an angle-bracket
encoding of a stylesheet.
If I understand the code for the underlying transformText function
correctly (not guaranteed!), it can accept either a URI or a stylesheet
in string form in its second argument, and its third argument tells the
system which case applies.
- If the third argument is true, the second argument is passed to
a parser and a DOM object is returned.
- If the third argument is false, the second argument is used to
load an external document, and the resulting DOM is returned.
(At least, I assume the results are DOM objects.)
Other calls to transformText() seem to use strings successfully in
the second argument.
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. (I notice now that I ought to change the name of
the exception, perhaps, too.)
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?
Thanks!
Michael Sperberg-McQueen
--
****************************************************************
* C. M. Sperberg-McQueen, Black Mesa Technologies LLC
* http://www.blackmesatech.com
* http://cmsmcq.com/mib
* http://balisage.net
****************************************************************
------------------------------------------------------------------------------
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