[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xmlbeans-user
Subject:    RE: Cannot find SchemaIdentityConstraints in particles
From:       "Les Walker" <lawalker () nortel ! com>
Date:       2007-05-25 12:08:42
Message-ID: E63CD74A41BC06418D625A31BDE26E8D107910D4 () zrtphxm1 ! corp ! nortel ! com
[Download RAW message or body]

Thanks Radu

That seems to have taken care of it. Much appreciated

Les

-----Original Message-----
From: Radu Preotiuc-Pietro [mailto:radup@bea.com] 
Sent: Wednesday, May 23, 2007 9:39 PM
To: user@xmlbeans.apache.org
Subject: RE: Cannot find SchemaIdentityConstraints in particles


Here's what you want to do instead:

    private void checkIdentityConstraints(SchemaType _st)
    {       
        if (_st.getContentType() == SchemaType.ELEMENT_CONTENT
                || _st.getContentType() == SchemaType.MIXED_CONTENT)
        {
            SchemaParticle particle = _st.getContentModel();
            checkIdentityConstraints(particle);
        }
    }

    private void checkIdentityConstraints(SchemaParticle particle)
            switch (particle.getParticleType())
            {
                case SchemaParticle.ELEMENT:
                    printParticle((SchemaLocalElement) particle);
                   break;
                case SchemaParticle.CHOICE:
                case SchemaParticle.SEQUENCE:
                case SchemaParticle.ALL:
                    SchemaParticle[] pchildren =
particle.getParticleChildren();
                    if (pchildren != null)
                    {    
                        for (SchemaParticle pchild : pchildren)
                        {
                             checkIdentityConstraints(pchild);

				....
 
I haven't actually run this code, but you get the idea...

Radu

-----Original Message-----
From: Les Walker [mailto:lawalker@nortel.com] 
Sent: Wednesday, May 23, 2007 2:02 PM
To: user@xmlbeans.apache.org
Subject: Cannot find SchemaIdentityConstraints in particles

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: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic