Xml XSD-限制一个元素的值包含在其他元素定义的值中
在XSD文件中,如何限制一个元素的值包含在其他元素定义的值中? 换句话说,要声明某个值,它必须已经被其他元素实例化 例如: 我有一份传感器清单Xml XSD-限制一个元素的值包含在其他元素定义的值中,xml,xsd,Xml,Xsd,在XSD文件中,如何限制一个元素的值包含在其他元素定义的值中? 换句话说,要声明某个值,它必须已经被其他元素实例化 例如: 我有一份传感器清单 <SensorDefinitionList> <SensorDefinition> <Name>ROLK8900</Name> <DisplayName>TRM1</DisplayName> <Presence>YES</Presence
<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>
ROLK8900
TRM1
对
40
0,0
JBLK7200
JBLK
对
35
0,0
...
以及包含其分布的元素,例如:
<SensorDistributionList>
<SensorDistribution>
<SensorDistributionId>0</SensorDistributionId>
<Name>System</Name>
<ListOfSensor>SDF</ListOfSensor>
</SensorDistribution>
<SensorDistribution>
<SensorDistributionId>3</SensorDistributionId>
<Name>MLAT</Name>
<ListOfSensor>MLAT</ListOfSensor>
</SensorDistribution>
...
</SensorDistributionList>
0
系统
自卫队
3.
MLAT
MLAT
...
在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>
...
。。。
...
您可以将SensorDefinition
的名称定义为xs:ID
,并在SensorDistribution
中使用它
<xs:element maxOccurs="unbounded" name="SensorDefinition">
<xs:complexType>
<xs:sequence>
...
<xs:element name="Name" type="xs:ID" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element maxOccurs="unbounded" name="SensorDistribution">
<xs:complexType>
<xs:sequence>
...
<xs:element name="Name" type="xs:IDREF" />
</xs:sequence>
</xs:complexType>
</xs:element>
...
...
更多:
更多: