XForms issues with complex schema model

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

XForms issues with complex schema model

Pascal Heus
I have a quite challenging schema that I'm trying to to xforms and am
not sure how to handle the insert/delete of elements in the form. A
fragment of one of the schema module is shown below, How would you
create an XForm for it?

    <xs:complexType name="IdentificationType">
                <xs:sequence>
                    <xs:element name="ID" type="xs:NCName">
                    <xs:element name="IdentifyingAgency"
type="xs:NCName" minOccurs="0">
                    <xs:element name="Version" type="xs:string"
minOccurs="0">
                    <xs:element name="VersionResponsibility"
type="xs:NCName" minOccurs="0">
                    <xs:element name="Affiliation" type="xs:NCName"
minOccurs="0">
                    <xs:element name="VersionReason"
type="InternationalStringType" minOccurs="0" maxOccurs="unbounded">
                </xs:sequence>
    </xs:complexType>

The problem is that only the first element is mandatory. The other  four
can be added at the user discretion. This means that I start with a
nodeset with only one element and any of the next four can be
inserted/deleted at will. I would like a UI that shows an insert button
when the element is absent and a delete button when it is present. I was
hoping the addition of the xforms:insert "context" and "origin"
attributes would help me address this but I don't see how to specify the
position of an element taking. Since this is a sequence, the order must
be preserved. Since most of them are NCName, they can't be empty or the
schema validation would fail.

This is just one of the many issues I'm facing. I would love to find an
OPS/forms based solution to build editors for our XML specs but XForms
1.1 may not yet be ready to handle complex cases. For example, in the
case below, I should be able to say that I want to insert "Version"
after "ID" or "IdentifyingAgency" but also before "VersionResposibiliy"
or before "Affiliation" etc.. A "smart" XForms implementation should
actually be able to figure this out based on the schema (a schema aware
XForms?).. I should say inert "Version" in "IdentificationType" and the
element should fall into the right place.

I may of course be completely wrong and missing something... An option
would be to have a relaxed version of the schema that does not strongly
enforce type and sequences and then  transform to the real one for
validation that takes away the purpose of having a schema in the first
place (and would be a lot of work...). In all cases, any suggestion
would be appreciated.

thanks
*P





--
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
Reply | Threaded
Open this post in threaded view
|

AW: XForms issues with complex schema model

joerg.moebius
Hi Pascal,
Concerning your issue transformation with
http://xsdtrans/sourceforge.net might give you an idea.

The 'Address'-Element of the following schema has nearly the structure
of your complexType.

<?xml version="1.0"?>
<xs:schema targetNamespace="http://oesoft.de/type"
        xmlns:Q1="http://oesoft.de/type"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        elementFormDefault="qualified"
attributeFormDefault="unqualified"
        version="1.0">
        <xs:element name="Address">
                <xs:complexType>
                        <xs:sequence>
                                <xs:element name="Id" type="xs:integer"
default="111" />
                                <xs:element name="Prename"
type="xs:string"
                                        default="Hans" minOccurs="0"
maxOccurs="unbounded" />
                                <xs:element name="Lastname"
type="xs:string"
                                        default="Hansen" minOccurs="0"
/>
                        </xs:sequence>
                </xs:complexType>
        </xs:element>
        <xs:element name="Addresses">
                <xs:complexType>
                        <xs:sequence>
                                <xs:element ref="Q1:Address"
maxOccurs="unbounded" />
                        </xs:sequence>
                </xs:complexType>
        </xs:element>
</xs:schema>

When you transform this element with http://xsdtrans/sourceforge.net you
get the following xforms-form:


.
.
        <body>
                <xforms:group id="AddressUI" appearance="full">
                        <xforms:label
id="AddressLabel">Address</xforms:label>
                        <xforms:alert id="AddressAlert">
                                Input is obligative.
                        </xforms:alert>
                        <xforms:input id="IdUI" bind="B00200">
                                <xforms:label
id="IdLabel">Id</xforms:label>
                                <xforms:alert id="IdAlert">
                                        Input is obligative.
                                </xforms:alert>
                        </xforms:input>
                        <xforms:group id="PrenameGroupUI"
appearance="full">
                                <xforms:trigger id="PrenameTrigger">
                                        <xforms:label
id="PrenameTriggerLabel">
                                                Insert after selected
                                        </xforms:label>
                                        <xforms:action
