[Xsltforms-support] serialize() fails on empty nodeset: workaround and proposed fix
Brought to you by:
alain-couthures
From: Leigh L K. Jr <lei...@xe...> - 2011-02-14 20:13:19
|
Calling the XPath extension function serialize(x) if x is an empty nodeset. In Firefox, it fails with a popup about a component failure. For example: <group ref="/path/to/parent"> <output value="serialize(x)" /> </group> This will fail if x doesn't exist, or even if parent doesn't exist. The only workaround I've found is a an instance with an empty element: <instance id="empty"><data xmlns=""><empty /></data></instance> <group ref="/path/to/parent"> <output value="serialize(instance('empty')/empty | x)" /> </group> Here's a proposed change to the serialize function which makes serialize return an empty string if there is no nodeset. Changes from xsltforms-dataisland-478.zip =================================================================== --- xsltforms.js (xsltforms-dataisland-478) +++ xsltforms.js (working copy) @@ -9241,6 +9241,7 @@ if (arguments.length == 0) { throw XPathCoreFunctionsExceptions.serializeNoContext; } + if (!nodeSet[0]) return ""; return Core.saveXML(nodeSet[0]); } ), |