Hi

this question is related to an earlier related post
http://www.mail-archive.com/user%40xmlbeans.apache.org/msg02224.html


We are unable to retrieve some of the identity constraints from their
associated particles in the generated type system.  The content model of
each complex type is traversed as described below, and we find that many
of the constraints are missing. After some investigation, I was led to
think it was possibly due to pointless particles in the schema that were
being ignored - but I still see the particles that have the constraints
defined against them. 

The following test schema illustrates what is happening:

        <xs:element name="testdesign" type="con:testdesign"/>

        <xs:complexType name="testdesign">
                <xs:sequence>
                        <xs:element name="testroot" type="con:testroot">
                                <xs:key name="elementAKey">
                                        <xs:selector
xpath="./con:elementA"/>
                                        <xs:field xpath="@name"/>
                                </xs:key>
                        </xs:element>
                        <xs:element name="testRoot2" type="xs:string"/>
                </xs:sequence>
        </xs:complexType>

When there is more than one element in the above sequence, the
constraint "elementAKey" cannot be found - nor can any particles for the
"testdesign" type. When element "testroot2" is removed, then
"elementAKey" is found.

Constraints are being searched as follows (note: only global types are
defined in schema):

              for(SchemaType type:sts.globalTypes())
            {
                checkIdentityConstraints(type);
            }

    private void checkIdentityConstraints(SchemaType _st)
    {       
        if (_st.getContentType() == SchemaType.ELEMENT_CONTENT
                || _st.getContentType() == SchemaType.MIXED_CONTENT)
        {
            SchemaParticle particle = _st.getContentModel();
            switch (particle.getParticleType())
            {
                case SchemaParticle.ELEMENT:
                    printParticle(_st);
                   break;
                case SchemaParticle.CHOICE:
                case SchemaParticle.SEQUENCE:
                case SchemaParticle.ALL:
                    SchemaParticle[] pchildren =
particle.getParticleChildren();
                    if (pchildren != null)
                    {    
                        for (SchemaParticle pchild : pchildren)
                        {
                            SchemaType childType = pchild.getType();
                            if(childType!=null)
                            {   
                                printParticle(childType);      
                                checkIdentityConstraints(childType);

                                ....


The validation of documents appears to work correctly and detects
violations of these "missing" constraints and I can find it
directly with  SchemaTypeSystem.findIdentityConstraintRef().  So it
seems there is still a flaw in the algorithm (?). 


thanks again for any assistance

Les





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to