Reputation: 2200
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
ProcessorName
=NPT Length
then ParamName
=UseFilter
, ParamType
=System.Boolean
and ParamValue
type boolean;ProcessorName
=NPT Width
then ParamName
=UseFilter
, ParamType
=System.Boolean
and ParamValue
type xs:boolean
;ProcessorName
=Finder Width
and ParamName
=CMinX
then ParamType
=System.Int32
and ParamValue
type xs:integer
;ProcessorName
=Finder Width
and ParamName
=CMaxX
then ParamType
=System.Int32
and ParamValue
type xs:integer
;ProcessorName
=B Width
then ParamName
=MinX
, ParamType
=System.Int32
and ParamValue
type xs:integer
;and
DeviceParamUpdate
with ProcessorName
=NPT Length
is present then must be present that with ProcessorName
=NPT Width
DeviceParamUpdate
with ProcessorName
=Finder Width
must both be present or none.Is there any way to force this type of validations in the XSD file? Thanks in Advance...
Upvotes: 1
Views: 104
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