Thread: [Xsltforms-support] Binding to optional element
Brought to you by:
alain-couthures
From: Micah D. <Mic...@ma...> - 2010-01-19 20:10:58
|
Hey everyone, 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? Thanks! -m |
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 |
From: Klotz, L. <Lei...@xe...> - 2010-01-19 21:25:14
|
You might be able to use the relevance-with-submission-flag hack: <bind nodeset="/root/format" relevant="instance('state')/aboutToSubmit = 'false' or . != ''" /> <instance id="state"><data xmlns=""><aboutToSubmit>false</aboutToSubmit></instance> <submit submission="save"> <setvalue ev:event="DOMActivate" ref="instance('state')/aboutToSubmit">true</setvalue> </submit> <submission id="save"> <setvalue ev:event="xforms-submit-done" ref="instance('state')/aboutToSubmit">false</setvalue> <setvalue ev:event="xforms-submit-error" ref="instance('state')/aboutToSubmit">false</setvalue> </submit> -----Original Message----- From: Micah Dubinko [mailto:Mic...@ma...] Sent: Tuesday, January 19, 2010 11:58 AM To: xsl...@li... Subject: [Xsltforms-support] Binding to optional element Hey everyone, 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? Thanks! -m ------------------------------------------------------------------------------ Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev _______________________________________________ Xsltforms-support mailing list Xsl...@li... https://lists.sourceforge.net/lists/listinfo/xsltforms-support |
From: Tambet M. <tam...@gm...> - 2010-01-20 08:34:22
|
This is the same solution I have used in wsdl2xforms, but I used xforms-submit event instead. <xforms:instance id="temp"> <temp> <relevant xsi:type="boolean">true</relevant> </temp> </xforms:instance> <xforms:submission ...> <xforms:setvalue ref="instance('temp')/relevant" value="false()" events:event="xforms-submit"/> <xforms:setvalue ref="instance('temp')/relevant" value="true()" events:event="xforms-submit-done"/> <xforms:setvalue ref="instance('temp')/relevant" value="true()" events:event="xforms-submit-error"/> </xforms:submission> <xforms:bind nodeset="/root/format" relevant="(. != '' or boolean-from-string(instance('temp')/relevant))"/> Works well enough in Chiba. OK, name could be more descriptive :). Tambet Klotz, Leigh wrote: > You might be able to use the relevance-with-submission-flag hack: > > <bind nodeset="/root/format" relevant="instance('state')/aboutToSubmit = 'false' or . != ''" /> > <instance id="state"><data xmlns=""><aboutToSubmit>false</aboutToSubmit></instance> > <submit submission="save"> > <setvalue ev:event="DOMActivate" ref="instance('state')/aboutToSubmit">true</setvalue> > </submit> > <submission id="save"> > <setvalue ev:event="xforms-submit-done" ref="instance('state')/aboutToSubmit">false</setvalue> > <setvalue ev:event="xforms-submit-error" ref="instance('state')/aboutToSubmit">false</setvalue> > </submit> > > -----Original Message----- > From: Micah Dubinko [mailto:Mic...@ma...] > Sent: Tuesday, January 19, 2010 11:58 AM > To: xsl...@li... > Subject: [Xsltforms-support] Binding to optional element > > Hey everyone, > > 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? > > Thanks! -m > > > ------------------------------------------------------------------------------ > Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. > http://p.sf.net/sfu/rsaconf-dev2dev > _______________________________________________ > Xsltforms-support mailing list > Xsl...@li... > https://lists.sourceforge.net/lists/listinfo/xsltforms-support > > ------------------------------------------------------------------------------ > Throughout its 18-year history, RSA Conference consistently attracts the > world's best and brightest in the field, creating opportunities for Conference > attendees to learn about information security's most important issues through > interactions with peers, luminaries and emerging and established companies. > http://p.sf.net/sfu/rsaconf-dev2dev > _______________________________________________ > Xsltforms-support mailing list > Xsl...@li... > https://lists.sourceforge.net/lists/listinfo/xsltforms-support > |
From: Micah D. <Mic...@ma...> - 2010-01-20 08:41:46
|
Thanks Tambet, Looks like a good direction to pursue. In the case where the default selection (no element) gets saved and then the form is reopened, in other words when the instance is <root/> How do you make it work (since the binding to /root/format goes nowhere)? -m On Jan 20, 2010, at 12:34 AM, Tambet Matiisen wrote: > This is the same solution I have used in wsdl2xforms, but I used > xforms-submit event instead. > > <xforms:instance id="temp"> > <temp> > <relevant xsi:type="boolean">true</relevant> > </temp> > </xforms:instance> > <xforms:submission ...> > <xforms:setvalue ref="instance('temp')/relevant" value="false()" > events:event="xforms-submit"/> > <xforms:setvalue ref="instance('temp')/relevant" value="true()" > events:event="xforms-submit-done"/> > <xforms:setvalue ref="instance('temp')/relevant" value="true()" > events:event="xforms-submit-error"/> > </xforms:submission> > <xforms:bind nodeset="/root/format" relevant="(. != '' or > boolean-from-string(instance('temp')/relevant))"/> > > Works well enough in Chiba. OK, name could be more descriptive :). > > Tambet > > Klotz, Leigh wrote: >> You might be able to use the relevance-with-submission-flag hack: >> >> <bind nodeset="/root/format" relevant="instance('state')/aboutToSubmit = 'false' or . != ''" /> >> <instance id="state"><data xmlns=""><aboutToSubmit>false</aboutToSubmit></instance> >> <submit submission="save"> >> <setvalue ev:event="DOMActivate" ref="instance('state')/aboutToSubmit">true</setvalue> >> </submit> >> <submission id="save"> >> <setvalue ev:event="xforms-submit-done" ref="instance('state')/aboutToSubmit">false</setvalue> >> <setvalue ev:event="xforms-submit-error" ref="instance('state')/aboutToSubmit">false</setvalue> >> </submit> >> >> -----Original Message----- >> From: Micah Dubinko [mailto:Mic...@ma...] >> Sent: Tuesday, January 19, 2010 11:58 AM >> To: xsl...@li... >> Subject: [Xsltforms-support] Binding to optional element >> >> Hey everyone, >> >> 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? >> >> Thanks! -m >> >> >> ------------------------------------------------------------------------------ >> Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. >> http://p.sf.net/sfu/rsaconf-dev2dev >> _______________________________________________ >> Xsltforms-support mailing list >> Xsl...@li... >> https://lists.sourceforge.net/lists/listinfo/xsltforms-support >> >> ------------------------------------------------------------------------------ >> Throughout its 18-year history, RSA Conference consistently attracts the >> world's best and brightest in the field, creating opportunities for Conference >> attendees to learn about information security's most important issues through >> interactions with peers, luminaries and emerging and established companies. >> http://p.sf.net/sfu/rsaconf-dev2dev >> _______________________________________________ >> Xsltforms-support mailing list >> Xsl...@li... >> https://lists.sourceforge.net/lists/listinfo/xsltforms-support >> > > > ------------------------------------------------------------------------------ > Throughout its 18-year history, RSA Conference consistently attracts the > world's best and brightest in the field, creating opportunities for Conference > attendees to learn about information security's most important issues through > interactions with peers, luminaries and emerging and established companies. > http://p.sf.net/sfu/rsaconf-dev2dev > _______________________________________________ > Xsltforms-support mailing list > Xsl...@li... > https://lists.sourceforge.net/lists/listinfo/xsltforms-support |
From: Tambet M. <tam...@gm...> - 2010-01-20 08:54:23
|
Micah Dubinko wrote: > Thanks Tambet, > > Looks like a good direction to pursue. > > In the case where the default selection (no element) gets saved and then the form is reopened, in other words when the instance is > <root/> > > How do you make it work (since the binding to /root/format goes nowhere)? > Good question. I don't have solution for that. In case of wsdl2xforms we submit the instance to web service and never retrieve it. Would xsi:nil attribute give you the same result? Something like this: <xf:instance> <root> <format xsi:nil="false">xml</format> </root> </xf:instance> <xf:bind nodeset="/root/format/@xsi:nil" calculate=".. = ''"/> If I'm correct, Chiba even sets xsi:nil automatically for you, if you happen to have that attribute. I understand, that this not exactly "missing element" feature that you needed, but maybe the target application handles the missing element and xsi:nil="true" element the same way? Tambet |
From: Klotz, L. <Lei...@xe...> - 2010-01-20 17:07:47
|
You can always add one on load: <insert ev:event="xforms-model-construct-done" if="not(/root/format)" nodeset="..." context="..." /> -----Original Message----- From: Micah Dubinko [mailto:Mic...@ma...] Sent: Wednesday, January 20, 2010 12:42 AM To: Tambet Matiisen Cc: xsl...@li... Subject: Re: [Xsltforms-support] Binding to optional element Thanks Tambet, Looks like a good direction to pursue. In the case where the default selection (no element) gets saved and then the form is reopened, in other words when the instance is <root/> How do you make it work (since the binding to /root/format goes nowhere)? -m On Jan 20, 2010, at 12:34 AM, Tambet Matiisen wrote: > This is the same solution I have used in wsdl2xforms, but I used > xforms-submit event instead. > > <xforms:instance id="temp"> > <temp> > <relevant xsi:type="boolean">true</relevant> > </temp> > </xforms:instance> > <xforms:submission ...> > <xforms:setvalue ref="instance('temp')/relevant" value="false()" > events:event="xforms-submit"/> > <xforms:setvalue ref="instance('temp')/relevant" value="true()" > events:event="xforms-submit-done"/> > <xforms:setvalue ref="instance('temp')/relevant" value="true()" > events:event="xforms-submit-error"/> > </xforms:submission> > <xforms:bind nodeset="/root/format" relevant="(. != '' or > boolean-from-string(instance('temp')/relevant))"/> > > Works well enough in Chiba. OK, name could be more descriptive :). > > Tambet > > Klotz, Leigh wrote: >> You might be able to use the relevance-with-submission-flag hack: >> >> <bind nodeset="/root/format" >> relevant="instance('state')/aboutToSubmit = 'false' or . != ''" /> >> <instance id="state"><data >> xmlns=""><aboutToSubmit>false</aboutToSubmit></instance> >> <submit submission="save"> >> <setvalue ev:event="DOMActivate" >> ref="instance('state')/aboutToSubmit">true</setvalue> >> </submit> >> <submission id="save"> >> <setvalue ev:event="xforms-submit-done" >> ref="instance('state')/aboutToSubmit">false</setvalue> >> <setvalue ev:event="xforms-submit-error" >> ref="instance('state')/aboutToSubmit">false</setvalue> >> </submit> >> >> -----Original Message----- >> From: Micah Dubinko [mailto:Mic...@ma...] >> Sent: Tuesday, January 19, 2010 11:58 AM >> To: xsl...@li... >> Subject: [Xsltforms-support] Binding to optional element >> >> Hey everyone, >> >> 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? >> >> Thanks! -m >> >> >> --------------------------------------------------------------------- >> --------- Throughout its 18-year history, RSA Conference consistently >> attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. >> http://p.sf.net/sfu/rsaconf-dev2dev >> _______________________________________________ >> Xsltforms-support mailing list >> Xsl...@li... >> https://lists.sourceforge.net/lists/listinfo/xsltforms-support >> >> --------------------------------------------------------------------- >> --------- Throughout its 18-year history, RSA Conference consistently >> attracts the world's best and brightest in the field, creating >> opportunities for Conference attendees to learn about information >> security's most important issues through interactions with peers, >> luminaries and emerging and established companies. >> http://p.sf.net/sfu/rsaconf-dev2dev >> _______________________________________________ >> Xsltforms-support mailing list >> Xsl...@li... >> https://lists.sourceforge.net/lists/listinfo/xsltforms-support >> > > > ---------------------------------------------------------------------- > -------- Throughout its 18-year history, RSA Conference consistently > attracts the world's best and brightest in the field, creating > opportunities for Conference attendees to learn about information > security's most important issues through interactions with peers, > luminaries and emerging and established companies. > http://p.sf.net/sfu/rsaconf-dev2dev > _______________________________________________ > Xsltforms-support mailing list > Xsl...@li... > https://lists.sourceforge.net/lists/listinfo/xsltforms-support ------------------------------------------------------------------------------ Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev _______________________________________________ Xsltforms-support mailing list Xsl...@li... https://lists.sourceforge.net/lists/listinfo/xsltforms-support |
From: Klotz, L. <Lei...@xe...> - 2010-01-19 21:34:53
|
Another option, though with UI ramifications. It uses a select1 for the named cases and a button for the default case. And the new insert/delete attributes in XForms 1.1. I've not tested this, but it's from http://www.w3.org/TR/xforms/#data-mutation-patterns <instance id="data"> <data xmlns=""><format>XML</format></data> </instance> <instance id="prototypes"> <data xmlns=""><format>XML</format></data> </instance> <group ref="/root/format"> <select1 ref="."> <label>Format: </label> <item><label>XML</label><value>xml</value></item> <item><label>Text</label><value>text</value></item> <item><label>Binary</label><value>binary</value></item> <item><label>Default</label><value /></item> <delete ev:event="xforms-value-changed" if=". = ''" nodeset="." /> </select1> </group> <trigger ref="/root[not(format)]"> <label>Set Format</label> <insert ev:event="DOMActivate" context="/root" nodeset="format" origin="instance('prototypes')/format" /> </trigger> -----Original Message----- From: Micah Dubinko [mailto:Mic...@ma...] Sent: Tuesday, January 19, 2010 11:58 AM To: xsl...@li... Subject: [Xsltforms-support] Binding to optional element Hey everyone, 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? Thanks! -m ------------------------------------------------------------------------------ Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev _______________________________________________ Xsltforms-support mailing list Xsl...@li... https://lists.sourceforge.net/lists/listinfo/xsltforms-support |