views:

491

answers:

1

Hello,

I have this XML pattern...

<module>
   <promo>
      <day>1</day>
      <day>2</day>
   </promo>
   <promo>
      <day>3</day>
      <day>4</day>
   </promo>
   <promo>
      <day>Default</day>
   </promo>
</module>

I would like to stop users putting the same value into 2 <day> tags anywhere in the <module> tag.

I can currently do it using the <xsd:unique> tag, but this doesn't allow me to have two <day> tags in one <promo> tag.

I could also use the attribute base="xs:ID" but this doesn't allow the value to start with a number.

Any help is much appreciated.

Regards, Tom.

+4  A: 

Here is the answer to my question. Setting a xs:unique tag to this...

<xsd:unique name="day">
 <xs:selector xpath="promo/day" />
 <xs:field xpath="." />
</xsd:unique>

In the element declaration for the 'module' tag gives me the functionality I need.

Regards, Tom.

Crazy... I've tried *exactly the same thing* (and some variants of it) for half an hour now, using MSXML. MSXML did not give me an error even though it was clearly not meeting this requirement. What have you been using? Can you try with MSXML?
Tomalak