I have an XML schema where certain tags must have an id attribute. I can get this working just fine using use="required"
<xs:element name="SiteDiscoveryReleaseReportReceived">
<xs:complexType>
<xs:all>
<xs:element name="ReceivedDate" type="xs:date" nillable="true" />
<xs:element name="StaffLead" type="xs:int" nillable="true" />
<xs:element name="Status" nillable="true">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="id" type="xs:int" use="required" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
I also want to make the tag nillable, but the XSD above will not allow me to do <Status xs:nil="true"/> because the id attribute is missing. How can I make the id attribute required if the tag is not nil? Or is not having an id attribute on nil tags going to cause logical problems with xpath queries?
If it matters, this is for an XML column in SQL Server.