Re: [Chiba-devel] xsi:type/xforms:type on complex elements/binds
Creators discontinued Chiba & founded betterFORM http://betterform.de
Brought to you by:
chibaxforms,
windauer
From: Tambet M. <tam...@gm...> - 2009-07-21 07:59:15
|
Ronald van Kuijk wrote: > Hahaha.... I did not expect that just preventing the validation would > be 'the right thing to do' but if it comes from you I believe it is > :-)... I could have done something similar myself if I'd just dared to > :-[ Sometimes when deadline is ticking you just do what makes it work ;). > > I went the other way, preventing your schema2xform.xsl from adding > type attributes to elements of a complex type which works to. In > addition to this I'd rather have the xforms:type on the bind then the > xsi:type, feels like it kind of fits better there, but that is an > unimportant detail The original purpose of the script was to make XForms forms for SOAP web services. SOAP requires xsi:type attribute for all elements. I agree, that having them within binds would be nicer. The correct solution would be, that wsdl2xforms generates xsi:type and schema2xforms generates type attribute within bind. > > Besides this issue, two other small had to be solved before Chiba > works with custom types. That is adding the custom namespace to the > root element of the document and also referencing the schema from the > model schema attribute. If all three are done, your patch is not > needed. This was because I wanted full schema validation, but your > schema2xforms.xsl creates more constraints in the form, so > schemavalidation is not realy needed anymore. I considered this approach, because very often WSDL already contains schema. But there were several obstacles: 1. Schema in WSDL file is for all services in that file. Copying that schema into every form would make all forms unnecessarily big. One option here would be to put schema into separate file that is referenced from every form. 2. I was bit puzzled, when schema rules will apply. When schema defines a type (simple or complex), and you use that type, then everything is clear. But when schema defines rules for element with certain name, then these rules will be applied only if this element is a root element? But I had the elements inside SOAP envelope. So it would require me to generate fake schema for SOAP envelope. I finally decided, that generating all validation rules with binds would be clearer and easier. > > I just got all this fixed (took me 6 hours since my 'xslt' was a bit > rusty), but if your patch also works (I'll give it a try) there are 2 > solutions. It would mean though that your schema2xforms could also be > used for previous versions of Chiba. > > Btw, I saw you use chiba:match which does not seem to be in the > current 3.0.0 branche. Does this mean schema2xforms is just for 2? > Since there is code in chiba 2 for this but I'm not sure if that could > be ported to 3.0 since migration to saxon took place. This was just workaround, because Chiba didn't support XPath 2.0 matches() function. Does Chiba 3 use Saxon? Then it should be easy to replace. http://www.saxonica.com/documentation/functions/intro/fn_matches.html > > Nice work btw with the xslt, Only thing missing for me is an extension > to be able to generate labels/hints/tooltips from external files in > addition to getting it from annotations. Thanks for encouragement. Regarding your question there are several possibilities: 1. You could create "texts" instance in XForms file, which is populated from external XML file. Then you could use ref attribute of labels, hints and help to get the text from that instance. Something like this: <xforms:instance id="texts" src="texts.xml"/> <xforms:input ref="somefield"> <xforms:label ref="instance('texts')/text[@field='somefield']"/> </xforms:input> You could make language of your forms changeable on fly, if you include language selector on your form: <xforms:select1 ref="instance('temp')/language"> <xforms:label>Language</xforms:label> <xforms:item> <xforms:value>en</xforms:value> <xforms:label>English</xforms:value> <xforms:item> <xforms:item> <xforms:value>et</xforms:value> <xforms:label>Estonian</xforms:value> <xforms:item> </xforms:select> <xforms:input ref="somefield"> <xforms:label ref="instance('texts')/language[@code=instance('temp')/language]/text[@field='somefield']"/> </xforms:input> Orbeon Forms Builder does it this way. 2. If you would prefer doing it during generation, then you could use document() function of XSLT. http://www.saxonica.com/documentation/functions/intro/xslt_document.html In both cases you would have to override few templates at the end of schema2xforms.xsl file. Preferable would be to make your own .xsl, which imports schema2xforms.xsl. Tambet |