Re: [Xsltforms-support] [PATCH] Adding extra XPath functions
Brought to you by:
alain-couthures
From: Kostis A. <ank...@gm...> - 2010-04-09 05:21:39
|
I was too quick to report "success!"... I tested on different browsers, and * on Chrome it is OK. * On firefox it does not find the correct NS :-( As an aid, i see that the xslt's result root node (the html element) does not contain the 'local' NS. I then tried the dummy attribute workaround but nothing. * On IE7 it does not locate the extra function, although the XPath expression seems OK, and the function's namspace is correct. It seems that the the registration code for the extra function does not work! It needs more work, particularly on firefox.... Kostis On Fri, Apr 9, 2010 at 4:00 AM, Kostis Anagnostopoulos <ank...@gm...> wrote: > 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> >> > |