How can I have sub-elements of a complex/mixed type with unrestricted order and count?

Posted by mbmcavoy on Stack Overflow See other posts from Stack Overflow or by mbmcavoy
Published on 2010-05-05T22:41:52Z Indexed on 2010/05/05 22:48 UTC
Read the original article Hit count: 255

Filed under:
|
|

I am working with XML where some elements will contain text with additional markup. This is similar to this example at W3Schools. However, I need the markup tags to be able to appear in any order and possibly more than once.

To modify their example for illustration:

<letter>
  Dear Mr.<name>John Smith</name>.
  Your order <orderid>1032</orderid>
  will be shipped on <shipdate>2001-07-13</shipdate>.
  Thank you, <name>Bob Adams</name>
</letter>

None of the options presented by W3Schools (on the page following the linked example) allow this XML due to the second <name> element. Their explanation of the "indicators" and my testing are consistent.

<xs:sequence> - violates the element order

<xs:choice> - more than one kind of element is used.

<xs:all> - maxOccurs is restricted to "1".

This seems like it should be basic, after all, XHTML allows such things. How do I define my schema to allow this?

© Stack Overflow or respective owner

Related posts about Xml

Related posts about xsd