- From: Pete Cordell <petexmldev@codalogic.com>
- Date: Fri, 23 Mar 2012 12:34:28 -0000
- To: "Michael Kay" <mike@saxonica.com>, <xmlschema-dev@w3.org>
Original Message From: "Michael Kay" >> I think a mandatory attribute with a default is telling an XML creator >> that if they don't have a specific value for this field then they should >> set it to the default value. > Except that the XSD spec doesn't have any way of saying that that's what > it's saying, because it doesn't define semantics for this use case; the > only semantics defined for the schema is its effect on validation / PSVI > creation. That means that if XSD allowed this, it would have to say "this > is allowed but has no recognized meaning". Do you mean that XSD only specifies semantics for parsing XML documents, not actually generating them? It may be the OO programming background of the customers I work with, but most of them seem to expect (or want) 'default' to mean, "If I don't explicitly set the value, then use the default value when generating the XML." Potentially the end-to-end effect of a optional attribute filled with the default value at the receiving end is the same as a mandatory attribute filled with the default value at the originating end, but it can aid debugging and clarity if the default value is made explicit in the transferred XML. > ... > > It's hard to get this right consistently. In many cases I think the right > approach when users do something pointless is a warning (which is of > course outside the scope of the spec). But should we, for example, allow > you to specify minInclusive for an xs:QName, given that it will have no > effect? I think not. And specifying a default for a mandatory attribute > seems to me to fall into the same category. I agree a minInclusive for an xs:QName is nonsensical. However, I think setting a default for a mandatory value is at worst redundant, and can be useful in a number of situations. Pete Cordell Codalogic Ltd Interface XML to C++ the easy way using C++ XML data binding to convert XSD schemas to C++ classes. Visit http://codalogic.com/lmx/ or http://www.xml2cpp.com for more info
Received on Friday, 23 March 2012 12:33:06 UTC