Giorgio
Giorgio

Reputation: 2200

Complex restricting logic in XSD file

I'm triyng to create a schema definition and I have to describe the following scenario:

...
<DeviceParamUpdate>
   <Update>
      <ProcessorName>NPT Length</ProcessorName>
      <ParamName>UseFilter</ParamName>
      <ParamValue>False</ParamValue>
      <ParamType>System.Boolean</ParamType>
   </Update>
</DeviceParamUpdate>
<DeviceParamUpdate>
   <Update>
      <ProcessorName>NPT Width</ProcessorName>
      <ParamName>UseFilter</ParamName>
      <ParamValue>False</ParamValue>
      <ParamType>System.Boolean</ParamType>
   </Update>
</DeviceParamUpdate>
<DeviceParamUpdate>
   <Update>
      <ProcessorName>Finder Width</ProcessorName>
      <ParamName>CMinX</ParamName>
      <ParamValue>-500</ParamValue>
      <ParamType>System.Int32</ParamType>
   </Update>
</DeviceParamUpdate>
<DeviceParamUpdate>
   <Update>
      <ProcessorName>Finder Width</ProcessorName>
      <ParamName>CMaxX</ParamName>
      <ParamValue>1500</ParamValue>
      <ParamType>System.Int32</ParamType>
   </Update>
</DeviceParamUpdate>
<DeviceParamUpdate>
   <Update>
      <ProcessorName>B Width</ProcessorName>
      <ParamName>MinX</ParamName>
      <ParamValue>-1675</ParamValue>
      <ParamType>System.Int32</ParamType>
   </Update>
</DeviceParamUpdate>
...

where

and

Is there any way to force this type of validations in the XSD file? Thanks in Advance...

Upvotes: 1

Views: 104

Answers (1)

kjhughes
kjhughes

Reputation: 111491

If you're using XML Schema 1.0, you cannot express such constraints in the schema, but you could use Schematron or you could check it at the application level.

If you're using XML Schema 1.1, you can specify co-occurrence constraints via XPath 2.0 using xs:assert.

Upvotes: 1

Related Questions