0
votes

I want to define a complex type via XSD that

  • can contain inner text
  • can contain inner elements
  • text and elements can be freely mixed without order constraints
  • elements can appear zero or multiple times

That's what the body element of XHTML allows. E.g:

<body> 
    Hello <b>World</b>, nice <span>to</span> <b>meet</b> you<b>!!!</b>
</body>

Looking at the element composition constraints like sequence, all or choice that doesn't seem to be possible with XSD.

But on the other hand, XHTML, as a valid XML language, should be describable by an XSD schema.

So any ideas how I could describe such complex types? Thank you in advance...

1
If you need to have XHTML elements defined in your schema, please look at this question: stackoverflow.com/questions/17012597/…ColdFusion
Thank you for your answer... maybe I did not stated this exactly but I'm not interested in an (partial) XHTML inclusion. I rather refered to the body-element just as a comparison. What I want to define is a complex type fulfilling the requirements stated in my questionmbue
Well, this is not so difficult to describe in an XSD, you just need to write a number of definitions for that, because those elements like <span> or <b> may contain lots of other elements (including themselves) as well as text. This is done typically using element groups: <xs:group>. Just look how they do it for XHTML. Here's the full schema for it: w3.org/2002/08/xhtml/xhtml1-strict.xsd . If it is difficult to read, you can use some freely available XML schema documentation generator.ColdFusion

1 Answers

1
votes

It's not clear why you believe this is impossible in XSD, so I can't help you understand.

Define your complex type with mixed content; make its outermost group an xs:choice element with minOccurs="0" and maxOccurs="unbounded"; within that choice list the elements which should be allowed as children.