XForm Template Source Editor

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

XForm Template Source Editor

bwallis42
Have you ever considered putting in a simple xml source editor as an alternative to the designer/edit-source option? i.e. support a url of the form "/orbeon/fr/orbeon/builder/sourceedit/000" that opens a simple javascript based xml source editor such as codemirror (http://codemirror.net/).

The reason I'm asking is that I have some old form templates that run fine in the form runner but use constructs that are not supported in the builder (xf:repeat and others). Often they are also missing some of the boilerplate code like the fr-form-metadata instance. When I open them in the builder to edit their source I get the following instead of the source:

<dummy xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
       xmlns:xh="http://www.w3.org/1999/xhtml"
       xmlns:xi="http://www.w3.org/2001/XInclude"
       xmlns:ev="http://www.w3.org/2001/xml-events"
       xmlns:secure="java:org.orbeon.oxf.util.SecureUtils"
       xmlns:frf="java:org.orbeon.oxf.fr.FormRunner"
       xmlns:saxon="http://saxon.sf.net/"
       xmlns:xs="http://www.w3.org/2001/XMLSchema"
       xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
       xmlns:xbl="http://www.w3.org/ns/xbl"
       xmlns:fb="http://orbeon.org/oxf/xml/form-builder"
       xmlns:p="http://www.orbeon.com/oxf/pipeline"
       xmlns:fbf="java:org.orbeon.oxf.fb.FormBuilder"
       xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
       xmlns:xf="http://www.w3.org/2002/xforms"
       xmlns:toolboxOps="java:org.orbeon.oxf.fb.ToolboxOps"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>

I assume this is because the builder processes the template prior to editing and that processing is failing. I see the following errors in my logfile

2017-04-10 12:51:17,077 38770070 ERROR [ajp-0.0.0.0-8209-6] xslt.XSLTTransformer - Error at line 414 of oxf:/forms/orbeon/builder/form/annotate.xpl:
None.get: None.get
2017-04-10 12:51:17,080 38770073 ERROR [ajp-0.0.0.0-8209-6] xslt.XSLTTransformer - Error at line 469 of oxf:/forms/orbeon/builder/form/annotate.xpl:
None.get

thanks
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: XForm Template Source Editor

Alessandro  Vernet
Administrator
Hi Brian,

If the form was created with an old version of Form Builder, it should be automatically upgraded for you. But in this case, I imagine you're talking about a form whose source was modified, and thus can't be upgraded automatically. In that case, my recommendation would be for you to do the upgrade manually.

In this case, I imagine you were using an <xf:repeat> because Form Builder didn't support repeated grids. Now that it does, you could create a form with a repeated grid, see what the source looks like, and change the source of your other form to match that format. Would this make sense for you?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: XForm Template Source Editor

bwallis42
Yes, we have a *lot* of forms that were hand crafted and yes, a lot of usage of xf:repeat. Our total of templates across our customer base is over 1000 so we won't be converting by hand.

I am crafting an xsl script to do the conversion for us and will be trying to convert the repeats into repeating grids. Unfortunately the existing forms are not all done consistently so it is a challenge getting a working script but we will get there. As long as we can cover 95% of them the final few shouldn't be too hard.

I'm still interested in having a simple xform template source editor though, ever considered adding one?

brian...
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: XForm Template Source Editor

Alessandro  Vernet
Administrator
Hi Brian,

Using XSLT and having a (semi-)automated way to convert your forms makes sense, especially if you have a large number of them.

I don't think the need to have just the source code editor came up before for us, but I can see how it could be doable.

Just to make sure I understand this properly: if you have some structure in your form Form Builder doesn't recognize, like an <xf:repeat>, you can still open the form in Form Builder, open the Edit Source dialog, and edit that part, can't you?

The part with the <xf:repeat> might not be shown in the Form Builder main panel until you convert it to a grid in the source editor, but it will show in the source editor, and it not showing Form Builder main panel can be seen as feature, as this gives you good feedback on what is understood by Form Builder, doesn't it?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: XForm Template Source Editor

bwallis42
Alessandro Vernet wrote
I don't think the need to have just the source code editor came up before for us, but I can see how it could be doable.
It would be an easy way to edit forms for when you are building hand crafted forms, which we seem to have quite a few of for various reasons.  It is something I am considering doing external to Orbeon anyway using codemirror.

Just to make sure I understand this properly: if you have some structure in your form Form Builder doesn't recognize, like an <xf:repeat>, you can still open the form in Form Builder, open the Edit Source dialog, and edit that part, can't you?

The part with the <xf:repeat> might not be shown in the Form Builder main panel until you convert it to a grid in the source editor, but it will show in the source editor, and it not showing Form Builder main panel can be seen as feature, as this gives you good feedback on what is understood by Form Builder, doesn't it?
Alex
No, some forms just get replaced with the dummy element shown above so you cannot even edit the source. In these cases we have to go find it in our repository and edit it using vi or something like that. These forms display and work OK but the builder just doesn't cope with something in them.

thanks
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: XForm Template Source Editor

Alessandro  Vernet
Administrator
Hi Brian,

I forgot that you had cases where part of the form (or the whole form?) is replaced by a <dummy> element. I don't think this should happen. Would you be able to share with us the source of a form where you have this, so we can reproduce the problem by pasting the source of that form in Form Builder? (And it doesn't need to be a real form; if you prefer, a simple/minimal test case would work as well.)

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: XForm Template Source Editor

bwallis42
Hi Alex,
  Here is an example. The whole form is replaced with the dummy element when you try to edit the source. The builder displays nothing but the form works OK. I'm running 2016.3.

This is a hand crafted form but has been translated from it's original version we used with 3.9 orbeon.


2.xml

(hope the file attach works :-)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: XForm Template Source Editor

bwallis42
actually, I'm not sure that form does work correctly. The text area does not get displayed when it is used.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: XForm Template Source Editor

bwallis42
Ahh, drop the spell checker from under the text area. Then it works OK but still breaks in the editor.

thanks.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: XForm Template Source Editor

Alessandro  Vernet
Administrator
In reply to this post by bwallis42
Hi Brian,

I am loading the form, and see the following problems:

1. missing <fr:body> inside the <fr:view>
2. missing instance `fr-form-instance`

If you fix those 2 problems, you'll be able to load the form in Form Builder. It won't show "properly", but you can then go fix the remaining issues with the source editor in Form Builder. If this is a problem you have across many forms, maybe you can fix this automatically for all the forms, before you load them in Form Builder?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: XForm Template Source Editor

bwallis42
Ahh, thanks Alex.

Should have seen that. My converter script is meant to fix those two things but obviously missed it on this form, it must have a different structure from the others that do get those fixes applied.

thanks
brian...
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: XForm Template Source Editor

Alessandro  Vernet
Administrator
No problem, and of course, and of course let us know if you find other cases where Form Builder fails, while it think it shouldn't. (There is some tension here in the code: failing when finding something *really* wrong in the source allows errors to be caught early and makes the Form Builder code simpler, but it also doesn't give you a chance to fix the problem in the Form Builder source editor.)

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Loading...