Hi,
I am new to OPS and XForms, currently I have what feels like a massive learning curve. One sticking point that I have is how to represent an XML schema choice in XForms. If somebody could point me in the right direction I would be very gratefull. An axample of what I mean can be seen in the following schema fragment: ... <complexType> <choice> <element name="argument"> <complexType> <sequence> <element name="name" type="string"></element> <element name="type" type="task:input-type"></element> <element name="tag" type="string" nillable="true"></element> <element name="position" type="short"></element> <element name="value" type="task:value"></element> </sequence> </complexType> </element> <element name="param"> <complexType> <sequence> <element name="name" type="string"></element> <element name="value" type="task:value"></element> </sequence> </complexType> </element> </choice> </complexType> ... Regards, Neal Johnston-Ward -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Indeed, that raises some issues, such as what your
instance will look like. It might be that you need to have two instances, one for each choice, and depending on a computed value or user selection, inputs become "relevant" or not. How would you or the user determine which choice to present? --Hank ----- Original Message ----- From: <[hidden email]> To: <[hidden email]> Sent: Thursday, June 08, 2006 1:48 PM Subject: [ops-users] How to deal with XML Schema choice elements in XForms > Hi, > > I am new to OPS and XForms, currently I have what feels like a massive learning curve. One sticking point that I have is how to > represent an XML schema choice in XForms. If somebody could point me in the right direction I would be very gratefull. > > An axample of what I mean can be seen in the following schema fragment: > > ... > <complexType> > <choice> > <element name="argument"> > <complexType> > <sequence> > <element name="name" type="string"></element> > <element name="type" type="task:input-type"></element> > <element name="tag" type="string" nillable="true"></element> > <element name="position" type="short"></element> > <element name="value" type="task:value"></element> > </sequence> > </complexType> > </element> > <element name="param"> > <complexType> > <sequence> > <element name="name" type="string"></element> > <element name="value" type="task:value"></element> > </sequence> > </complexType> > </element> > </choice> > </complexType> > ... > > Regards, > > Neal Johnston-Ward > > -------------------------------------------------------------------------------- > > -- > You receive this message as a subscriber of the [hidden email] mailing list. > To unsubscribe: mailto:[hidden email] > For general help: mailto:[hidden email]?subject=help > ObjectWeb mailing lists service home page: http://www.objectweb.org/wws > -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Administrator
|
In reply to this post by neal.johnstonward
Neal,
> One sticking point that I have is how to represent an XML schema > choice in XForms. If somebody could point me in the right direction > I would be very gratefull. So your instance could look like: <foo> <bar/> <argument> <!-- etc. --> </argument> </foo> or: <foo> <bar/> <param> <!-- etc. --> </param> </foo> If you already *have* such an XForms isntance, then handling the choice in the XForms controls is very easy: <xforms:group ref="argument"> <!-- Controls for the content of the argument element --> </xforms:group> <xforms:group ref="param"> <!-- Controls for the content of the argument element --> </xforms:group> If one of the groups points to a non-existing node, then that group simply won't display as it is considered non-relevant. Now if you want to *create* such an instance, it is again not that difficult. Create two files containing prototypes for the data you want to create: argument-template.xml: <argument> <!-- etc. --> </argument> param-template.xml: <param> <!-- etc. --> </param> Then refer to these files in your XForms model: <xforms:instance id="argument-template-instance" src="argument-template.xml"/> <xforms:instance id="param-template-instance" src="param-template.xml"/> Then at the time you want to actually insert either <argument> or <param> elements in your instance, execute the following actions: <xforms:insert nodeset="bar" at="1" position="after" origin="instance('argument-template-instance')"/> or: <xforms:insert nodeset="bar" at="1" position="after" origin="instance('param-template-instance')"/> Now exactly when you perform such insertion is up to you: you may have "Add Argument" and "Add Param" buttons (xforms:trigger), for example. I hope this helps. -Erik > An axample of what I mean can be seen in the following schema fragment: > > ... > <complexType> > <choice> > <element name="argument"> > <complexType> > <sequence> > <element name="name" type="string"></element> > <element name="type" type="task:input-type"></element> > <element name="tag" type="string" nillable="true"></element> > <element name="position" type="short"></element> > <element name="value" type="task:value"></element> > </sequence> > </complexType> > </element> > <element name="param"> > <complexType> > <sequence> > <element name="name" type="string"></element> > <element name="value" type="task:value"></element> > </sequence> > </complexType> > </element> > </choice> > </complexType> > ... > > Regards, > > Neal Johnston-Ward -- Orbeon - XForms Everywhere: http://www.orbeon.com/blog/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Free forum by Nabble | Edit this page |