开发者

How to specify read only text or label in an XML data schema

I am referring to XML data schema as detailed here: http://www.w3schools.com/schema/default.asp.

When I retrieve data from the database and submit it to the client, there are text fields which I wish to retain as uneditable display/read only fields.

For example, hypothetically i开发者_如何转开发n the following sequence,

<xsd:element ....
<xsd:element name="employeeName" xsd:type="xsd:string"/>
<xsd:element name="projID" xsd:type="xsd:string" readOnly='true'>
<xsd:element name="hireDate" type="xsd:date"/>
<xsd:element ....
<xsd:element name="today" type="xsd:date" readOnly='true'/>
<xsd:element ....

Where the client display would interpret the xsd stream and construct the input form. Of course, the label is faux schema tag to illustrate my need of placing a read-only field in the midst of the form.

In the above example, projID and today should be presented to the user as read-only fields, but there is no such schema syntax as readOnly.

One way I know how to achieve this is to break the stream into two complex type segments and so split it into two input forms and get the client to present an intervening label in between the two forms.

However, that is problematic because

  1. I have quite a few read-only info fields that need to be presented thro the ui. There would be too many interruptions to a smooth single form. It's best to have just one input form.
  2. Some read-only fields are presented in the middle of an entity sequence. That means interrupting the database-to-jdo(or jpa)-to-client data flow for that entity.

Therefore, how to specify a read-only field element in an xml schema?

... and (sheepishly) may I ask, how to specify a hidden field?


You may use XML Schema annotations to provide such information for your application. It's awkward, but it could work. Something along the lines of:

<xs:element name="heading" type="xs:string">
    <xs:annotation>
        <xs:appinfo>
            <readOnly>true</readOnly>
        </xs:appinfo>
    </xs:annotation>
 </xs:element>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