2
votes

In XML Schema, one can use the "mixed" attribute on a <complexType> to allow it to contain text as well as child elements.

My question is whether there is any way to constrain what type of textual content is allowed, when using the "mixed" attribute. For instance, can I specify that the text must represent a floating-point number?

1

1 Answers

4
votes

No, you cannot place constraints on the mixed content's text nodes. You can constrain the elements of the mixed content as usual, but the actual mixed-in text is free from constraints.

I'm afraid W3C XML Schema's definition of mixed content is kind of slapped onto complex content in a not-too-thorough way. If Schema made a better abstraction of nodes with shared ground between text, elements, processing instructions and the like, like DOM does, it'd work better. But as it stands, I do believe you're out of luck.

Maybe someone with a tighter grasp on the actual XML Schema spec can confirm/deny this.