You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by David Rolland <da...@msem.univ-montp2.fr> on 2004/03/17 10:29:27 UTC

getAttributeDeclaration with an extension

I'm trying to retrieve attributes declarations from an 'XSModel' instance
using 'getAttributeDeclaration' method but null is return.
For example, I can't get 'birthday' and 'adn' declarations.

The part of the schema is (all the types are declared in the xsd) :

<?xml version="1.0" encoding="iso-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
...
<xs:complexType name="entityType" mixed='true'>
    <xs:sequence>
        <xs:element name="name" minOccurs="1" maxOccurs="1"
type="nameType"/>
        <xs:element name="comment" type="commentType" default=""/>
    </xs:sequence>
    <xs:attribute name="id" type="xs:ID"/>
</xs:complexType>

<xs:element name="dog">
    <xs:complexType>
        <xs:complexContent mixed='true'>
            <xs:extension base="entityType">
                <xs:sequence>
                    <xs:element name="colour" minOccurs="1" maxOccurs="1"
type="xs:string"/>
                        <xs:complexType>
                            <xs:sequence>
                                <xs:element name="dogShow" minOccurs="0"
maxOccurs="unbounded">
                                    <xs:complexType>
                                        <xs:attribute name="result"
type="xs:byte"/>
                                        <xs:attribute name="show"
type="xs:IDREF"/>
                                    </xs:complexType>
                                </xs:element>
                            </xs:sequence>
                        </xs:complexType>
                    </xs:element>
                </xs:sequence>
                <xs:attribute name="adn" type="xs:string"/>
                <xs:attribute name="birthday" type="birthdayType"
use="required"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
</xs:element>


Any ideas would be appreciated.

Thanks,
David


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


Re: getAttributeDeclaration with an extension

Posted by Mike Boos <mb...@ca.ibm.com>.



"David Rolland" <da...@msem.univ-montp2.fr> wrote on 03/17/2004
04:29:27 AM:

> I'm trying to retrieve attributes declarations from an 'XSModel' instance
> using 'getAttributeDeclaration' method but null is return.
> For example, I can't get 'birthday' and 'adn' declarations.

The XSModel interface is for accessing the top-level items in the schema.
The attribute declarations you are trying to get at are local. To get at
the 'birthday' and 'adn' declarations, you would have retrieve them from
the attribute uses of the complex type definition of the 'dog' element
declaration, eg:

XSElementDeclaration dogDecl = schemaModel.getElementDeclaration("dog",
null);
XSComplexTypeDefinition complexType =
(XSComplexTypeDefinition)dogDecl.getTypeDefinition();
XSObjectList attributeUses = complexType.getAttributeUses();
for(int i = 0; i < attributeUses.getLength(); i++) {
      XSAttributeUse attrUse = (XSAttributeUse)attributeUses.item(i);
      XSAttributeDeclaration attrDecl = attrUse.getAttrDeclaration();
      //Work with attrDecl
      ...
}

Hope this helps you!

Mike Boos
mboos@ca.ibm.com
(905) 413-3722


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