xmlxsdseparatorxmllist

Is there a way to define XSD for an element-separated list


I would like to define a schema for the following XML construct:

<object>System<S/>Design<S/>Part</object>

Where element "object" should be filled with a list of content as enumeration values (System, Design, Part), which potentially may contain spaces - that's why I cannot go with space-separated list. As a separator I use element.

But all the xsd elements that can parent simple content won't parent elements and vice verso. Is there any way to work around it?


Solution

  • The answer is no -- unless you move to XSD 1.1 and use assertions.

    In XSD 1.0 there is no way of constraining the text that appears in the text nodes of a mixed-content element. This is because you aren't using XML the way it was designed to be used (you will also have problems with XPath/XSLT on this kind of structure).

    In XSD 1.1 you could have an assertion on the declaration of "object" such as

    test="every $s in text() satisfies $s = ('System', 'Design', 'Part')