0
在XSD文件中,如何限制要包含在由其他元素定义的值中的元素的值? 换句话说,要声明某个值,它必须已经被其他元素实例化。XSD - 限制要包含在由其他元素定义的值中的元素的值
例如:
我有传感器列表,
<SensorDefinitionList>
<SensorDefinition>
<Name>ROLK8900</Name>
<DisplayName>TRM1</DisplayName>
<Presence>YES</Presence>
<SensorId>40</SensorId>
<Coordinates>0,0</Coordinates>
</SensorDefinition>
<SensorDefinition>
<Name>JBLK7200</Name>
<DisplayName>JBLK</DisplayName>
<Presence>YES</Presence>
<SensorId>35</SensorId>
<Coordinates>0,0</Coordinates>
</SensorDefinition>
...
</SensorDefinitionList>
和含有它们的分布,例如一个元件:
<SensorDistributionList>
<SensorDistribution>
<SensorDistributionId>0</SensorDistributionId>
<Name>System</Name>
<ListOfSensor>SDF</ListOfSensor>
</SensorDistribution>
<SensorDistribution>
<SensorDistributionId>3</SensorDistributionId>
<Name>MLAT</Name>
<ListOfSensor>MLAT</ListOfSensor>
</SensorDistribution>
...
</SensorDistributionList>
在XSD,我想向我所描述的SensorDistribution名称是之前在SensorDefinition中定义的传感器名称。 如何以这种方式编写我的XSD?
...
<xs:element name="SensorDistributionList">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="SensorDistribution">
<xs:complexType>
<xs:sequence>
<xs:element name="SensorDistributionId" type="xs:integer" />
<xs:element name="Name" type="xs:string" />
<xs:element name="ListOfSensor" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
...