While writing a schema for the xml documents my simulation model accepts as input, I came across a tricky situation. How to define an element that has an attribute, but which also has plain text content between it’s tags (rather than more elements or nothing).
Since I knew very little about schemas a couple of days ago, I found that all tutorials and examples completely missed this combination which I’m sure must be more common than made out.
Here is my solution:
<xsd:attribute name="name" type="xsd:string"/>
Attributes go within the extension tag, and you need simpleContent rather than complexContent. It makes load of sense, so I’m not complaining about the design. It was just very hard to find somewhere that explained it.