The issue is that I am using XS:all because the elements can be in any order. I can not put a maxoccurs on a referenced element:
<xs:element name="PersonInfo">
<xs:complexType>
<xs:all>
<xs:element name="Addr" type="AdressType" minOccurs="0" maxOccurs="unbounded" />
</xs:all>
<xs:attribute name="id" type="xs:ID" use="optional" />
<xs:attribute name="Test" type="xs:string" use="optional" />
</xs:complexType>
</xs:element>
<xs:complexType name="AdressType">
<xs:all>
<xs:element name="BuildingAptNumber" type="xs:string" minOccurs="0" />
<xs:element name="Addr1" type="xs:string" minOccurs="0" />
<xs:element name="City" type="xs:string" minOccurs="0" />
<xs:element name="StateProvCd" type="xs:string" minOccurs="0" />
<xs:element name="PostalCode" type="xs:string" minOccurs="0" />
</xs:all>
<xs:attribute name="AddrTypeCd" type="xs:string" use="optional" />
</xs:complexType>
If the element was not referenced i would be able to get away with using a ComplexType. Is there any way to reference the element and have a maxoccurs under xs:all ?
EDIT: The only way I see to add maxoccurs is to use a complextype and define xs:choice inside of the complex type:
<xs:element name="Test" minOccurs="0">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Addr" type="PMICADDRESS"/>
</xs:choice>
</xs:complexType>
</xs:element>
So the issue is that I don't know how to declare complex type of the addr element. The one solution I found is to change to xsd 1.1. I have not been able to update to XSD 1.1. yet. I found a thread that is helping out: Middle way between XSD all and XSD sequence