That's just how it's defined in the schema specification. Also keep in mind that different uses of the same attribute declaration can specify different value constraints so you really do need to walk through the XSAttributeUse to get the "effective value constraint" [1].
If the attribute is locally declared (see the tables [2] under "otherwise if the <attribute> element information item has <complexType> or <attributeGroup> as an ancestor and the ref [attribute] is absent...) the {value constraint} property of the attribute declaration is absent. You can get it from the attribute use by digging into the complex type in the ElementPSVI. Thanks. [1] http://www.w3.org/TR/xmlschema-1/#key-evc [2] http://www.w3.org/TR/xmlschema-1/#declare-attribute Michael Glavassevich XML Parser Development IBM Toronto Lab E-mail: [EMAIL PROTECTED] E-mail: [EMAIL PROTECTED] Dick Deneer <[EMAIL PROTECTED]> wrote on 03/27/2007 03:08:57 PM: > I try to get the fixed value declared in the schema. > I have an XSModel of the schema. > In the standard po.xsd there is a attribute: > <xs:attribute fixed="US" name="country" type="xs:NMTOKEN"/> > > I have to retrieve this value through the XSAttributeUseImpl : > switch (attrUseImpl.getConstraintType()) > { > case DEFAULT_VALUE: > value = attrUseImpl.getConstraintValue(); > break; > case FIXED_VALUE: > value = attrUseImpl.getConstraintValue(); > break; > } > > I also have another xsd where the attributes are declared in an > attributeGroup. > In the attributeGrouup I refer to a schemaVersion attribute: > <xsd:attribute fixed="1.5" name="schemaVersion"/> > <xsd:attributeGroup name="CMDRootAttrGroup"> > <xsd:attribute ref="schemaVersion" use="required"/> > <xsd:attribute ref="startLevel" use="required"/> > </xsd:attributeGroup> > > If I want to retrive the fixed value, I have to use this code: > XSAttributeDecl attrDecl = (XSAttributeDecl) attrUseImpl > .getAttrDeclaration(); > switch (attrDecl.getConstraintType()) > { > case DEFAULT_VALUE: > value = attrDecl.getConstraintValue(); > break; > case FIXED_VALUE: > value = attrDecl.getConstraintValue(); > break; > } > > Is there a reason for this differnence. > I would like to always have the constraint available in the XSAttributeDecl. > Because when I validate the xml instance I can cast an attribute an > AttributePSVI and get the XSAttributeDecl. > But in the case of the po.xsd, I can not get to the fixed value constraint. > > Regards > Dick Deneer --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]