simple and complex unions?

Discussion in 'XML' started by stevecanfield@yahoo.com, Jan 7, 2008.

  1. Guest

    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 <value> node:

    <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 very simple, but I'm stuck... Please help!

    -sc
     
    , Jan 7, 2008
    #1
    1. Advertising

  2. 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 <value> node:
    >
    > <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 very simple, but I'm stuck... Please help!


    I think you need to allow mixed contents theN which would not only allow
    <value>1234</value> but as well <value><object>foo</object>1234</value>:
    <URL:http://www.w3.org/TR/xmlschema-0/#mixedContent>

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Jan 7, 2008
    #2
    1. Advertising

  3. Guest

    On Jan 7, 3:08 am, Martin Honnen <> wrote:
    > 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 <value> node:

    >
    > > <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</value> but 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
     
    , Jan 7, 2008
    #3
  4. Guest

    On 7 Jan, 19:36, "" <>
    wrote:
    > On Jan 7, 3:08 am, Martin Honnen <> wrote:
    >
    > > 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 <value> node:

    >
    > > >     <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</value> but 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
     
    , Jan 8, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. news.amnet.net.au
    Replies:
    1
    Views:
    604
    =?UTF-8?b?TMSByrtpZSBUZWNoaWU=?=
    Apr 13, 2004
  2. Stanimir Stamenkov
    Replies:
    2
    Views:
    794
    Stanimir Stamenkov
    Oct 25, 2005
  3. Udo Steinberg
    Replies:
    3
    Views:
    592
    Udo Steinberg
    May 15, 2004
  4. Robert Mark Bram
    Replies:
    0
    Views:
    718
    Robert Mark Bram
    Feb 4, 2007
  5. Kottiyath

    How complex is complex?

    Kottiyath, Mar 18, 2009, in forum: Python
    Replies:
    22
    Views:
    801
Loading...

Share This Page