sshyran / genxdm

Automatically exported from code.google.com/p/genxdm
0 stars 0 forks source link

Schema parser calculates incorrect type for element declaration #156

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When an element declaration lacks a "type" attribute but does have a 
"substitutionGroup" attribute, the type of the element should be the type of 
the element named in the substitution group.

For example:

    <xs:element name="foo" substitutionGroup="ns1:bar"/>

The type of the foo element should be the same as the type of ns1:bar element. 
(See section 3.3.2 of the schema spec.)

Currently the schema parser is raising an 
org.genxdm.processor.w3c.xs.exception.scc.SccElementDeclarationSubstitutionGroup
TypeDerivationException.

Original issue reported on code.google.com by joe.bays...@gmail.com on 3 Nov 2014 at 6:08

GoogleCodeExporter commented 8 years ago
The element type was set incorrectly for the following two use cases:
1. The declaration for element A lacks a type attribute and is in subgroup of 
element b; the declaration for element b also lacks a type attribute and is in 
subgroup of c; the element declaration for element c does have a type 
attribute.  In this case elements a and b should have the same type as element 
c; instead, they are set to xs:anyType.
2. The declaration for element A lacks a type attribute and is in the subgroup 
of element b; element b is from an imported document and that document has 
already been parsed, placing element b in the SchemaComponentCache for already 
parsed documents.  Element A's type is improperly set to xs:anyType.

Original comment by joe.bays...@gmail.com on 10 Nov 2014 at 4:12

GoogleCodeExporter commented 8 years ago
(r519)
To address use case #1 from previous comment, we modified the 
XMLSchemaCache.computeSubstitutionGroup method to be recursive, so that 
elements w/o typeRefs but w/substitution groups can have their type properly 
set.

To address use case #2, we modified the XMLSchemaConverter.convertElement 
method.  Now, if an element's typeRef is the complexUrType (indicating the lack 
of a type attribute in the element declaration) and the element is a member of 
a substitutionGroup, we use the substitutionGroupHead's type as the element 
type.

Original comment by joe.bays...@gmail.com on 10 Nov 2014 at 4:19