Florent Guillaume wrote:
Jim Fulton wrote:

But a schema is useful for more than "specifying the values of an object". All notions of schemas I've encountered (CPS Schemas, XML Schemas, Archetypes) use the schema to constrain or validate an existing object, yes, but also to create new objects from scratch (even in the absence of widgets). Being able to specify initial values is quite important there.


It's not clear to me that XML schemas specify this.  I'm quite skeptical
than they do.  (They have this mysterious "initial value" thing that
I can't make any sense of.)  I can't believe that XML schemas deal
with the history of a document, which would seem necessary to give
inital value, as we mean it, any meaning.


http://www.w3.org/TR/xmlschema-0/#OccurrenceConstraints (2.2.1) says:

  Default values of both attributes and elements are declared using the
  'default' attribute, although this attribute has a slightly different
  consequence in each case. When an attribute is declared with a default
  value, the value of the attribute is whatever value appears as the
  attribute's value in an instance document; if the attribute does not
  appear in the instance document, the schema processor provides the
  attribute with a value equal to that of the 'default' attribute. Note
  that default values for attributes only make sense if the attributes
  themselves are optional, and so it is an error to specify both a
  default value and anything other than a value of 'optional' for 'use'.

An "instance document" is comparable to our object, it is what is being validated/filled by the processor.

This is *not* what default/initial-value is in zope schema.  The XML
"default" concept is closest to missing_value in zope schema.

The default attribute of current zope schema fields are defined
(by the README.txt in zope.schema) as:

  "Default field values are assigned to objects when they are first
   created."

Interestingly, we don't really use them that way.  There may
be cases where __init__ honors these specifications.  If there
are, I doubt they are common.  In practice, we use this information to
initialize forms.  That is, we use these as UI hints.  I think this
is a valid use case, but I think it is better served by information
in form fields.

Jim

--
Jim Fulton           mailto:[EMAIL PROTECTED]       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org
_______________________________________________
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to