tags:

views:

29

answers:

1

Hi

I want to mass create some users and I want to set the users timezone automatically. However I am using timezones generated by this

 Dictionary<string, TimeZoneInfo> storeZoneName = TimeZoneInfo.GetSystemTimeZones().ToDictionary(z => z.DisplayName);

So I need the names to be exactly like the ones this list returns. So can I put like a constraint on that xml node that the name has to exactly match one of the names.

So I am guessing I will need to write this list somewhere in the file and that's what I am not sure if you can do something like that in a schema.

A: 

If it is a predefined list of values you'll want to use XSD Enumerations.

See links below:

xml.com

w3c.org

mjmarsh
Cool what is the "id" for in XSD Enumerations? My timezone dictionary does have an "id" and a display name. Could I use the id field for the id of the timezone?
chobo2
Unfortunately I don't think it is possible to link enumerations for two elements or attributes. For example, if timezone 6 is 'US Central', I don't think you can force the XML to make sure that if the "timezone" element is 6 then the "Description" element must be "US Central". You would probably have to merge the two fields, e.g put them in one tag like "6 - US Central"
mjmarsh