Re: [Xsltforms-support] Binding to optional element
Brought to you by:
alain-couthures
From: COUTHURES A. <ala...@ag...> - 2010-01-19 21:22:07
|
Hey Micah, > This was difficult to do in XForms 1.0. What's the latest state of the art? > > Say I have an XML instance like this: > <root> > <format>xml</format> > </root> > > Possible values for the format element are "xml", "text", "binary", or a default setting, indicated by a complete absence of the <format> element. I'd like this to attach to a select1 with four choices: > > <xf:select1 ref="format">... > > * xml > * text > * binary > * default > > Where the first three set the value of the <format> element, and the fourth omits the element altogether. In XForms 1.0, the difficulty comes from binding to a nonexistent element. Are there features from 1.1, 1.2, or XSLTForms that make this case easier? Anyone have an example? This is clearly a real world situation: the lack of an XML element has its own meaning in the XML world. The problem with XForms 1.1 is that an instance has two purposes: to act as a sort of schema and to represent the initial values. Being a sort of elementary schema, every element has to be present, even without a value. Lacks of element will disable corresponding bindings. Within a repeat, it's not possible to delete the very last item and then insert it again because there is no node to copy anymore... I think this should be in XForms 2.0 to separate this without confusion: one schema and one instance with initial values. XSLTForms doesn't support it yet but it's a very interesting feature because of this current restriction. Using an extra work instance in XForms 1.1 is, usually, a possible workaround, with some actions (depending on @if probably) to synchronize instances. Sorry, I haven't develop one yet myself for this kind of situation. -Alain |