[Xsltforms-support] [PATCH] Adding extra XPath functions
Brought to you by:
alain-couthures
From: Kostis A. <ank...@gm...> - 2010-04-09 04:01:03
|
Hi David, The problem (i think) was that the newer XPath expression parsing templates (as of rev361) for each xpath-expression they filled-in the contents of the variable 'xexprs' with a nodeset created out of the blue, so it had no NS attached - thus, your xmlns:local="..." declaration was lost. I solved it just by embeding the <xexprs> nodeset within a node from the source document, just by copying the current node. Note that I have not tested the patch thorougly, it just makes your test-case to run ok. For a quicker setup, you can mannually patch the final 'xsltforms.xsl' file in line: 197 Regards Kostis On Tue, Mar 30, 2010 at 9:26 PM, David Cato <ot...@cr...> wrote: > <?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> > |