Jump to content


  • Posts

  • Joined

  • Last visited

About evanc

  • Birthday 06/06/1964

Profile Information

  • Location
    Seattle, WA

evanc's Achievements


Newbie (1/7)



  1. I certainly hope you have found the answer to this someplace else considering the age of this post... The work around I have been using for this sort of issue is this: <xs:complexType name="PhoneNumbers_type"> <xs:choice minOccurs="0" maxOccurs="2"> <xs:element name="work" type="xs:string" /> <xs:element name="cell" type="xs:string" /> </xs:choice></xs:complexType>
  2. I have seen a couple other posts similar to this, but not quite the sameā€¦ I am trying to create Schemas to validate my product's object model. I am finding many instances where attributes associated with elements depend upon the content of the element. For example: <busy nil="true"></busy> or <busy type="boolean">true</busy> are valid values. I have been using my own type with a union and optional attributes to validate this element like so: <?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="busy"> <xs:complexType> <xs:simpleContent> <xs:extension base="nilBoolean"> <xs:attribute name="type" use="optional" type="xs:NCName"/> <xs:attribute name="nil" use="optional" type="xs:boolean"/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> <xs:simpleType name="nilBoolean"> <xs:union memberTypes="xs:boolean empty"/> </xs:simpleType> <xs:simpleType name="empty"> <xs:restriction base="xs:string"> <xs:maxLength value="0"/> </xs:restriction> </xs:simpleType></xs:schema> But what I would really like is to have more explicit control to say that the 'nil' attribute is required if the value is empty, and the 'type' attribute is required if the value is not empty. It sounds simple enough, but I haven't determined how. Can anyone point me on the correct path? Thanks,Evan
  • Create New...