id="PrenameTriggerAction">
                                                <xforms:insert
id="PrenameTriggerInsert"
       
at="xforms:index('PrenameRepeatUI')" bind="B00300"
                                                        position="after"
/>
                                        </xforms:action>
                                </xforms:trigger>
                                <xforms:repeat id="PrenameRepeatUI"
appearance="compact"
                                        bind="B00300">
                                        <xforms:input id="PrenameUI"
bind="B00300">
                                                <xforms:label
id="PrenameLabel">
                                                        Prename
                                                </xforms:label>
                                                <xforms:alert
id="PrenameAlert" />
                                        </xforms:input>
                                </xforms:repeat>
                                <xforms:label
id="PrenameLabel">Prename</xforms:label>
                                <xforms:alert id="PrenameAlert" />
                        </xforms:group>
                        <xforms:input id="LastnameUI" bind="B00400">
                                <xforms:label
id="LastnameLabel">Lastname</xforms:label>
                                <xforms:alert id="LastnameAlert" />
                        </xforms:input>
                </xforms:group>
                <xforms:trigger>
                        <xforms:label
id="debug-trigger">debug</xforms:label>
                        <xforms:send id="debug-action"
submission="debug" />
                </xforms:trigger>
        </body>
.
.

Rendering this site for example with chiba, you get

1. a required input for the 'Id'-element
2. a repeat input with the appropriate triggers for the
'Prename'-element (for instance only the insert-trigger)
3. an omittable input for the 'Name'-element

With this site you can achieve a data instance like:

<vchr:Address xmlns:vchr="http://oesoft.de/type"
        xmlns="http://www.w3.org/1999/xhtml"
        xmlns:chiba="http://chiba.sourceforge.net/xforms"
        xmlns:ev="http://www.w3.org/2001/xml-events"
        xmlns:xforms="http://www.w3.org/2002/xforms"
        xmlns:xlink="http://www.w3.org/1999/xlink"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <vchr:Id>111</vchr:Id>
        <vchr:Prename>Hans</vchr:Prename>
        <vchr:Lastname/>
        <vchr:Prename>Hans</vchr:Prename>
</vchr:Address>


Regards Joerg


-----Ursprüngliche Nachricht-----
Von: Pascal Heus [mailto:[hidden email]]
Gesendet: Sonntag, 24. September 2006 04:56
An: [hidden email]
Betreff: [ops-users] XForms issues with complex schema model

I have a quite challenging schema that I'm trying to to xforms and am
not sure how to handle the insert/delete of elements in the form. A
fragment of one of the schema module is shown below, How would you
create an XForm for it?

    <xs:complexType name="IdentificationType">
                <xs:sequence>
                    <xs:element name="ID" type="xs:NCName">
                    <xs:element name="IdentifyingAgency"
type="xs:NCName" minOccurs="0">
                    <xs:element name="Version" type="xs:string"
minOccurs="0">
                    <xs:element name="VersionResponsibility"
type="xs:NCName" minOccurs="0">
                    <xs:element name="Affiliation" type="xs:NCName"
minOccurs="0">
                    <xs:element name="VersionReason"
type="InternationalStringType" minOccurs="0" maxOccurs="unbounded">
                </xs:sequence>
    </xs:complexType>

The problem is that only the first element is mandatory. The other  four
can be added at the user discretion. This means that I start with a
nodeset with only one element and any of the next four can be
inserted/deleted at will. I would like a UI that shows an insert button
when the element is absent and a delete button when it is present. I was
hoping the addition of the xforms:insert "context" and "origin"
attributes would help me address this but I don't see how to specify the
position of an element taking. Since this is a sequence, the order must
be preserved. Since most of them are NCName, they can't be empty or the
schema validation would fail.

This is just one of the many issues I'm facing. I would love to find an
OPS/forms based solution to build editors for our XML specs but XForms
1.1 may not yet be ready to handle complex cases. For example, in the
case below, I should be able to say that I want to insert "Version"
after "ID" or "IdentifyingAgency" but also before "VersionResposibiliy"
or before "Affiliation" etc.. A "smart" XForms implementation should
actually be able to figure this out based on the schema (a schema aware
XForms?).. I should say inert "Version" in "IdentificationType" and the
element should fall into the right place.

