On 7 Jan, 19:36, "stevecanfi...@yahoo.com" <stevecanfi...@yahoo.com>
wrote:
On Jan 7, 3:08 am, Martin Honnen <mahotr...@yahoo.dewrote:
stevecanfi...@yahoo.com wrote:
I have xml that has nodes that either have a text value or more nested
elements. For example, both of these are valid for my <valuenode:
* * <value>1234</value>
and
* * <value><object>foo</object></value>
Any clues on how I could express this in the schema (xsd)? I've
figured out how to do one or the other, but not allow either. It seems
like it should be verysimple, but I'm stuck... Please help!
I think you need to allow mixed contents theN which would not only allow
<value>1234</valuebut as well <value><object>foo</object>1234</value>:
<URL:http://www.w3.org/TR/xmlschema-0/#mixedContent>
I ended up doing just that, but I'm not entirely happy with the
result. It seems to me that specifying mixed content allows *any* text
content. I'd like to limit it to just digits.
-sc
Alas, with XSD, using the mixed content is the best you can do. It
would be nice if XSD had something like xs:text similar to what Relax-
NG has so you could do:
<xs:complexType ...>
<xs:choce>
<xs:text type='xs:int'/>
<xs:element name='object' type='xs:string'/>
</xs:choice>
</xs:complexType>
Unfortunately it's not even on the radar for the next version of XSD.
HTH,
Pete Cordell
Codalogic
Visit
http://www.codalogic.com/lmx/ for XML C++ data binding