Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In XML Schema, can mixed content restrict the type of the text?

Tags:

xml

xsd

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?

like image 916
PeteAC Avatar asked Sep 05 '25 03:09

PeteAC


1 Answers

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.

like image 54
G_H Avatar answered Sep 07 '25 20:09

G_H