XML Schema context sensitive?

Hello,

I think the general opinion is that XML Schema can represent context free 
grammars, but no context sensitive grammars. 

I think that XML Schema **can** represent context sensitive grammars. 
 by means of local element declarations? Would you please correct if I'm 
wrong after considering the following example:

Schema:
***********************************************************

<?xml version="1.0" encoding="UTF-8"?>

<schema>

<element name="A">
  <complexType>
    <element name="C" type="string"/>
  </complexType>
</element>
<element name="B">
  <complexType>
    <element name="C" type="integer"/>
  </complexType>
</element>

</schema>

Instances:
***********************************************************

The following instance is valid:

<A xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" 
       xsi:noNamespaceSchemaLocation="kontextSensitiv.xsd">
  <C> abc </C>
</A>

whereas 

<B xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" 
       xsi:noNamespaceSchemaLocation="kontextSensitiv.xsd">
  <C> abc </C>
</B>

is not valid. The reason for this is an explanation in Section 2.2.3 of the 
Primer:

"If the two things are elements within different types (i.e. not global 
elements), say I declare one element called name as part of the USAddress 
type and a second element called name as part of the Item type, there is no 
conflict. (Such elements are sometimes called local element declarations.)"

Yours,
Holger

Received on Tuesday, 24 April 2001 11:24:23 UTC