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">
		<element name="blah" type="any" />
	<attribute name="type" use="required" type="string" />

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">
		<restriction base="tns:baseType">
				<element name="blah" type="any" />
			<attribute name="type" use="required" type="string"
fixed="derivedTypeType" />

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 conten goes here...

and have the "type" attribute be inserted upon validation -> leading to
the following xml (post validation)

<derivedElt type="derivedType">
	...de content goes here

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>

Any ideas?


Received on Monday, 9 September 2002 16:27:04 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:05 UTC