- From: Jeni Tennison <jeni@jenitennison.com>
- Date: Fri, 21 Dec 2001 15:09:53 +0000
- To: Jesse McCarthy <mccarthy36@earthlink.net>
- CC: xmlschema-dev@w3.org
Hi Jesse, >>By the way, this schema isn't valid because you can't specify a >>fixed or default value on an attribute whose type is or is derived >>from xs:ID (from Schema Component Constraint: Attribute Declaration >>Properties Correct, clause 3). I kept it like that simply because >>that was how you had it in your example. > > Thanks, I was not aware of that (and XSV didn't mention it). I could > achieve the desired effect using an enumeration with a single value > or a pattern consisting of the literal string, right? I don't see anything stopping you from doing that - it would have the same effect as a fixed value constraint, in terms of validation, though it wouldn't report the same PSVI. I think the reason that ID attributes aren't permitted value constraints is that it would easily lead to two elements having the same ID, which is of course illegal in XML. But I can see that there might be uses for it - if you wanted to make sure that you only ever had one element of that particular type in the document, for example. >>If you want to both *extend* a type (adding to the content model) >>and *restrict* a type (limiting attribute values), then you need to >>do it in two steps - one a restriction and one an extension. You can >>do it either way round, but since restrictions require you to >>specify the full content model, it's easiest to do it first (on the >>shorter content model): > > Why do I have to do it in two steps / can I do it at all? When you ask "Why?", what kind of response are you after? Do you want to have the constraints from the Rec quoted so that you can see why I say you have to use two steps, or do you want to know the reasons behind the way XML Schema is designed? > But doesn't clause 4 -- "4 Two distinct attribute declarations in > the {attribute uses} must not have identical {name}s and {target > namespace}s." -- of 3.4.6 Constraints on Complex Type Definition > Schema Components preclude doing that (even on the second of the two > steps you suggest)? When you restrict, the {attribute uses} of the derived type contains all the {attribute uses} from the definition of the derived type, plus any of the {attribute uses} from the definition of the base type that have not been overridden by {attribute uses} from the derived type. So you don't end up with duplicate attribute declarations because the attribute declaration of the id attribute in the base type is not added to the {attribute uses} of the derived type. Look at the way that the {attribute uses} property is defined in the XML Schema Rec, in Section 3.4.2 http://www.w3.org/TR/xmlschema-1/#declare-type. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/
Received on Friday, 21 December 2001 10:10:01 UTC