xml schema to specify element type based on attribute value?

Discussion in 'XML' started by James, Jul 18, 2007.

  1. James

    James Guest

    Hello,

    I'm trying to create a schema for the following document..

    <Foo>
    <Content type="html">
    ... valid xhtml goes here ...
    </Content>
    <Content type="plain">
    ... xs:string value goes here ...
    </Content>
    </Foo>

    So, basically I need to specify that the type of the Content element
    will be a complex type with a sequence of xs:any when the value of the
    type attribute on that element is "html" or it's an simple type of
    xs:string when the value of the type attribute is "plain"..

    Is this possible with xsd?

    Thanks,

    -jr
    James, Jul 18, 2007
    #1
    1. Advertising

  2. James wrote:
    > Is this possible with xsd?


    Better solution with XSD is <html-content> versus <plain-content>.


    --
    Joe Kesselman / Beware the fury of a patient man. -- John Dryden
    Joseph Kesselman, Jul 18, 2007
    #2
    1. Advertising

  3. >> Is this possible with xsd?
    > Better solution with XSD is <html-content> versus <plain-content>.


    Should have added: You could also do things with instance-document type
    directives (http://www.w3.org/TR/xmlschema11-1/#xsi_type). But I've
    rarely seen that used well...

    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
    Joe Kesselman, Jul 28, 2007
    #3
    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. Markus
    Replies:
    1
    Views:
    1,528
    Markus
    Nov 23, 2005
  2. ian mayo
    Replies:
    2
    Views:
    415
    ian mayo
    Aug 11, 2003
  3. Richard G.
    Replies:
    1
    Views:
    493
    Bart Van der Donck
    Jun 27, 2004
  4. tankbattle
    Replies:
    1
    Views:
    799
    George Bina
    Jul 21, 2006
  5. Replies:
    2
    Views:
    7,197
Loading...

Share This Page