* xmlSchemaCheckAttrUsePropsCorrect: * @ctxt: a parser context * @use: an attribute use * * Schema Component Constraint: * Attribute Use Correct (au-props-correct) * */
| 20138 | * |
| 20139 | */ |
| 20140 | static int |
| 20141 | xmlSchemaCheckAttrUsePropsCorrect(xmlSchemaParserCtxtPtr ctxt, |
| 20142 | xmlSchemaAttributeUsePtr use) |
| 20143 | { |
| 20144 | if ((ctxt == NULL) || (use == NULL)) |
| 20145 | return(-1); |
| 20146 | if ((use->defValue == NULL) || (WXS_ATTRUSE_DECL(use) == NULL) || |
| 20147 | ((WXS_ATTRUSE_DECL(use))->type != XML_SCHEMA_TYPE_ATTRIBUTE)) |
| 20148 | return(0); |
| 20149 | |
| 20150 | /* |
| 20151 | * SPEC au-props-correct (1) |
| 20152 | * "The values of the properties of an attribute use must be as |
| 20153 | * described in the property tableau in The Attribute Use Schema |
| 20154 | * Component ($3.5.1), modulo the impact of Missing |
| 20155 | * Sub-components ($5.3)." |
| 20156 | */ |
| 20157 | |
| 20158 | if (((WXS_ATTRUSE_DECL(use))->defValue != NULL) && |
| 20159 | ((WXS_ATTRUSE_DECL(use))->flags & XML_SCHEMAS_ATTR_FIXED) && |
| 20160 | ((use->flags & XML_SCHEMA_ATTR_USE_FIXED) == 0)) |
| 20161 | { |
| 20162 | xmlSchemaPCustomErr(ctxt, |
| 20163 | XML_SCHEMAP_AU_PROPS_CORRECT_2, |
| 20164 | WXS_BASIC_CAST use, NULL, |
| 20165 | "The attribute declaration has a 'fixed' value constraint " |
| 20166 | ", thus the attribute use must also have a 'fixed' value " |
| 20167 | "constraint", |
| 20168 | NULL); |
| 20169 | return(ctxt->err); |
| 20170 | } |
| 20171 | /* |
| 20172 | * Compute and check the value constraint's value. |
| 20173 | */ |
| 20174 | if ((use->defVal != NULL) && (WXS_ATTRUSE_TYPEDEF(use) != NULL)) { |
| 20175 | int ret; |
| 20176 | /* |
| 20177 | * TODO: The spec seems to be missing a check of the |
| 20178 | * value constraint of the attribute use. We will do it here. |
| 20179 | */ |
| 20180 | /* |
| 20181 | * SPEC a-props-correct (3) |
| 20182 | */ |
| 20183 | if (xmlSchemaIsDerivedFromBuiltInType( |
| 20184 | WXS_ATTRUSE_TYPEDEF(use), XML_SCHEMAS_ID)) |
| 20185 | { |
| 20186 | xmlSchemaCustomErr(ACTXT_CAST ctxt, |
| 20187 | XML_SCHEMAP_AU_PROPS_CORRECT, |
| 20188 | NULL, WXS_BASIC_CAST use, |
| 20189 | "Value constraints are not allowed if the type definition " |
| 20190 | "is or is derived from xs:ID", |
| 20191 | NULL, NULL); |
| 20192 | return(ctxt->err); |
| 20193 | } |
| 20194 | |
| 20195 | ret = xmlSchemaVCheckCVCSimpleType(ACTXT_CAST ctxt, |
| 20196 | use->node, WXS_ATTRUSE_TYPEDEF(use), |
| 20197 | use->defValue, &(use->defVal), |
no test coverage detected