Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml XSD-限制一个元素的值包含在其他元素定义的值中_Xml_Xsd - Fatal编程技术网

Xml XSD-限制一个元素的值包含在其他元素定义的值中

Xml XSD-限制一个元素的值包含在其他元素定义的值中,xml,xsd,Xml,Xsd,在XSD文件中,如何限制一个元素的值包含在其他元素定义的值中? 换句话说,要声明某个值,它必须已经被其他元素实例化 例如: 我有一份传感器清单 <SensorDefinitionList> <SensorDefinition> <Name>ROLK8900</Name> <DisplayName>TRM1</DisplayName> <Presence>YES</Presence

在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>

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>

...
...
更多: 更多: