Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Required element check

Status
Not open for further replies.

ShubhaMishra

Programmer
Jan 4, 2007
10
IN
Hi,
I know this is a basic query but I am not able to solve that and also not able to find the answer for this question.
Actually I want a required check for a element.
For example:

<xs:element name="Client" type="xs:string" minOccurs="1"/>

I am using micOccurs but this is not checking that the value of tag is null.If value is "<Client></Client>" its working properly. I also tried nilable ="false", but that is also not working.Can anybody tell me an what can be done.
Note: use="required" can be used with attribute not with element :(

Thanks in advance.

Shubhangi
 
[1] minLength
[tt]
<xs:element name="Client" minOccurs="1" maxOccurs="unbounded">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1" />
</xs:restriction>
</xs:simpleType>
</xs:element>
[/tt]
[2] minLength may be a too rigid condition in some cases where pure ignorable spaces may not be allowed, a regex pattern may be considered. One way to put the pattern may be this, replacing the <xs:minLength ... />. (There could be lots of equally valid variations.)
[tt]
<xs:element name="Client" minOccurs="1" maxOccurs="unbounded">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value=""(\s*\w+\s*)+" />
</xs:restriction>
</xs:simpleType>
</xs:element>
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top