I may of course be completely wrong and missing something... An option
would be to have a relaxed version of the schema that does not strongly
enforce type and sequences and then  transform to the real one for
validation that takes away the purpose of having a schema in the first
place (and would be a lot of work...). In all cases, any suggestion
would be appreciated.

thanks
*P







--
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
Reply | Threaded
Open this post in threaded view
|

Re: XForms issues with complex schema model

Erik Bruchez
Administrator
In reply to this post by Pascal Heus
Pascal,

 > I have a quite challenging schema that I'm trying to to xforms and am
 > not sure how to handle the insert/delete of elements in the form. A
 > fragment of one of the schema module is shown below, How would you
 > create an XForm for it?
 >
 >     <xs:complexType name="IdentificationType">
 >                 <xs:sequence>
 >                     <xs:element name="ID" type="xs:NCName">
 >                     <xs:element name="IdentifyingAgency"
 > type="xs:NCName" minOccurs="0">
 >                     <xs:element name="Version" type="xs:string"
 > minOccurs="0">
 >                     <xs:element name="VersionResponsibility"
 > type="xs:NCName" minOccurs="0">
 >                     <xs:element name="Affiliation" type="xs:NCName"
 > minOccurs="0">
 >                     <xs:element name="VersionReason"
 > type="InternationalStringType" minOccurs="0" maxOccurs="unbounded">
 >                 </xs:sequence>
 >     </xs:complexType>
 >
 > The problem is that only the first element is mandatory. The other  four
 > can be added at the user discretion. This means that I start with a
 > nodeset with only one element and any of the next four can be
 > inserted/deleted at will. I would like a UI that shows an insert button
 > when the element is absent and a delete button when it is present. I was
 > hoping the addition of the xforms:insert "context" and "origin"
 > attributes would help me address this but I don't see how to specify the
 > position of an element taking. Since this is a sequence, the order must
 > be preserved. Since most of them are NCName, they can't be empty or the
 > schema validation would fail.

 > This is just one of the many issues I'm facing. I would love to find an
 > OPS/forms based solution to build editors for our XML specs but XForms
 > 1.1 may not yet be ready to handle complex cases. For example, in the
 > case below, I should be able to say that I want to insert "Version"
 > after "ID" or "IdentifyingAgency" but also before "VersionResposibiliy"
 > or before "Affiliation" etc.. A "smart" XForms implementation should
 > actually be able to figure this out based on the schema (a schema aware
 > XForms?).. I should say inert "Version" in "IdentificationType" and the
 > element should fall into the right place.
 >
 > I may of course be completely wrong and missing something... An option
 > would be to have a relaxed version of the schema that does not strongly
 > enforce type and sequences and then  transform to the real one for
 > validation that takes away the purpose of having a schema in the first
 > place (and would be a lot of work...). In all cases, any suggestion
 > would be appreciated.

With XForsm 1.1's improved xforms:insert, you can insert pretty much
anything anywhere.

Of course, this is not automatic. XForms has no Schema-awareness
except with regards to validation. There is no automatic mechanism in
XForms that will build a user interface with the appropriate controls
that ensure that the resulting document matches a particular
schema. But you can build something like this manually, or build a
tool that generates such a user interface in XForms.

But back to an actual answer to the low-level insertion question. You
could insert "VersionResponsibility" with something like:

<xforms:insert nodeset="ID | IdentifyingAgency | Version"
                position="after"
 
origin="instance('identification-type-template')/VersionResponsibility"/>

And then:

<xforms:instance id="identification-type-template">
   <IdentifyingAgency/>
   <Version/>
   <VersionResponsibility/>
   <Affiliation/>
   <VersionReason/>
</xforms:instance>

In addition you also have to control the display of insert/delete
triggers depending on the current state of your XForms instance.

-Erik

--
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
Reply | Threaded
Open this post in threaded view
|

Re: XForms issues with complex schema model

