- From: Jeni Tennison <jeni@jenitennison.com>
- Date: Sat, 22 Dec 2001 08:38:03 +0000
- To: Jesse McCarthy <mccarthy36@earthlink.net>
- CC: xmlschema-dev@w3.org
Hi Jesse, >>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. > > You mean I will have to include the attribute in the instance > document, correct? Yes, that's right. >>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. > > That was the only rationale I could imagine. That is exactly the use > I have in mind -- to ensure that there is only a single element of > the given type in the document. I assume that this element could appear just about anywhere (otherwise you could probably constrain it more easily using content models)? Another approach that you could use would be to use a different type for the id attribute (e.g. xs:Name) and create an identity constraint with xs:key within the declaration for the document element, something like: <xs:key name="uniqueElement"> <xs:selector xpath=".//elementName" /> <xs:field xpath="@id" /> </xs:key> (This says that within the document, every element called 'elementName' has to have a unique value for its id attribute.) Since this doesn't use xs:ID as the attribute type, this would enable you to use 'fixed' to fix the value of the id attribute. > By the way, what software would you recommend for schema validation, > either locally or online? For obvious reasons I have lost confidence > in the XSV validator available via the web. Well, Xerces-C++ and now Xerces-J v2 claim to cover all of XML Schema now. I haven't tried Xerces-J yet, but I haven't yet come across anything that Xerces-C++ doesn't handle. Those are both from xml.apache.org. There's also MSXML4 (although that implementation is still a bit dodgy, particularly with identity constraints) and MSV (multi-schema validator from http://www.sun.com/software/xml/developers/multischema/). I think it's a good idea at the moment to have a range of validators to try things out with. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/
Received on Sunday, 23 December 2001 07:49:40 UTC