Apr 30, 2005
81
0
66
Hi,

Can someone show me how to define an XSD type that matches the following XML:

<!-- List is restricted to 3 integer elements -->
<tag some_attribute="xyz">1 10 100</tag>

I can define it fine without the attribute or if I move the list into an attribute, but the above syntax has me stumped.

Cheers.

 

MrChad

Lifer
Aug 22, 2001
13,507
3
81
<xs:element name="tag" type="xs:string">
...<xs:attribute name="some_attribute" type="xs:string"/>
</xs:element>

You won't be able to restrict the contents of <tag> to a list, though. A better bet would be to define three child integer elements rather than a tokenized string.
 
Apr 30, 2005
81
0
66
Hi,
At this point it is purely academic; I'm just curious if it can be done ( xsd:list is convenient for validating the element count and for use with scripting languages that can split() a string into an array ).

Cheers.
 

MrChad

Lifer
Aug 22, 2001
13,507
3
81
Hmm, I stand corrected. I was unaware of xs:list.

This is close, but it doesn't add the 3 element restriction.