You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by bu...@apache.org on 2002/05/13 19:24:05 UTC

DO NOT REPLY [Bug 9041] New: - schema validation with substitutionGroup from another namespace

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=9041>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=9041

schema validation with substitutionGroup from another namespace

           Summary: schema validation with substitutionGroup from another
                    namespace
           Product: Xerces2-J
           Version: 2.0.0
          Platform: All
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: XML Schema Structures
        AssignedTo: xerces-j-dev@xml.apache.org
        ReportedBy: luca@ucar.edu


Hi,
I think there might be a bug in schema validation when a substitution group
references an element in another namespace. As an example I get an error when 
validating the following document:

<?xml version="1.0" encoding="UTF-8"?>
<nc:netcdf xmlns:nc="http://nebbia.scd.ucar.edu/xml/test/netcdf"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:cf="http://nebbia.scd.ucar.edu/xml/test/netcdf-cf"
           xsi:schemaLocation="http://nebbia.scd.ucar.edu/xml/test/netcdf
http://nebbia.scd.ucar.edu/xml/test/netcdf.xsd
http://nebbia.scd.ucar.edu/xml/test/netcdf-cf
http://nebbia.scd.ucar.edu/xml/test/netcdf-cf.xsd">
  <nc:variable name="P0" />
  <nc:latitude name="lat" />
  <cf:latitude name="lat" />
</nc:netcdf>

where the two schema defintions are as follows:
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema targetNamespace="http://nebbia.scd.ucar.edu/xml/test/netcdf"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:nc="http://nebbia.scd.ucar.edu/xml/test/netcdf"
            elementFormDefault="qualified">

  <xsd:element name="netcdf" type="nc:NetcdfType" />
  <xsd:complexType name="NetcdfType">
    <xsd:sequence>
       <xsd:element ref="nc:variable"  minOccurs="0" maxOccurs="unbounded" />
    </xsd:sequence>
  </xsd:complexType>

  <xsd:element name="variable" type="nc:VariableType" />
  <xsd:complexType name="VariableType">
     <xsd:attribute name="name" type="xsd:string" use="optional" />
  </xsd:complexType>

  <xsd:element name="latitude" type="nc:VariableType"
substitutionGroup="nc:variable" />

</xsd:schema>

and:

<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema targetNamespace="http://nebbia.scd.ucar.edu/xml/test/netcdf-cf"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:nc="http://nebbia.scd.ucar.edu/xml/test/netcdf"
            xmlns:cf="http://nebbia.scd.ucar.edu/xml/test/netcdf-cf"
            elementFormDefault="qualified">

  <xsd:import namespace="http://nebbia.scd.ucar.edu/xml/test/netcdf"
              schemaLocation="http://nebbia.scd.ucar.edu/xml/test/netcdf-cf.xsd" />

  <xsd:element name="latitude" type="nc:VariableType"
substitutionGroup="nc:variable" />

</xsd:schema>

the error I get when trying to validate with an instance of
org.apache.xerces.parsers.SAXParser is:

[Error] example.ncx:8:29: cvc-complex-type.2.4.a: Invalid content starting with
element 'cf:latitude'. The content must match
'("http://nebbia.scd.ucar.edu/xml/test/netcdf":variable){0-UNBOUNDED}'.

(I have set the followinf=g features on:
        parser.setFeature( "http://xml.org/sax/features/validation", true);
        parser.setFeature( "http://xml.org/sax/features/namespaces",true);
        parser.setFeature( "http://apache.org/xml/features/validation/schema",true);
)

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org