[xsd-users] Complex type with mixed content
Barrie Kovish
barrie.kovish at singularsoftware.com
Sun Aug 15 13:55:31 EDT 2010
I've run into a case where complex mixed content is causing us some problems. I'm hoping there might be a somewhat simpler solution than having to implement a type by hand. In our case the complex mixed type is always either a simple string or a complex type but never mixed. It is however declared in the schema as complex, mixed. Here is an example of what I am talking about. The following would be 2 examples of valid XML:
Here is an example of the simple case:
<sample>
2000
</sample>
Here is an example of a complex case:
<sample>
<freq>
20
</freq>
<phase>
2.17
</phase>
</sample>
The XSD definition looks like:
<xs:element name='sample'>
<xs:complexType mixed='true'>
<xs:choice minOccurs='0' maxOccurs='unbounded'>
<xs:element ref='freq'/>
<xs:element ref='phase'/>
</xs:choice>
</xs:complexType>
</xs:element>
Also we don't actually use any of the content of the <sample> element. However we do need to preserve it between reading in the XML file modifying the XML and then writing it out.
Is there a simpler solution than implementing a custom type by had?
Thanks,
Barrie Kovish
More information about the xsd-users
mailing list