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