Dear XXE people,

I'm experimenting with XXE for data input have a problem when dealing with 
cascading groups.

I want to have a menu which allows to choose the country, the region/province 
and the city.

Alas, something like this: 

        Italy
                Piemonte
                        Milano
                        Linate
                Val d'Aosta
                        Aosta
                ...
                Lazio
                        Roma
                        Rieti
                        Viterbo

Obviously, these are qualified choices: if choosing "Italy", the provinces to 
choose from are "Piemonte" / "Val d'Aosta" / "Lombardia" / etc. and when 
choosing, for example, "Lazio", there are the cities "Rome", "Rieti" etc. to 
choose from.

Declaring groups is easy in RelaxNG, where attribute values and sub-elements 
can intermingle, but not in XSD (which XXE uses). 

I have to work with elements, exclusively, and came up with this solution:

        <place>
            <Country>
                <CountryName>Italy</CountryName>
                <Region>
                    <RegionName>Lazio</RegionName>
                    <City>
                        <CityName>Roma</CityName>
                    </City>
                </Region>
            </Country>
        </place>

Defining this in RelaxNG looks like this:

                    <element name="place">
                        <element name="Country">
                            <choice>
                                <group>
                                    <element name="CountryName">
                                        <value>Italy</value>
                                    </element>
                                    <element name="Region">
                                        <choice>
                                            <group>
                                                <element name="RegionName">
                                                    <value>Lazio</value>
                                                </element>
                                                <element name="City">
                                                    <element name="CityName">
                                                        <choice>
                                                            <value>Roma</value>
                                                            <value>Rieti</value>
                                                        </choice>
                                                    </element>
                                                </element>
                                            </group>
                                            <group>
                                                <element name="RegionName">
                                                    <value>Campania</value>
                                                </element>
                                                <element name="City">
                                                    <element name="CityName">
                                                        <choice>
                                                            
<value>Napoli</value>
                                                            
<value>Caserta</value>
                                                        </choice>
                                                    </element>
                                                </element>
                                            </group>
                                        </choice>
                                    </element>
                                </group>
                            </choice>
                        </element>
                    </element>

And here is the automatic (Trang) translation into XSD:

  <xs:element name="place">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Country"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="Country">
    <xs:complexType>
      <xs:choice>
        <xs:sequence>
          <xs:element ref="CountryName"/>
          <xs:element ref="Region"/>
        </xs:sequence>
        <xs:element ref="none"/>
      </xs:choice>
    </xs:complexType>
  </xs:element>
  <xs:element name="CountryName">
    <xs:simpleType>
      <xs:restriction base="xs:token">
        <xs:enumeration value="Italy"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <xs:element name="Region">
    <xs:complexType>
      <xs:choice>
        <xs:sequence>
          <xs:element name="RegionName">
            <xs:simpleType>
              <xs:restriction base="xs:token">
                <xs:enumeration value="Lazio"/>
              </xs:restriction>
            </xs:simpleType>
          </xs:element>
          <xs:element name="City">
            <xs:complexType>
              <xs:sequence>
                <xs:element name="CityName">
                  <xs:simpleType>
                    <xs:restriction base="xs:token">
                      <xs:enumeration value="Roma"/>
                      <xs:enumeration value="Rieti"/>
                    </xs:restriction>
                  </xs:simpleType>
                </xs:element>
              </xs:sequence>
            </xs:complexType>
          </xs:element>
        </xs:sequence>
        <xs:sequence>
          <xs:element name="RegionName">
            <xs:simpleType>
              <xs:restriction base="xs:token">
                <xs:enumeration value="Campania"/>
              </xs:restriction>
            </xs:simpleType>
          </xs:element>
          <xs:element name="City">
            <xs:complexType>
              <xs:sequence>
                <xs:element name="CityName">
                  <xs:simpleType>
                    <xs:restriction base="xs:token">
                      <xs:enumeration value="Napoli"/>
                      <xs:enumeration value="Caserta"/>
                    </xs:restriction>
                  </xs:simpleType>
                </xs:element>
              </xs:sequence>
            </xs:complexType>
          </xs:element>
        </xs:sequence>
      </xs:choice>
    </xs:complexType>
  </xs:element>

The RNG and XSD files do all validate without errors.

But when I load my file in XXE (obviously, I have defined a CSS and declared 
all namespaces), I get the following message (the actual file loads when I 
quit the message, but the schema isn't interpreted):

        file:/home/k1/workspace/CollectioML/collectio.xsd:E:222:10: element
        declaration "RegionName" inconsistent [cos-element-consistent]

Xerces didn't complain, however.

Is it a over-sensibility on the part of XXE, or am I stuck in the middle of a 
difficult consistency specification?

Any advice would be much appreciated!

-- 
klaus e. werner | ???? ??? ???? ??? ??? ????
mailto://kewerner at fastmail.fm  callto://kewerner

Reply via email to