XSD mandatory element

C

Chris West

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
 
C

Colin Mackenzie

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top