XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] Required Field validation strategies

Hi Jason

Is there a problem with just saying     minOccurs="0"   for the
elements you want to be optional? Perhaps we need to see the
schema as it stands. Maybe there is another reason for the
problems of sequence when an element is omitted. There seems
to be a consensus that elements without content are to be
avoided so just making them optional in most cases is all that
is usually required. So making everything minOccurs='0' unless
there is a good reason to make it minOccurs='1' (the default so
it is sufficient to leave out minOccurs and it automatically is
assumed to be 1). You could prevent empty elements being valid
by making minLength=1 but that may be overkill. It might not
always be feasible to remove empty elements in an xml file (e.g.
it is tricky when using XForms to make the xml file).

Dates are best always being optional, I think, for the reasons
you give (unless the xml without a particular date has to be invalid):
you can't really make a date datatype element empty except by
some rule in addition to the schema which says that say 1900-01-01
is to be regarded as null - not very sensible really. So a date
element without content needs to be left out of the xml and so
that element should probably be optional (minOccurs='0')

All the best

Stephen Green

On 20/03/07, J Siatkowski <jason.siatkowski@gmail.com> wrote:
> My thanks to both Stephen and Michael. I tinkered with the file and I
> was able to get it successfully validated with just the xmlns
> declaration. That makes me a lot happier.
>
> The other issue, which I didn't discuss earlier because it might have
> been moot based on the first issue, is my handling of null fields. My
> schema does indeed have custom data types, i.e. string0to14, etc. It
> also has some enumeration types. The schema also enforces required
> fields, although I have been sorely tempted to remove this from the
> schema because I have not been able to successfully validate a file
> with nulls without adding xs:nil = "true" to the elements which I want
> to be null. Only a small amount of the fields are required, and
> therefore the size of the uploaded file could be a lot smaller if the
> customer wasn't required to include the tags for elements which have
> no value. In my tests, if I omitted the tag, the schema validation
> failed because the tags were out of order. I also tried specifying a
> default value for each field in the schema if it was null, but that
> did not work well at all for date fields. A problem which I learned
> was quite common from what I've read since then.
>
> I would like to still use the schema so I can continue to read the
> file into the dataset, but I think it would be useful to allow the
> customer to supply only the tags that actually have values while still
> performing required field validation.
>
> Is this an all or nothing situation? It seems my choices are to allow
> the schema to validate required fields and therefore require the
> customer to provide all tags even if the data is null, or I can remove
> required fields from the schema and just perform my validation in code
> after the schema validation is performed.
>
> Again, thanks for any advice,
> --Jason
>
> _______________________________________________________________________
>
> XML-DEV is a publicly archived, unmoderated list hosted by OASIS
> to support XML implementation and development. To minimize
> spam in the archives, you must subscribe before posting.
>
> [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
> Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
> subscribe: xml-dev-subscribe@lists.xml.org
> List archive: http://lists.xml.org/archives/xml-dev/
> List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
>
>


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS