| re: XSD: How far should I go?
It depends on your application, so there is no easy answer.
I'm not sure the considerations are any different than for any other set of
data validations.
You seem to expect US phone numbers. Will you only need to record US phone
numbers? Your pattern will fail on international phone numbers.
I do not believe this will affect ADO.NET operations.
I do not know of a way to make enumeration values case insensitive.
--
Kathleen Dollard
Microsoft MVP
Author "Code Generation in Microsoft .NET"
"bullshark" <bullshark@scubadiving.com> wrote in message
news:7vr7005g6crio1gvvrj6cb7nqqh7bljk0v@4ax.com...[color=blue]
> I have a legacy data specification that I want to move into XML.
>
> My question revolves around specificity (in general) (c: Being a noob
> I don't know what the current wisdom is with respect to detailed
> specification in the XSD. Take a phone number for example. One could
> define a phone element with a simple specification like:
>
> <xs:element name = "phone" type=xs:string />
>
> Of course, one could declare a simple type and limit it to say 20 chars.
>
> At the extreme, one can composite several simple types:
>
> <xs:simpleType name="TelephoneNumberType">
> <xs:restriction base="xs:string">
> <xs:pattern value="([0-9]){0,2}\([0-9]{3}\)[0-9]{3}\-[0-9]{4}([/color]
Ext:[0-9]{4})?" />[color=blue]
> </xs:restriction>
> </xs:simpleType>
> <xs:simpleType name="PhoneKind">
> <xs:restriction base="xs:string">
> <xs:enumeration value="Cell" />
> <xs:enumeration value="Fax" />
> <xs:enumeration value="Home" />
> <xs:enumeration value="Office" />
> <xs:enumeration value="Other" />
> </xs:restriction>
> </xs:simpleType>
> <xs:complexType name="TelephoneType">
> <xs:sequence>
> <xs:element name="Number" type="xsl:TelephoneNumberType" />
> <xs:element name="Comment" type="xs:string" minOccurs="0"/>
> </xs:sequence>
> <xs:attribute name="kind" type="xsl:PhoneKind" default="Home"/>
> </xs:complexType>
>
> Beyond assuring conformance to a format, does the increased complexity add
> any other utility? i.e. will this make other XML tasks related harder or[/color]
easier?[color=blue]
> Is this helpful in DataSets, transforms and the like?
>
> I really have no feel for how expensive this kind of thing is.
>
> My understanding is that the choice depends mostly on the importance of
> the data. i.e. if format is mission critical then it's a no-brainer. A
> secondary consideration in my case is to have buckets to hold all the
> fields of the original format. That could be accomplished other ways, such
> as:
> < xs:element name="phone">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="CountryCode" type="xs:string"/>
> <xs:element name="AreaCode" type="xs:string"/>
> <xs:element name="Number" type="xs:string"/>
> <xs:element name="Ext" type="xs:string"/>
> ...
>
> This would give more navigational choices I guess, and again I could make
> more explicit simpletypes for the fields. But I don't really see the[/color]
utility[color=blue]
> in that unless navigation at that level is anticipated. It would make the
> XML considerably more verbose and
>
> I would appreciate any observations experience you might have to offer.
>
> Returning to the TelephoneType and the PhoneKind enumeration, I have a
> specific question(at last): "Can the validation of the enumeration be made
> case-insensitive?"
>
> regards,
>
> bullshark
>[/color] |