[ 
https://issues.apache.org/jira/browse/XERCESJ-1540?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13151787#comment-13151787
 ] 

Mukul Gandhi commented on XERCESJ-1540:
---------------------------------------

I wrote a small test case (and using Xerces 2.11.0 to run this test case), 
trying to verify your claim that Xerces isn't modeling XSD particles (and 
consequently the XSD complex type model) correctly.

I'm using the following XSD documents:

test.xsd

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; xmlns:ns="http://ns";>

   <xs:import schemaLocation="person.xsd" namespace="http://ns"/>
   
   <xs:complexType name="result">
      <xs:sequence>
         <xs:element form="qualified" minOccurs="0" name="username" 
type="xs:string"/>
         <xs:element form="qualified" minOccurs="0" name="password" 
type="xs:string"/>
         <xs:element ref="ns:name"/>
         <xs:element minOccurs="0" ref="ns:author"/>
      </xs:sequence>
   </xs:complexType> 
         
</xs:schema>

person.xsd :

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
targetNamespace="http://ns";>

     <xs:element name="name" type="xs:string"/>
         
     <xs:element name="author" type="xs:string"/>
         
</xs:schema>

The following java test case, builds an XSModel instance from the XSD document 
test.xsd and then queries certain aspects (essentially the XSParticle details 
which you think are incorrectly modeled) of the constructed XSModel instance:

XSLoader xsLoader = new XSLoaderImpl();
XSModel xsModel = xsLoader.loadURI("test.xsd");
XSComplexTypeDefinition cmplxTypeDefinition = 
(XSComplexTypeDefinition)xsModel.getTypeDefinition("result", null);
XSParticle compositeParticle = cmplxTypeDefinition.getParticle();
XSTerm term1 = compositeParticle.getTerm();
if (term1 instanceof XSModelGroup) {
   System.out.println("the complex type 'result' has a model group particle");
   XSModelGroup modelGp = (XSModelGroup)term1;
   if (modelGp.getCompositor() == XSModelGroup.COMPOSITOR_SEQUENCE) {
       System.out.println("the compositor kind of model group particle(that is 
within a complex type 'result') is 'sequence'");
       XSObjectList modelGpPrtcls = modelGp.getParticles();
       System.out.println("no of particles within the model group particle are: 
" + modelGpPrtcls.getLength());
       for (int prtclIdx = 0; prtclIdx < modelGpPrtcls.getLength(); prtclIdx++) 
{
          XSParticle partclInst = (XSParticle)modelGpPrtcls.get(prtclIdx);
          XSTerm prtclTrm = partclInst.getTerm();
          if (prtclTrm instanceof XSElementDeclaration) {
             XSElementDeclaration elmDecl = (XSElementDeclaration) prtclTrm;
             System.out.println("particle "+(prtclIdx+1)+". element name: 
"+elmDecl.getName());
          }
      }
   }
}


The above program prints following output,

the complex type 'result' has a model group particle
the compositor kind of model group particle (that is within a complex type 
'result') is 'sequence'
no of particles within the model group particle are: 4
particle 1. element name: username
particle 2. element name: password
particle 3. element name: name
particle 4. element name: author

Following is some explanation what the above output indicates,
1. The complexType in this example has only one particle, which is of kind 
model group whose compositor is "sequence"
2. When we further query the model group particle from step 1, it shows to 
contain four particles which are of kind "element declarations"

I believe, this test case showcases that Xerces correctly models XSD complex 
types and particles. You seem to have incorrectly assumed the nature of the 
particle within the complex type (it is a model group particle, and not four 
element particles as you incorrectly thought).

I therefore think, your bug report may be incorrect.
                
> getParticle() method of XSComplexTypeDefinition, does not return element 
> references in a complex type
> -----------------------------------------------------------------------------------------------------
>
>                 Key: XERCESJ-1540
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1540
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: XML Schema API
>    Affects Versions: 2.11.0
>         Environment: Windows 7, xercesImpl-2.11.0b.jar
>            Reporter: Deepti Garg
>             Fix For: 2.11.0
>
>         Attachments: Chrono1.wsdl, Chrono1.wsdl, 
> WebservicesBaseComplexTypeWrapper.java
>
>
> The element references of complex types in the XSD are not returned by the 
> method of the Xerces API, getPaticle(.
> <xs:complexType name="result">
>     <xs:sequence>
>      <xs:element form="qualified" minOccurs="0" name="username" 
> type="xs:string"/>
>      <xs:element form="qualified" minOccurs="0" name="password" 
> type="xs:string"/>
>      <xs:element ref="ns:name"/>
>      <xs:element minOccurs="0" ref="ns:author"/>
>     </xs:sequence>
>    </xs:complexType>
> Here for the complex type result, only username and password elements are 
> returned by the getParticle() method. Even if the element reference belongs 
> to the same namespace as the complex type, it is not returned by the 
> getParticle() method. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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

Reply via email to