1
我想用我的xml模式完成的任务是为每个questionPool提出唯一的问题 - 并非针对所有questionPools。在我的XML文件,我有这样的代码,注释说什么我想要做的:XML Schema如何使每个元素的子元素都是唯一的?
<questionPools>
<questionPool>
<question idref="question1"/>
<question idref="question2"/>
</questionPool>
<questionPool>
<question idref="question3"/>
<question idref="question1"/> <!-- Duplicate but not in question pool so allowed -->
<question idref="question3"/> <!-- Not allowed because duplicate in question pool -->
</questionPool>
</questionPools>
我都试过,但它会检查所有问题而不是具体的人到一个池:
<xsd:key name="keyQuestionPool">
<xsd:selector xpath="questionPools/questionPool/question"/>
<xsd:field xpath="@idref"/>
</xsd:key>
非常感谢! – nefarel 2011-05-28 14:21:29