Re: [Xsltforms-support] Change instance via JavaScript?
Brought to you by:
alain-couthures
From: Alain C. <ala...@ag...> - 2011-11-11 07:05:21
|
Hello, Javascript URIs are not already supported in XSLTForms for submissions. I was just asking if it could be interesting because it shouldn't be difficult to implement and it would be quite elegant. What do you think? Thanks! -Alain Le 09/11/2011 03:31, C. M. Sperberg-McQueen a écrit : > I should mention that I do realize that a simple string-to-string > function can be defined as an XPath extension as shown in the > page on extensions at > http://en.wikibooks.org/wiki/XSLTForms/XSLTForms_only_Extensions#User-Defined_Functions > -- I'm just trying to get a grip on the method of using a submission to > a Javascript URI as a technique for calling Javascript from an XForms > (specifically XSLTForms) context. > > On Nov 8, 2011, at 6:55 PM, C. M. Sperberg-McQueen wrote: > >> On Nov 6, 2011, at 3:41 PM, Alain Couthures wrote: >>>> ... >>> Modifying an instance with Javascript instructions is always problematic >>> because of dependencies to be set for refresh. It could also be very >>> specific of a version of en implementation... >>> >>> Maybe the best way would be to just define an extension for submission: >>> instead of "http:" or "file:", "javascript:" could be used to retrieve a >>> string from a Javascript instruction. >>> >>> You could then externally activate a submit action for it. >>> >>> What do you think? >> >> Well, I don't know about the original poster, but I think you've just >> explained to me how to handle a problem I was having without a >> trip to the server. Thank you! >> >> However, when I try to put this idea into practice, I encounter >> a simple practical difficulty. I want to use Javascript to manipulate a >> string in the document, so I write a function called, say, >> manipulate_string, which takes a string as argument and returns >> a string as its result. >> >> I can write a submission element that specifies a call to this >> function as the resource, and I can even specify the argument >> (which I have placed in an instance document for the purpose), >> thus: >> >> <xf:submission id="hackstring" >> method="get" >> ref="instance('stringhack')/s" >> replace="text" >> targetref="instance('stringhack')/s" >> > >> <xf:resource >> value="concat('javascript:manipulate_string("', instance('stringhack')/s, '")')" >> /> >> </xf:submission> >> >> But before submission, XForms appends "?s=" and the value of the >> XPath expression in the 'ref' attribute, which has the effect that >> the Javascript call is not recognized so my function never executes. >> >> Is there a way around this problem? >> >> -- >> **************************************************************** >> * C. M. Sperberg-McQueen, Black Mesa Technologies LLC >> * http://www.blackmesatech.com >> * http://cmsmcq.com/mib >> * http://balisage.net >> **************************************************************** >> >> >> >> |