RE: Both extending and restricting with <redefine>

Hi Henry,

Thanks for the reply.  There's been a little mix-up, though.  I changed
the file b.xsd after an earlier reply from Michael Kay, as explained in
this archived message:
http://lists.w3.org/Archives/Public/xmlschema-dev/2005Apr/0004.html

(I should have created new files instead of editing existing ones when
responding.  Sorry for the confusion.)

> Are you sure -- web form reports the expected error when I run it:
> http://www.w3.org/2001/03/webdata/xsv?docAddrs=http%3A%2F%2Fwww.ruleml.org%2F0.89%2Fexa%2Fab.ruleml&style=xsl#

That file which now validates fine with XSV uses a b.xsd with <redefine>s:

	<xs:redefine schemaLocation="a.xsd">
		<!-- add y to body -->
		<xs:group name="body.content">
			<xs:choice>
				<xs:group ref="body.content"/>
				<xs:element ref="y"/>				
			</xs:choice>
		</xs:group>	
	</xs:redefine>

	<xs:redefine schemaLocation="a.xsd">
		<!-- remove x from body by restriction --> 	
		<xs:group name="body.content">
			<xs:choice>
				<xs:element ref="y"/>
			</xs:choice>
		</xs:group>
	</xs:redefine>

The above just doesn't seem to right to me, but this strategy seems the
best supported right now (with Saxon and XSV, at least).

When I sent my original message to the list, the file b.xsd only used one
<redefine>:

	<xs:redefine schemaLocation="a.xsd">
		<!-- add y to body -->
		<xs:group name="body.content">
			<xs:choice>
				<xs:group ref="body.content"/>
				<xs:element ref="y"/>				
			</xs:choice>
		</xs:group>	

		<!-- remove x from body by restriction --> 	
		<xs:group name="body.content">
			<xs:choice>
				<xs:element ref="y"/>
			</xs:choice>
		</xs:group>
	</xs:redefine>

I created new files f.xsd, g.xsd (at http://www.ruleml.org/0.89/xsd) for this
original example.  Note that with this one <redefine>, XSV crashes:
http://www.w3.org/2001/03/webdata/xsv?docAddrs=http%3A%2F%2Fwww.ruleml.org%2F0.89%2Fexa%2Ffg.ruleml&style=xsl#

> The 'correct' way to do this is with _three_ files.

Unfortunately XSV doesn't seem to like the three file way either:

m.xsd is the same as the previous a.xsd/f.xsd

n.xsd redefines m.xsd, adding in <y>

o.xsd redefines n.xsd, removing <x>

(again all at http://www.ruleml.org/0.89/xsd)

Validating http://www.ruleml.org/0.89/exa/mno.ruleml results in a crash:
http://www.w3.org/2001/03/webdata/xsv?docAddrs=http%3A%2F%2Fwww.ruleml.org%2F0.89%2Fexa%2Fmno.ruleml&style=xsl#

I wish the spec were clearer on this.  Do you still recommend the 3 file
approach?  Normally in RuleML each schema represents a meaningful sublanguage,
so having extra "intermediate" schemas is less than ideal, but if it's
the only way to replace one element by another I guess we have no choice.

Thanks again,

David

-----Original Message-----
From: ht@inf.ed.ac.uk [mailto:ht@inf.ed.ac.uk] 
Sent: Saturday, April 02, 2005 10:43 AM
To: Hirtle, David
Cc: xmlschema-dev@w3.org
Subject: Re: Both extending and restricting with <redefine>

"Hirtle, David" <David.Hirtle@nrc-cnrc.gc.ca> writes:

> a.xsd (http://www.ruleml.org/0.89/xsd/a.xsd) defines an element "body"
> which allows only the element "x".
>
> b.xsd (http://www.ruleml.org/0.89/xsd/b.xsd) redefines "body" from 
> a.xsd, first extending it to allow a new element "y" and then 
> restricting it to disallow "x", effectively replacing "x" with "y" in 
> the content model of "body".
>
> Assuming this is permissible in XML Schema...
>
> ab.ruleml (http://www.ruleml.org/0.89/exa/ab.ruleml) should not be 
> valid w.r.t. b.xsd because "body" contains an "x".
>
> XSV (web form and installation) reports no validity problems but 
> crashes.  Saxon correctly (?) identifies the problem, as appended 
> below.

Are you sure -- web form reports the expected error when I run it:

  http://www.w3.org/2001/03/webdata/xsv?docAddrs=http%3A%2F%2Fwww.ruleml.org%2F0.89%2Fexa%2Fab.ruleml&style=xsl#

> So I'm left with the question: is this the correct way to "replace" an 
> element with another in a content model via <redefine> (if possible at 
> all with XML Schema)?  And what about the validators?

I can see why this works, but I don't _think_ it should.

The 'correct' way to do this is with _three_ files.

ht
--
 Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
                     Half-time member of W3C Team
    2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
            Fax: (44) 131 650-4587, e-mail: ht@inf.ed.ac.uk
                   URL: http://www.ltg.ed.ac.uk/~ht/ [mail really from me _always_ has this .sig -- mail without it is forged spam]

Received on Monday, 4 April 2005 14:44:41 UTC