Hi,

I am trying to examine schema attribute definintions using Xerces.  I am able 
to retrieve information about attributes that includes an attribute name, its 
type name and whether it is required.
However I want to retrieve more detailed information about the attribute's 
type. For example, given the type definition below I would like to retrieve the 
values that make up the enumeration i.e.
1,2,3,4,5. I can't seem to work out the correct approach to retrieving this 
information. I would also like to know how this would work for a type with 
restrictions like 'negative integer'. 

I have also included my code to highlight how I have been trying to approach 
this problem.

<simpleType name="testType">
         <restriction base="integer">
            <enumeration value="1"/>
            <enumeration value="2"/>
            <enumeration value="3"/>
            <enumeration value="4"/>
            <enumeration value="5"/>
         </restriction>
 </simpleType>  

<complexType name="classType">
          <sequence>
                <element name="template" type="templateType" 
maxOccurs="unbounded"/>
          </sequence>
          <attribute name="matches" type="testType" use="required"/>
</complexType>

Where element is an instance of 'XSElementDeclaration':

XSTypeDefinition elementTypeDef = element.getTypeDefinition();
XSObjectList attributeUses  = 
((XSComplexTypeDefinition)elementTypeDef).getAttributeUses();
        
for(int attrUseIdx=0; attrUseIdx < attributeUses.getLength(); attrUseIdx++)
{
            XSAttributeUse attributeUse = 
(XSAttributeUse)attributeUses.item(attrUseIdx);
            XSAttributeDeclaration attribute = 
attributeUse.getAttrDeclaration();
            XSSimpleTypeDefinition attributeType = 
attribute.getTypeDefinition();
            
            System.out.println(attribute.getName() + ", required? " + 
attributeUse.getRequired() +
            ", bounded? " + attributeType.getBounded() + ", finite? " + 
attributeType.getFinite() +
            ", numeric? " + attributeType.getNumeric() + ", type: " + 
attributeType.getName() +
            ", constraint value: " + attribute.getConstraintValue() + ", 
enumeration" attributeType);            
}

Hope there is a straightforward answer to this.

Cheers,

Martin.


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

Reply via email to