RE: "tying-down" a required attribute's value

Saul - 

if the attribute is declared "required" in the parent type, 
then you *cannot* define a restriction which converts this to optional.  
This would break the requirement that an element of the derived type by
restriction is valid according to the parent type.  

Like you say, the only way to get a fixed attribute value 
inserted at validation time and not appear in the instance 
document is for the the attribute to be "optional".  

Regards   Simon
_____
[This mail represents part of a discussion of work in progress 
and should not be used for any purpose without my permission.] 
_____
Simon.Cox@csiro.au  CSIRO Exploration & Mining
26 Dick Perry Avenue, Kensington WA 6151
PO Box 1130, Bentley WA 6102  AUSTRALIA
T: +61 (8) 6436 8639  F: +61 (8) 6436 8555  C: +61 (4) 0330 2672
http://www.csiro.au/page.asp?type=resume&id=CoxSimon

> -----Original Message-----
> From: Saul Farber [mailto:saul@syncline.com]
> Sent: Tuesday, 10 September 2002 4:29 AM
> To: xmlschema-dev@w3.org
> Subject: "tying-down" a required attribute's value
> 
> 
> Hello experts!
> 
> I'm trying to restrict a complexType which declares a 
> required attribute
> (use="required" on the base type).
> 
> Base Type:
> 
> <element name="baseElt" type="tns:baseType" />
> <complexType name="baseType">
> 	<sequence>
> 		<element name="blah" type="any" />
> 	</sequence>
> 	<attribute name="type" use="required" type="string" />
> </complexType>
> 
> In my restricted type I am trying to "fix" the value of that "type"
> attribute in my derived type.  For example:
> 
> <element name="derivedElt" type="tns:derivedType" />
> <complexType name="derivedType">
> 	<complexContent>
> 		<restriction base="tns:baseType">
> 			<sequence>
> 				<element name="blah" type="any" />
> 			</sequence>
> 			<attribute name="type" use="required" 
> type="string"
> fixed="derivedTypeType" />
> 		</restriction>
> 	</complexContent>
> </complexType>
> 
> So far so good...my problem is that I don't want people to have to
> explicitly DECLARE the type on my derived type.  I would like 
> people to
> be able to write the following:
> 
> <derivedElt>
> 	...derivedElt conten goes here...
> </derivedElt>
> 
> and have the "type" attribute be inserted upon validation -> 
> leading to
> the following xml (post validation)
> 
> <derivedElt type="derivedType">
> 	...de content goes here
> </derivedElt>
> 
> As far as I can tell, however, attributes are only "inserted" with
> pre-defined values when their "use" attribute is declared 
> "optional".  I
> don't have control over the schema of the base type in this 
> case (it's a
> handed-down schema), and I'd like to allow my users to forgo the
> explicit declaration of the "type" attribute on their <derivedElt>
> instances.
> 
> Any ideas?
> 
> thanks!
> --saul
> 
> 
> 
> 

Received on Monday, 9 September 2002 20:45:38 UTC