Thread: [Xsltforms-support] Problem with replace all
Brought to you by:
alain-couthures
From: Thorsten R. <t...@sc...> - 2010-01-27 23:31:52
Attachments:
step1.xhtml
step2.xhtml
|
Hi I'm trying to write my first XRX app and cannot get a form to work where I replace one xform with another. While the whole thing is starting to get complicated with modules and all, I think I have isolated the problem in a simple example. I wrote two straightforward xhtml files step1.xhtml and step2.xhtml. If they are loaded separately (and explicitly) both work. But if step2 is loaded by submitting step1 it does not work. I observed the problem in firefox 3.5.7. Pages are served by eXist 1.4.0rc-rev10028-20090908 on the localhost (ubuntu karmic koala). I'll attach the xhtml fies and past it as well in case attachments are filtered out: step1: <?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl"?> <?xsltforms-options debug="yes"?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xf="http://www.w3.org/2002/xforms"> <head> <title>Edit Person</title> <xf:model> <xf:instance> <person> <FAMILY/> </person> </xf:instance> <xf:submission id="submit" method="get" action="step2.xhtml" replace="all" /> </xf:model> </head> <body> <xf:input ref="FAMILY"> <xf:label>Family:</xf:label> </xf:input> <xf:submit submission="submit"> <xf:label>Next</xf:label> </xf:submit> </body> </html> step2: <?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl"?> <?xsltforms-options debug="yes"?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xf="http://www.w3.org/2002/xforms"> <head> <title>Edit Person</title> <xf:model> <xf:instance> <person> <FAMILY/> </person> </xf:instance> </xf:model> </head> <body> <xf:input ref="FAMILY"> <xf:label>Family:</xf:label> </xf:input> </body> </html> Regards Thorsten |
From: Klotz, L. <Lei...@xe...> - 2010-01-28 17:28:23
|
I think this is an XSLTForms limitation of submission replace='all', but of course Alain would have to answer that. I believe the problem is because replace='all' uses XHR, even when method='get'. You can use an XSLTForms-only hack for POST, by doing method="xml-urlencoded-post". In this case, XSLTForms creates an HTML4 form and serializes the XML into a single HTML4 field named "postdata." The disadvantge is that you must alter server-side code to look for a URL Encoded POST containing a parameter "postdata" and then extract that and parsing it as XML. Personally, I think that XSLTForms could similarly implement submission method='get' when replace='all' by creating an HTML form element, and there would be no compensation needed and your example below would work. Perhaps Alain has already explored this and found it unworkable for some reason, or perhaps it is just work that needs doing (and maybe you could help?) Leigh. -----Original Message----- From: Thorsten Roggendorf [mailto:t...@sc...] Sent: Wednesday, January 27, 2010 2:58 PM To: xsl...@li... Subject: [Xsltforms-support] Problem with replace all Hi I'm trying to write my first XRX app and cannot get a form to work where I replace one xform with another. While the whole thing is starting to get complicated with modules and all, I think I have isolated the problem in a simple example. I wrote two straightforward xhtml files step1.xhtml and step2.xhtml. If they are loaded separately (and explicitly) both work. But if step2 is loaded by submitting step1 it does not work. I observed the problem in firefox 3.5.7. Pages are served by eXist 1.4.0rc-rev10028-20090908 on the localhost (ubuntu karmic koala). I'll attach the xhtml fies and past it as well in case attachments are filtered out: step1: <?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl"?> <?xsltforms-options debug="yes"?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xf="http://www.w3.org/2002/xforms"> <head> <title>Edit Person</title> <xf:model> <xf:instance> <person> <FAMILY/> </person> </xf:instance> <xf:submission id="submit" method="get" action="step2.xhtml" replace="all" /> </xf:model> </head> <body> <xf:input ref="FAMILY"> <xf:label>Family:</xf:label> </xf:input> <xf:submit submission="submit"> <xf:label>Next</xf:label> </xf:submit> </body> </html> step2: <?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl"?> <?xsltforms-options debug="yes"?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xf="http://www.w3.org/2002/xforms"> <head> <title>Edit Person</title> <xf:model> <xf:instance> <person> <FAMILY/> </person> </xf:instance> </xf:model> </head> <body> <xf:input ref="FAMILY"> <xf:label>Family:</xf:label> </xf:input> </body> </html> Regards Thorsten |
From: Thorsten R. <ju...@sc...> - 2010-01-28 19:45:22
|
Hi Leigh Thanks for the response. I'm new to xForms so I was not sure whether it was my fault. Note that I originally observed the problem in a post request/response. I made it a get so that it is more easily reproducible. Also thanks for the workaround suggestion. However, I'll first try to split up the page and store the required data in a user session between calls. If it works, the solution will be generic (instead of xsltforms-specific). And finally my apologies, but I have no time to help with fixing that (and I hardly know XSLT). I could only give up my own project in order to help you. Regards Thorsten Am Donnerstag, den 28.01.2010, 09:27 -0800 schrieb Klotz, Leigh: > I think this is an XSLTForms limitation of submission replace='all', > but of course Alain would have to answer that. I believe the problem > is because replace='all' uses XHR, even when method='get'. > > You can use an XSLTForms-only hack for POST, by doing > method="xml-urlencoded-post". In this case, XSLTForms creates an > HTML4 form and serializes the XML into a single HTML4 field named > "postdata." The disadvantge is that you must alter server-side code > to look for a URL Encoded POST containing a parameter "postdata" and > then extract that and parsing it as XML. > > Personally, I think that XSLTForms could similarly implement submission > method='get' when replace='all' by creating an HTML form element, and > there would be no compensation needed and your example below would > work. Perhaps Alain has already explored this and found it unworkable > for some reason, or perhaps it is just work that needs doing (and > maybe you could help?) > > Leigh. > > -----Original Message----- > From: Thorsten Roggendorf [mailto:t...@sc...] > Sent: Wednesday, January 27, 2010 2:58 PM > To: xsl...@li... > Subject: [Xsltforms-support] Problem with replace all > > Hi > > I'm trying to write my first XRX app and cannot get a form to work > where I replace one xform with another. While the whole thing is > starting to get complicated with modules and all, I think I have > isolated the problem in a simple example. I wrote two straightforward > xhtml files step1.xhtml and step2.xhtml. If they are loaded separately > (and explicitly) both work. But if step2 is loaded by submitting step1 > it does not work. > > I observed the problem in firefox 3.5.7. Pages are served by eXist > 1.4.0rc-rev10028-20090908 on the localhost (ubuntu karmic koala). > > I'll attach the xhtml fies and past it as well in case attachments are filtered out: > > step1: <?xml-stylesheet href="xsltforms/xsltforms.xsl" > type="text/xsl"?> <?xsltforms-options debug="yes"?> <html > xmlns="http://www.w3.org/1999/xhtml" > xmlns:ev="http://www.w3.org/2001/xml-events" > xmlns:xs="http://www.w3.org/2001/XMLSchema" > xmlns:xf="http://www.w3.org/2002/xforms"> <head> <title>Edit > Person</title> <xf:model> <xf:instance> > <person> <FAMILY/> > </person> </xf:instance> > <xf:submission id="submit" method="get" action="step2.xhtml" > replace="all" /> </xf:model> </head> <body> <xf:input > ref="FAMILY"> <xf:label>Family:</xf:label> </xf:input> > <xf:submit submission="submit"> > <xf:label>Next</xf:label> </xf:submit> </body> </html> > > step2: <?xml-stylesheet href="xsltforms/xsltforms.xsl" > type="text/xsl"?> <?xsltforms-options debug="yes"?> <html > xmlns="http://www.w3.org/1999/xhtml" > xmlns:ev="http://www.w3.org/2001/xml-events" > xmlns:xs="http://www.w3.org/2001/XMLSchema" > xmlns:xf="http://www.w3.org/2002/xforms"> > <head> <title>Edit > Person</title> <xf:model> <xf:instance> > <person> <FAMILY/> > </person> </xf:instance> </xf:model> > </head> <body> <xf:input ref="FAMILY"> > <xf:label>Family:</xf:label> </xf:input> </body> </html> > > Regards > Thorsten |
From: COUTHURES A. <ala...@ag...> - 2010-01-29 17:15:35
|
Hello, > I think this is an XSLTForms limitation of submission replace='all', but of course Alain would have to answer that. > The required instructions to interpret an XSLT processing-instruction (such as the one for applying xsltforms.xsl !) in the return of the submission are not yet implemented. > I believe the problem is because replace='all' uses XHR, even when method='get'. > XmlHttpRequest is the only way to manage errors, if any, from the initial XForms document. > You can use an XSLTForms-only hack for POST, by doing method="xml-urlencoded-post". In this case, XSLTForms creates an HTML4 form and serializes the XML into a single HTML4 field named "postdata." The disadvantge is that you must alter server-side code to look for a URL Encoded POST containing a parameter "postdata" and then extract that and parsing it as XML. This hack was easy to implement. It guarantees that the browser knows it is a completely new page so memory leak should be under control. But there is no error management... By the way, at server-side, it is not necessary to check if the parameter is named "postdata" or anything else... > > > Personally, I think that XSLTForms could similarly implement submission method='get' when replace='all' by creating an HTML form element, and there would be no compensation needed and your example below would work. I consider that xf:load is better for that usage. > Perhaps Alain has already explored this and found it unworkable for some reason, or perhaps it is just work that needs doing (and maybe you could help?) > There is still plenty of work that needs doing in XSLTForms ! Thanks! -Alain |
From: Klotz, L. <Lei...@xe...> - 2010-01-29 17:27:41
|
Alain, -----Original Message----- From: COUTHURES Alain [mailto:ala...@ag...] Sent: Friday, January 29, 2010 9:16 AM To: Klotz, Leigh Cc: Thorsten Roggendorf; xsl...@li... Subject: Re: [Xsltforms-support] Problem with replace all Hello, > > I think this is an XSLTForms limitation of submission > replace='all', but of course Alain would have to answer that. > The required instructions to interpret an XSLT processing-instruction (such as the one for applying xsltforms.xsl !) in the return of the submission are not yet implemented. I still believe the <submssion method="get" replace="all"> could easily use the same technique as the XSTLForms feature <submssion method="xml-urlencoded-post"> and use the underlying HTML4 form implementation for the GET instead of using XHR. This seems like a small amount of work, and would fix the main use case immediately. > I believe the problem is because replace='all' uses XHR, even when method='get'. XmlHttpRequest is the only way to manage errors, if any, from the initial XForms document. I believe that having the success case of replace='all' work according to spec is more important than having the failure case work. Also, XForms 1.1 Test 11.4.9.b was recently changed to use replace='none' instead of replace='all' because it seems likely that xforms-submit-error handling is not possible in the replace='all' case in many processors, not just Ubiquity and XSLTForms. See http://lists.w3.org/Archives/Public/public-forms/2009Dec/0074.html for discussion. > You can use an XSLTForms-only hack for POST, by doing > method="xml-urlencoded-post". In this case, XSLTForms creates > an HTML4 form and serializes the XML into a single HTML4 field > named "postdata." The disadvantge is that you must alter > server-side code to look for a URL Encoded POST containing a > parameter "postdata" and then extract that and parsing it as > XML. This hack was easy to implement. It guarantees that the browser knows it is a completely new page so memory leak should be under control. But there is no error management... By the way, at server-side, it is not necessary to check if the parameter is named "postdata" or anything else... > Personally, I think that XSLTForms could similarly implement submission method='get' > when replace='all' by creating an HTML form element, and there would be no compensation > needed and your example below would work. I consider that xf:load is better for that usage. > Perhaps Alain has already explored this and found it unworkable for > some reason, or perhaps it is just work that needs doing (and maybe > you could help?) > There is still plenty of work that needs doing in XSLTForms ! Thanks! -Alain Leigh. |
From: COUTHURES A. <ala...@ag...> - 2010-01-29 17:33:46
|
Leigh, > I still believe the <submssion method="get" replace="all"> could easily use > the same technique as the XSTLForms feature <submssion > method="xml-urlencoded-post"> and use the underlying HTML4 form > implementation for the GET instead of using XHR. > > This seems like a small amount of work, and would fix the main use case immediately. > Don't you think that <submission method="get" replace="all">, with no instance data to submit, has no meaning itself and that <load> should be used instead ? -Alain |
From: Klotz, L. <Lei...@xe...> - 2010-01-29 17:40:15
|
I don't mean to cause confusion; I meant with instance data to submit, serialized as application/x-www-form-urlencoded. For example: <html> <head> <model> <instance> <data xmlns=""> <q /> <hl>en</hl> </data> </instance> <submission id="do-search" method="get" resource="http://www.example.com/search" replace="all" /> </model> </head> <body> <input ref="q"> <label>Search: </label> <send submission="do-search" ev:event="DOMActivate" /> </input> <select1 ref="hl"> <label>Language</label> <item><label>English</label><value>en</value></item> <item><label>French</label><value>fr</value></item> </select1> </body> </html> -----Original Message----- From: COUTHURES Alain [mailto:ala...@ag...] Sent: Friday, January 29, 2010 9:34 AM To: Klotz, Leigh Cc: Thorsten Roggendorf; xsl...@li... Subject: Re: [Xsltforms-support] Problem with replace all Leigh, > I still believe the <submssion method="get" replace="all"> could > easily use the same technique as the XSTLForms feature <submssion > method="xml-urlencoded-post"> and use the underlying HTML4 form > implementation for the GET instead of using XHR. > > This seems like a small amount of work, and would fix the main use case immediately. > Don't you think that <submission method="get" replace="all">, with no instance data to submit, has no meaning itself and that <load> should be used instead ? -Alain |
From: Thorsten R. <ju...@sc...> - 2010-01-29 22:06:26
|
Hi > The required instructions to interpret an XSLT > processing-instruction (such as the one for applying xsltforms.xsl > !) in the return of the submission are not yet implemented. You seem to prefer the other solution - which I don't fully understand, so I'm a bad judge for that. However, doing a manual transform is rather trivial (I've tried, it really is). See http://www.w3schools.com/xsl/xsl_client.asp . This example is synchronous but I guess you have code for async XHR in place so adapting that would be simple. That only leaves the task of finding the processing instruction nodes. They are usually at the beginning of the document, so that should also be no problem. If it is though, a tiny dedicated XSLT could be used to extract such nodes. Regards Thorsten |
From: Klotz, L. <Lei...@xe...> - 2010-01-30 00:54:10
|
Having the browser Location display and the back button work properly with replace='all' is useful; of course, it depends on what we mean by "properly" ! If you use an HTML4 form submission with method="GET" to mimic an XHTML+XForms submission with replace='all': * After replace=all, the browser Location display shows the URL of the new page. * The back button takes you back to the the XHTML+XForms1.1 page. * Pressing Reload will reload the displayed page. * Bookmarks will bookmark the displayed page. If you use XHR and manual page re-processing: * After replace=all, the browser Location display still shows the URL of the XHTML+XForms page. * The back button takes you back to the page before the XHTML+XForms page. * Pressing Reload will reload the previous (XHTML+XForms) page. * Bookmarks will bookmark the previous (XHTML+XForms) page. So there's a choice to be made: when you do replace='all' are you getting a new page, and want all the user agent machinery of a new page, or are you keeping the same page, but with content from an internal source? Personally, I believe that obeying the expected user agent behavior for "replace" is correct, which is why I think it's possible to use the HTML4 form. Leigh. -----Original Message----- From: Thorsten Roggendorf [mailto:ju...@sc...] Sent: Friday, January 29, 2010 2:06 PM To: Klotz, Leigh Cc: COUTHURES Alain; xsl...@li... Subject: RE: [Xsltforms-support] Problem with replace all Hi > The required instructions to interpret an XSLT > processing-instruction (such as the one for applying xsltforms.xsl > !) in the return of the submission are not yet implemented. You seem to prefer the other solution - which I don't fully understand, so I'm a bad judge for that. However, doing a manual transform is rather trivial (I've tried, it really is). See http://www.w3schools.com/xsl/xsl_client.asp . This example is synchronous but I guess you have code for async XHR in place so adapting that would be simple. That only leaves the task of finding the processing instruction nodes. They are usually at the beginning of the document, so that should also be no problem. If it is though, a tiny dedicated XSLT could be used to extract such nodes. Regards Thorsten |