Reputation: 544
Hello I want to be able to define something like this:
<Infos>
<Mileage>9987
<UseIn>POS_DISPLAY</UseIn>
<UseIn>READER_DISPLAY</UseIn>
</Mileage>
</Infos>
Mileage
is mixed type. 9987
is its value, and UseIn
are some properties.
The problem is that I can't find a way to define restriction for Mileage
content.
Is there any way to define the structure above, without falling back to:
<Infos>
<Mileage>
<MileageValue>9987</MileageValue>
<UseIn>POS_DISPLAY</UseIn>
<UseIn>READER_DISPLAY</UseIn>
</Mileage>
</Infos>
Upvotes: 0
Views: 54
Reputation: 25034
For historical reasons I won't bother to describe, XSD types with mixed content allow character data to appear at any location. It's easy to define a type that allows the structure you show, but it's not so easy to define a type that allows what you show while rejecting variants like
<Mileage>
<UseIn>POS_DISPLAY</UseIn>
9987
<UseIn>READER_DISPLAY</UseIn>
</Mileage>
or
<Mileage>99
<UseIn>POS_DISPLAY</UseIn>
8
<UseIn>READER_DISPLAY</UseIn>
7
</Mileage>
My advice, fwiw, is to fall back to the second design, which will work better with most XML infrastructure.
Upvotes: 3