Pascal Heus
Erik:
Excellent, your xforms:insert suggestion is very elegant (better than what I came up with...)
Here is how I solved the insert/delete button-link. Might be useful to others as it does not require any bind and is relative to the current nodeset.
The slightly tricky part was for the insert.to show up if the r:Version is not present. This of course only applies for non-repeatable elements. The delete just need to appear when the element exists.
This latest xforms:insert is major improvement and solves issues I have been struggling with all summer, can't thank you enough for implement it :-)
many thanks
*P
                    <!--  insert r:Version -->
                    <xforms:group ref=".[not(r:Version)]">
                        <xforms:trigger appearance="xxforms:image">
                            <xxforms:img src="/images/add.gif"/>
                            <xforms:label>Add</xforms:label>
                        </xforms:trigger>
                        <xforms:trigger appearance="xxforms:link">
                            <xforms:label>Version</xforms:label>
                        </xforms:trigger>
                        <xforms:action ev:event="DOMActivate">
                            <xforms:insert context="." nodeset="r:ID | r:IdentifyingAgency" origin="instance('r:Version-template')" position="after"/>
                        </xforms:action>
                    </xforms:group>
                    <!--  delete  -->
                    <xforms:group ref="r:Version">
                        <xforms:trigger appearance="xxforms:image">
                            <xxforms:img src="/images/remove.gif"/>
                            <xforms:label>Remove</xforms:label>
                        </xforms:trigger>
                        <xforms:trigger appearance="xxforms:link">
                            <xforms:label>Version</xforms:label>
                        </xforms:trigger>
                        <xforms:action ev:event="DOMActivate">
                            <xforms:delete nodeset="." />
                        </xforms:action>
                    </xforms:group>




Erik Bruchez wrote:
Pascal,

> I have a quite challenging schema that I'm trying to to xforms and am
> not sure how to handle the insert/delete of elements in the form. A
> fragment of one of the schema module is shown below, How would you
> create an XForm for it?
>
>     <xs:complexType name="IdentificationType">
>                 <xs:sequence>
>                     <xs:element name="ID" type="xs:NCName">
>                     <xs:element name="IdentifyingAgency"
> type="xs:NCName" minOccurs="0">
>                     <xs:element name="Version" type="xs:string"
> minOccurs="0">
>                     <xs:element name="VersionResponsibility"
> type="xs:NCName" minOccurs="0">
>                     <xs:element name="Affiliation" type="xs:NCName"
> minOccurs="0">
>                     <xs:element name="VersionReason"
> type="InternationalStringType" minOccurs="0" maxOccurs="unbounded">
>                 </xs:sequence>
>     </xs:complexType>
>
> The problem is that only the first element is mandatory. The other  four
> can be added at the user discretion. This means that I start with a
> nodeset with only one element and any of the next four can be
> inserted/deleted at will. I would like a UI that shows an insert button
> when the element is absent and a delete button when it is present. I was
> hoping the addition of the xforms:insert "context" and "origin"
> attributes would help me address this but I don't see how to specify the
> position of an element taking. Since this is a sequence, the order must
> be preserved. Since most of them are NCName, they can't be empty or the
> schema validation would fail.

> This is just one of the many issues I'm facing. I would love to find an
> OPS/forms based solution to build editors for our XML specs but XForms
> 1.1 may not yet be ready to handle complex cases. For example, in the
> case below, I should be able to say that I want to insert "Version"
> after "ID" or "IdentifyingAgency" but also before "VersionResposibiliy"
> or before "Affiliation" etc.. A "smart" XForms implementation should
> actually be able to figure this out based on the schema (a schema aware
> XForms?).. I should say inert "Version" in "IdentificationType" and the
> element should fall into the right place.
>
> I may of course be completely wrong and missing something... An option
> would be to have a relaxed version of the schema that does not strongly
> enforce type and sequences and then  transform to the real one for
> validation that takes away the purpose of having a schema in the first
> place (and would be a lot of work...). In all cases, any suggestion
> would be appreciated.

With XForsm 1.1's improved xforms:insert, you can insert pretty much
anything anywhere.

Of course, this is not automatic. XForms has no Schema-awareness
except with regards to validation. There is no automatic mechanism in
XForms that will build a user interface with the appropriate controls
that ensure that the resulting document matches a particular
schema. But you can build something like this manually, or build a
tool that generates such a user interface in XForms.

But back to an actual answer to the low-level insertion question. You
could insert "VersionResponsibility" with something like:

<xforms:insert nodeset="ID | IdentifyingAgency | Version"
               position="after"

origin="instance('identification-type-template')/VersionResponsibility"/>

And then:

<xforms:instance id="identification-type-template">
  <IdentifyingAgency/>
  <Version/>
  <VersionResponsibility/>
  <Affiliation/>
  <VersionReason/>
</xforms:instance>

In addition you also have to control the display of insert/delete
triggers depending on the current state of your XForms instance.

-Erik


-- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: [hidden email] For general help: [hidden email] 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