Thanks for the info. I tried it and wam it worked.
Now is there a way to say that if one element has a value that another
element should have one also. if you look at the phone number elements
there are 3 parts. what i need to do now is say if i have one of the 3
it is required to have all 3? possible or just crazy talk from an xml
wanna be:).
Bruce Wood - 08 Dec 2004 17:39 GMT
I know of no way to specify dependencies like that between independent
elements in XML. However, if you can make the phone number a
sub-element with its own structure, you can specify that all parts must
be there and that the whole phone number element is optional:
<xs:element ... >
<xs:complexType>
<xs:sequence>
<xs:element name="phoneNumber" type="phoneNumberType"
minOccurs="0" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="phoneNumber">
<xs:complexType>
<xs:attribute name="areaCode" type="areaCodeType"
use="required" />
<xs:attribute name="exchangeCode" type="exchangeCodeType"
use="requried" />
<xs:attribute name="number" type="phoneNumberNumberType"
use="required" />
</xs:complexType>
</xs:element
This pattern misses 0's (so a number like 10 won't pass it). Also, it
doesn't allow for negative numbers. The follwoing pattern will work better:
<xs:element name="Account_Id" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[+-]?[0-9]*"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
However, these values are still strings (they just look like integers) and
as such they allow values like 00009. You can further modify the pattern to
remove leading zeros (but still allow 0 value):
<xs:element name="Account_Id" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[+-]?([1-9][0-9]*|0"/>
</xs:restriction>
</xs:simpleType>
</xs:element>

Signature
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
> You need to change the definition of account_id to be constraint by a
> pattern:
[quoted text clipped - 84 lines]
>> }
>> xsd.Close();
Stan Kitsis [MSFT] - 08 Dec 2004 23:09 GMT
Sorry, missed the ( ). Here's what the declarations should look like:
<xs:element name="Account_Id" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="([+-]?[0-9]*)?"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
and
<xs:element name="Account_Id" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="([+-]?([1-9][0-9]*|0)?"/>
</xs:restriction>
</xs:simpleType>
</xs:element>

Signature
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
> This pattern misses 0's (so a number like 10 won't pass it). Also, it
> doesn't allow for negative numbers. The follwoing pattern will work
[quoted text clipped - 108 lines]
>>> }
>>> xsd.Close();