Go Back   Velocity Reviews > Newsgroups > XML
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

XML - XSD mandatory element

 
Thread Tools Search this Thread
Old 06-27-2003, 09:24 AM   #1
Default 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





Chris West
  Reply With Quote
Old 06-27-2003, 09:50 AM   #2
Colin Mackenzie
 
Posts: n/a
Default 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: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
>
>
>



  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump