Schema+XForms: display enumerations as select1?

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

Schema+XForms: display enumerations as select1?

Philipp Wagner-3
Hello,

I use XForms together with XML Schema to create my form. In my schema, I
have an element with the following type:

  <xsd:simpleType name="enumerationValue">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="n/a"/>
      <xsd:enumeration value="+"/>
      <xsd:enumeration value="(+)"/>
      <xsd:enumeration value="-"/>
      <xsd:enumeration value="++"/>
    </xsd:restriction>
  </xsd:simpleType>

The resulting form element should look like a regular dropdown list
(label = value).
Is it possible to have a <xf:input> element, bind it to the element with
the enumerationValue data type (as defined above) and it renders as a
dropdown list instead of an input box? From what I read in the XForms
spec, this is up to the implementation [1].
Mozilla XForms displays a regular input box at the moment. Are there
plans to extend it to display a dropdown box instead? Or are there
reasons not to do so? Of course, it will not be possible to define a
label and a value separately, but this is not always necessary (as in my
case).

Philipp

[1] http://www.w3.org/TR/xforms/#ui-input
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

RE: Schema+XForms: display enumerations as select1?

Klotz, Leigh
If you need to get it done now, try this.
Someone else might come up with something clever with XBL and
JavaScript.
Leigh.
 
<?xml version="1.0"?>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://www.w3.org/1999/xhtml"
      xmlns:ev="http://www.w3.org/2001/xml-events"
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:xf="http://www.w3.org/2002/xforms"
      xmlns:t="urn:test">
  <head>
    <title>test</title>
    <model xmlns="http://www.w3.org/2002/xforms">
      <instance>
        <data xmlns="">
          <value>+</value>
        </data>
      </instance>
      <instance id="testSchema" src="testSchema.xml" />
      <bind nodeset="a" type="t:enumerationValue" />
    </model>
    <style type="text/css">
      @namespace xf url('http://www.w3.org/2002/xforms');
    </style>
  </head>
  <body>
    <h1>test</h1>
    <group xmlns="http://www.w3.org/2002/xforms">
      <select1 ref="value">
        <label>Value: </label>
        <itemset
nodeset="instance('testSchema')/xs:simpleType[@name='enumerationValue']/
xs:restriction/xs:enumeration">
          <label ref="@value" />
          <value ref="@value" />
        </itemset>
      </select1>
    </group>
  </body>
</html>
------------

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           targetNamespace="urn:test"
           xmlns="urn:test"
           elementFormDefault="qualified">

  <xs:simpleType name="enumerationValue">
    <xs:restriction base="xs:string">
      <xs:enumeration value="n/a"/>
      <xs:enumeration value="+"/>
      <xs:enumeration value="(+)"/>
      <xs:enumeration value="-"/>
      <xs:enumeration value="++"/>
    </xs:restriction>
  </xs:simpleType>
</xs:schema>


-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Philipp
Wagner
Sent: Wednesday, November 07, 2007 7:23 AM
To: [hidden email]
Subject: Schema+XForms: display enumerations as select1?

Hello,

I use XForms together with XML Schema to create my form. In my schema, I
have an element with the following type:

  <xsd:simpleType name="enumerationValue">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="n/a"/>
      <xsd:enumeration value="+"/>
      <xsd:enumeration value="(+)"/>
      <xsd:enumeration value="-"/>
      <xsd:enumeration value="++"/>
    </xsd:restriction>
  </xsd:simpleType>

The resulting form element should look like a regular dropdown list
(label = value).
Is it possible to have a <xf:input> element, bind it to the element with
the enumerationValue data type (as defined above) and it renders as a
dropdown list instead of an input box? From what I read in the XForms
spec, this is up to the implementation [1].
Mozilla XForms displays a regular input box at the moment. Are there
plans to extend it to display a dropdown box instead? Or are there
reasons not to do so? Of course, it will not be possible to define a
label and a value separately, but this is not always necessary (as in my
case).

Philipp

[1] http://www.w3.org/TR/xforms/#ui-input
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Schema+XForms: display enumerations as select1?

Dan McCreary
In reply to this post by Philipp Wagner-3
Leigh's solution is a great start!

I believe this type of problem comes up all the time.  The challenge
is that XML Schema is not designed to capture user interface labels
AND group-vetted semantics of the enumerations which are frequently
very different than values stored in the actual XML instance
documents.  Enumerations also change much more frequently then most
other data types.

I believe the most strategic way of solving this in the long-term is
to build a simple metadata registry: a collection of XML files that
store a superset of what is needed for both building forms AND
validating data streams.  The registry elements are transformed into
both the XML Schema types and provide a service that can be used to
populate selection list and suggest fields in the forms. The ISO/IEC
11179 spec has a starting point for this.  (see the wikipedia page for
more on this topic).  You can also see an example of this here:

http://en.wikibooks.org/wiki/XForms/Selecting_from_File

I have created several metadata-registries in the past and I now have
some basic XForms UI front ends for it.  I hope to put them in the
open-source on google-code by the Spring.  I will be at the XML
conference in Boston Dec to talk about this.

http://2007.xmlconference.org/public/schedule/detail/425

Please let me know if anyone else in interested in an open-source
XForms-based metadata registry project.

- Dan


_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms