XSD mandatory element

Discussion in 'XML' started by Chris West, Jun 27, 2003.

  1. Chris West

    Chris West Guest

    I have an schema that defines an element as mandatory, but I also want the
    XML instance to have some content for that mandatory element.

    I can use a regular expression to guarantee content, but I'm interested to
    know if there is another way to achieve this (an attribute setting perhaps)?

    Thanks

    Chris
     
    Chris West, Jun 27, 2003
    #1
    1. Advertising

  2. are you saying that the instance has to have some mandatory text content?

    if so look at a minLength restriction on the element type in the schema e.g.

    <xsd:simpleType name="PopulatedStringType">
    <xsd:restriction base="xsd:string">
    <xsd:minLength value="1"/>
    </xsd:restriction>
    </xsd:simpleType>

    but remember that an element using this type would allow <mandatory>
    </mandatory>
    you could further restrict the string with a pattern to say that the content
    must not be all white space

    Colin

    "Chris West" <> wrote in message
    news:bdgvf7$g6h$...
    > I have an schema that defines an element as mandatory, but I also want the
    > XML instance to have some content for that mandatory element.
    >
    > I can use a regular expression to guarantee content, but I'm interested to
    > know if there is another way to achieve this (an attribute setting

    perhaps)?
    >
    > Thanks
    >
    > Chris
    >
    >
    >
     
    Colin Mackenzie, Jun 27, 2003
    #2
    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,190
    Markus
    Nov 22, 2005
  2. Matthet
    Replies:
    2
    Views:
    711
    Matthet
    Sep 24, 2003
  3. Rick Razzano

    XSD document for XSD defintion

    Rick Razzano, Sep 26, 2003, in forum: XML
    Replies:
    1
    Views:
    534
    C. M. Sperberg-McQueen
    Sep 26, 2003
  4. Thomas Wittek
    Replies:
    4
    Views:
    1,580
    Joe Kesselman
    Sep 13, 2007
  5. PeteOlcott
    Replies:
    1
    Views:
    974
    Mukul Gandhi
    Feb 5, 2009
Loading...

Share This Page