getEnclosingCTDefinition() gives you the complex type that "contains" the
current element. In the case of "responsemodel", because it is a global
element declaration, there is no complex type that contains it, so
getEnclosingCTDefinition() return null.

To get the type of the element, as Maksym indicated, you should use getType
().

HTH,
Sandy Gao
Software Developer, IBM Canada
(1-905) 413-3255
[EMAIL PROTECTED]



                                                                                       
                                          
                      Nick Betteridge                                                  
                                          
                      <[EMAIL PROTECTED]        To:       [EMAIL PROTECTED]            
                                
                      actics.com>               cc:                                    
                                          
                                                Subject:  Re: Scope and 
getEnclosingCTDefinition() bug?                          
                      07/30/2003 11:35                                                 
                                          
                      AM                                                               
                                          
                      Please respond to                                                
                                          
                      xerces-j-dev                                                     
                                          
                                                                                       
                                          
                                                                                       
                                          



Sorry, I've just realised that my problem was poorly stated - I'm trying to
traverse down the schema and when I try to get the XSComplexTypeDecl which
should be accessible via xsElementDecl.getEnclosingCTDefinition(), all I
get is a null.
 ----- Original Message -----
 From: Maksym Kovalenko
 To: [EMAIL PROTECTED]
 Sent: Wednesday, July 30, 2003 4:08 PM
 Subject: Re: Scope and getEnclosingCTDefinition() bug?

 Element responsemodel has global scope and its type has local scope.
 To get element's type use
 (XSComplexTypeDeclaration) xsElementDecl.getType()

 Nick Betteridge wrote:
       Hi

       I'm not too sure if this is a bug - I have a simple schema, and if I
       parse the schema and begin to traverse down through the
       schemagrammer, I get to the first complexType. Xerces tells me that
       the element "responsemodel" is a XSElementDecl.SCOPE_GLOBAL. Is this
       correct? Surely it should be a XSElementDecl.SCOPE_LOCAL? As a
       consequence, I cannot get the complexType.

       I'm using the latest version of xercesImpl.jar (29-Jul-2003)

       Regards
       Nick

       grammer
       = (SchemaGrammar)preparser.preparseGrammar(XMLGrammarDescription.XML_SCHEMA,

       xmlInputSource);
       xsNamedMap = grammer.getComponents(XSConstants.ELEMENT_DECLARATION);
       for (int i=0; i<xsNamedMap.getLength(); i++ ) {
                   XSObject object = xsNamedMap.item(i);
                   XSElementDecl xsElementDecl = (XSElementDecl)object;
                   if (xsElementDecl.getScope()
       ==XSElementDecl.SCOPE_GLOBAL) {
        ..... etc

       <?xml version="1.0" encoding="UTF-8"?>
       <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
           attributeFormDefault="unqualified" elementFormDefault
       ="qualified">
           <xs:element name="responsemodel">
               <xs:complexType>
                   <xs:sequence>
                       <xs:element name="response" type="xs:string"/>
                       <xs:element name="exceptionThrown" type
       ="xs:boolean"/>
                       <xs:element name="exceptionMessage" minOccurs="0"
       type="xs:string"/>
                       <xs:sequence>
                           <xs:element name="children" minOccurs="0"
                               maxOccurs="unbounded" type="xs:string"/>
                       </xs:sequence>
                       <xs:element name="booleanResponse" minOccurs="0"
       type="xs:boolean"/>
                       <xs:element name="byteResponse" minOccurs="0" type
       ="xs:base64Binary"/>
                       <xs:element name="calendarResponse" minOccurs="0"
       type="xs:date"/>
                       <xs:element name="longResponse" minOccurs="0" type
       ="xs:int"/>
                   </xs:sequence>
               </xs:complexType>
           </xs:element>
       </xs:schema>

 --



 Maksym Kovalenko
 Software Engineer
 Marketswitch Corporation
 http://www.marketswitch.com
 108 Powers Court, Suite 225
 Dulles, VA 20166
 Phone: +1 (703) 444-6750 ext. 302
 Fax: +1 (703) 444-6812








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

Reply via email to