XML : Validate unique attribute value, only when not empty

I have following XML element Example 1 -> Valid

  <Tracking Enabled="true" Implemented="true">                  <Track Name="" Type="Tracker1" />                  <Track Name="" Type="Tracker2" />                  <Track Name="" Type="Tracker3" />  </Tracing>    

Is it possible through XML Schema to check if the value of Name attribute is unique, only when the value is not empty. I have tried xs:Unique but it validates when string is not empty.

Example 2 -> Valid

  <Tracking Enabled="true" Implemented="true">          <Track Name="Name1" Type="Tracker1" />          <Track Name="" Type="Tracker2" />          <Track Name="Name3" Type="Tracker3" />  </Tracing>    

Example 3 -> Invalid

  <Tracking Enabled="true" Implemented="true">                  <Track Name="Name1" Type="Tracker1" />                  <Track Name="" Type="Tracker2" />                  <Track Name="Name1" Type="Tracker3" />  </Tracing>    

Example 4 -> Invalid

  <Tracking Enabled="true" Implemented="true">              <Track Name="Name1" Type="Tracker1" />              <Track Name="Name2" Type="Tracker2" />              <Track Name="Name2" Type="Tracker3" />  </Tracing>    

No comments:

Post a Comment