XSD mandatory element

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris West

    #1

    XSD mandatory element

    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

    #2
    Re: XSD mandatory element

    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:simpleTy pe name="Populated StringType">
    <xsd:restrictio n base="xsd:strin g">
    <xsd:minLengt h 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" <chrisw@memex.c om> wrote in message
    news:bdgvf7$g6h $1@mxgate.memex .co.uk...[color=blue]
    > 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[/color]
    perhaps)?[color=blue]
    >
    > Thanks
    >
    > Chris
    >
    >
    >[/color]


    Comment

    Working...