我对以下架构有问题我想将 job 元素的 jobGroup 属性与 jobGroup 元素的name属性“匹配” ,但我无法通过验证来验证此成本约束
这是我的架构和应该失败的示例
<?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace="http://www.example.org/example"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://www.example.org/example"
elementFormDefault="qualified" >
<xs:element name="cluster" type="tns:clusterType">
<xs:keyref name="jobGroupKeyRef" refer="tns:jobGroupKey">
<xs:selector xpath=".//job"></xs:selector>
<xs:field xpath="@jobGroup"></xs:field>
</xs:keyref>
<xs:key name="jobGroupKey">
<xs:selector xpath=".//jobGroup"></xs:selector>
<xs:field xpath="@name"></xs:field>
</xs:key>
</xs:element>
<xs:complexType name="jobType">
<xs:attribute name="id"
type="xs:positiveInteger"
use="required"/>
<xs:attribute name="submissionTime"
type="xs:dateTime"
use="required"/>
<xs:attribute name="jobGroup"
type="xs:string"
default="default"/>
</xs:complexType>
<xs:complexType name="jobGroupType">
<xs:attribute name="name"
type="xs:string"
use="required"/>
<xs:attribute name="description"
type="xs:string"
default=""/>
</xs:complexType>
<xs:complexType name="clusterType">
<xs:choice minOccurs="1" maxOccurs="unbounded">
<xs:element name="job"
type="tns:jobType"
minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="jobGroup"
type="tns:jobGroupType"
minOccurs="0"
maxOccurs="unbounded"/>
</xs:choice>
<xs:attribute name="name"
type="xs:string"
use="required"/>
</xs:complexType>
</xs:schema>
<cluster xmlns="http://www.example.org/example"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://www.example.org/example XSDFile.xsd"
name="CLUSTER1" >
<job submittedHost="HOST1"
id="1"
submissionTime="2009-03-31T17:40:35.000+02:00"
jobGroup="default"></job>
<job submittedHost="HOST2"
id="2"
submissionTime="2009-03-31T17:40:35.000+02:00"
jobGroup="wrongName"></job>
<jobGroup name="default"
description="Job Group number 1"></jobGroup>
</cluster>