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 -----
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

Reply via email to