Hi there, I am wondering whether I am doing something wrong in getting attribute declaration information. I am using Xerces 2.3.0.
If I have a schema like: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="testElem"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="attr1" type="xs:string"/> <xs:attribute name="attr2" type="xs:string" use="required"/> <xs:attribute name="attr3" type="xs:string" default="default"/> <xs:attribute name="attr4" type="xs:string" fixed="fixed"/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> </xs:schema> and an instance like: <?xml version="1.0"?> <testElem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="test.xsd" attr2="someValue"/> And I parse it with validation, and then print the information of the attribute declarations of the element PSVI like so: private void printInfo(ElementPSVI psvi) { XSComplexTypeDefinition complexType = (XSComplexTypeDefinition) psvi.getElementDeclaration().getTypeDefinition(); XSObjectList attrUses = complexType.getAttributeUses(); for (int m = 0; m < attrUses.getLength(); m++){ XSAttributeUse attrUse = (XSAttributeUse)attrUses.item(m); XSAttributeDeclaration attrDecl = attrUse.getAttrDeclaration(); if (attrDecl != null) { System.out.println("attrDecl.getName() = " + attrDecl.getName()); System.out.println("attrDecl.getConstraintType() = " + attrDecl.getConstraintType()); System.out.println("attrDecl.getConstraintValue() = " + attrDecl.getConstraintValue()); } } } I get as output: attrDecl.getName() = attr1 attrDecl.getConstraintType() = 0 attrDecl.getConstraintValue() = null attrDecl.getName() = attr2 attrDecl.getConstraintType() = 0 attrDecl.getConstraintValue() = null attrDecl.getName() = attr3 attrDecl.getConstraintType() = 0 attrDecl.getConstraintValue() = null attrDecl.getName() = attr4 attrDecl.getConstraintType() = 0 attrDecl.getConstraintValue() = null I must sort of do it right, because I get the right attributes, but I thought I would get different values for the constraint type, and a constraint value for attributes 3 and 4? Does anybody know if and what I am doing wrong? Kind regards, --Sander. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
