Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: XML schema for ordinal/nominal variables

From: "Christian Setzkorn" <christian@--------.-->
To: <noah_mendelsohn@--.---.--->
Date: 9/5/2006 6:35:00 PM
Dear Noah,

Many thanks for this. It is exactly what I want. I would like to store =
the
code ('1') but also keep track of what the code means ('male'). 

I am using ASP.NET/C#. Hence, I could later replace the 'coding' with =
the
'meaning' if the user prefers this.

Thanks again,

Chris  

PS: I didn't really understand why you use <bob></bob> instead of
<gender></gender> ... later I would like to use this simple type in =
complex
types with complex content model.

> -----Original Message-----
> From: xmlschema-dev-request@w... =
[mailto:xmlschema-dev-request@w...]
> On Behalf Of noah_mendelsohn@u...
> Sent: 04 September 2006 20:49
> To: Christian Setzkorn
> Cc: xmlschema-dev@w...
> Subject: Re: XML schema for ordinal/nominal variables
> 
> 
> I think the first question is, what do you want your XML instances to =
look
> like.  The example type you've given:
> 
> <xs:element name = "gender" >
>                  <xs:simpleType>
>                                  <xs:restriction base = "xs:string" =
>
>                                                  <xs:pattern value "0
> female | 1 male" />
>                                  </xs:restriction>
>                  </xs:simpleType>
> </xs:element>
> 
> will validate elements like:
> 
> <bob>1 male<bob>
> <mary>0 female</mary>
> 
> in which both the ordinal code and its mapped value appear in the =
instance
> (though I think you're missing some quotes on the strings in the =
pattern,
> I  believe your intent is clear.
> 
> Keep in mind that the main purpose of XML Schema is typically to =
describe
> what your documents will look like.  Schema does have a place to put =
other
> useful information associated with a declaration called <xsd:appinfo>.
> Perhaps what you want is an enumeration with appinfos, an example of =
which
> is in the specification itself at [1].  Adapting that to your example:
> 
> <simpleType name='gender'>
>     <annotation>
>         <documentation>Used to distinguish boys from =
girls</documentation>
>     </annotation>
>     <restriction base='integer'>
>       <enumeration value='0'>
>         <annotation>
>             <documentation>Female</documentation>
>         </annotation>
>       </enumeration>
>       <enumeration value='1'>
>         <annotation>
>             <documentation>Male</documentation>
>         </annotation>
>       </enumeration>
>     </restriction>
> </simpleType>
> 
> Now the instances you'll validate will look like:
> 
> <bob>1</bob>
> <mary>0</mary>
> 
> which I suspect is what you want.  Certain schema validators will make =
it
> easy for you to use their APIs to navigate to the appinfos at runtime,
> should you wish to have your programs automatically discover the
> associations between the enumeration values and their interpretations =
as
> genders.  I hope this helps.  Note, however, that enumerations work on
> what schemas call 'values', so
> 
> <bob>0001</bob>
> 
> will also be accepted if the base type is integer.  If you prefer you =
can
> make the basetype string, in which case only the exact character =
string
> you put into the enumeration will match, I.e. '0' or '1' respectively.
> 
> I hope this is helpful.
> 
> Noah
> 
> [1] http://www.w3.org/TR/2004/PER-xmlschema-2-20040318/#rf-enumeration
> 
> --------------------------------------
> Noah Mendelsohn
> IBM Corporation
> One Rogers Street
> Cambridge, MA 02142
> 1-617-693-4036
> --------------------------------------
> 
> 
> 
> 
> 
> 
> 
> 
> "Christian Setzkorn" <christian@s...>
> Sent by: xmlschema-dev-request@w...
> 09/04/2006 06:54 AM
> 
>         To:     <xmlschema-dev@w...>
>         cc:     (bcc: Noah Mendelsohn/Cambridge/IBM)
>         Subject:        XML schema for ordinal/nominal variables
> 
> 
> 
> Dear all,
> 
> I would like to define nominal/ordinal variables as XML schema. Both =
types
> of variables are characterized by code/string pairs. Here code is a =
real
> number.
> 
> Example of the nominal variable Gender:
> 
> code/string
> #######
> 1/male
> 0/female
> 
> Example of the ordinal variable Agreement:
> 
> code/string
> #######
> 0/strongly disagree
> 1/disagree
> 2/agree
> 3/strongly agree
> 
> My first attempt to define 'Gender' is this:
> 
> <xs:element name = "gender" >
>                  <xs:simpleType>
>                                  <xs:restriction base = "xs:string" =
>
>                                                  <xs:pattern value "0
> female | 1 male" />
>                                  </xs:restriction>
>                  </xs:simpleType>
> </xs:element>
> 
> Could this be improved?
> 
> Any feedback would be very much appreciated. Many thanks in advance.
> 
> Best wishes,
> 
> Christian Setzkorn
> 
> 
> 
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.1.405 / Virus Database: 268.11.7/436 - Release Date: =
01/09/2006
> 
> 
> 
> 
> 
> 
> 
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.394 / Virus Database: 268.11.7/436 - Release Date: =
01/09/2006
> 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.11.7/436 - Release Date: =
01/09/2006
 


From noah_mendelsohn@u... Tue Sep 05 19:41:09 2006
Received: from maggie.w3.org ([193.51.208.68])
	by frink.w3.org with esmtp (Exim 4.50)
	id 1GKgnF-0003z6-2K
	for xmlschema-dev@l...; Tue, 05 Sep 2006 19:41:09 +0000
Received: 


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent