W3C home > Mailing lists > Public > xmlschema-dev@w3.org > September 2002

"tying-down" a required attribute's value

From: Saul Farber <saul@syncline.com>
Date: 09 Sep 2002 16:29:01 -0400
To: xmlschema-dev@w3.org
Message-Id: <1031603341.10320.109.camel@saul.internal.syncline.com>
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 16:27:04 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:34 GMT