all groups > dotnet xml > august 2003 >
You're in the

dotnet xml

group:

schemas and empty elements


schemas and empty elements chris NO[at]SPAM yahoo.com
8/29/2003 11:37:23 AM
dotnet xml:
Hi,

Another silly question - by default if I define a specific element as a
string (xsd:string) in a schema, if I validate a document against that
schema and the element is empty, should it, or should it not pass through
successfully??

Basically, I know there is an <empty> tag to put in the schema if you
require a field to be empty, but if you want it to be either containing a
string or be empty, will it pass through validation if you do nothing but
declare the element as as string??

Cheers

Chris

Re: schemas and empty elements chris NO[at]SPAM yahoo.com
8/29/2003 1:12:49 PM
Thanks, that's what I thought.

Cheers

Chris

[quoted text, click to view]

Re: schemas and empty elements Oleg Tkachenko
8/29/2003 2:31:42 PM
[quoted text, click to view]

Should pass. Empty string is still valid xsd:string value. You can
constrain value to be at least 1 character lenght by restricting
xsd:string type:
<xs:element name="d">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel
AddThis Social Bookmark Button