[Xsltforms-support] Adding XPath functions
Brought to you by:
alain-couthures
From: David C. <ot...@cr...> - 2010-03-30 21:27:04
|
I'm trying to update an application that used an older version of XSLTForms to use a more current release of XSLTForms but locally added XPath functions are no longer working. Can someone point me to the appropriate documentation or advise me what I'm doing wrong? For a simple test case I've modified the Hello World example, as shown below, to add a simple function in my own namespace. This works in Safari, Chrome, and Opera, but not Firefox up through SVN rev 360. It doesn't work in any of those browsers from SVN rev 361 onwards. <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl"?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:local="http://example.com/local"> <head> <title>Testing local XPath functions</title> <script> window.addEventListener('load', function() { XPathCoreFunctions['http://example.com/local sample'] = new XPathFunction(false, XPathFunction.DEFAULT_NONE, false, function() { return "a test"; } ); }, false); </script> <xf:model> <xf:instance> <data xmlns=""> <PersonGivenName/> </data> </xf:instance> </xf:model> </head> <body> <p>This is <xf:output value="local:sample()" />.</p> <p>Type your first name in the input box. <br/> If you are running XForms, the output should be displayed in the output area.</p> <xf:input ref="PersonGivenName" incremental="true"> <xf:label>Please enter your first name: </xf:label> </xf:input> <br /> <xf:output value="concat('Hello ', PersonGivenName, '. We hope you like XForms!')"> <xf:label>Output: </xf:label> </xf:output> </body> </html> When the above page fails to load, the following alert is generated: Error initializing : Function http://www.w3.org/2005/xpath-functions sample() not found Looking at the generated HTML in Safari, the generated JavaScript has the expected namespace when creating the FunctionCallExpr prior to r361: XPath.create("local:sample()",new FunctionCallExpr('http://example.com/local sample')); But beginning with r361 (and with all versions when loaded in Firefox), the namespace used when creating the FunctionCallExpr is wrong: XPath.create("local:sample()",new FunctionCallExpr('http://www.w3.org/2005/xpath-functions sample')); Is this a XSLTForms bug or am I doing something wrong? - David |