| 3968 | */ |
| 3969 | |
| 3970 | int |
| 3971 | xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc, |
| 3972 | xmlAttributePtr attr) { |
| 3973 | int ret = 1; |
| 3974 | int val; |
| 3975 | CHECK_DTD; |
| 3976 | if(attr == NULL) return(1); |
| 3977 | |
| 3978 | /* Attribute Default Legal */ |
| 3979 | /* Enumeration */ |
| 3980 | if (attr->defaultValue != NULL) { |
| 3981 | val = xmlValidateAttributeValueInternal(doc, attr->atype, |
| 3982 | attr->defaultValue); |
| 3983 | if (val == 0) { |
| 3984 | xmlErrValidNode(ctxt, (xmlNodePtr) attr, XML_DTD_ATTRIBUTE_DEFAULT, |
| 3985 | "Syntax of default value for attribute %s of %s is not valid\n", |
| 3986 | attr->name, attr->elem, NULL); |
| 3987 | } |
| 3988 | ret &= val; |
| 3989 | } |
| 3990 | |
| 3991 | /* ID Attribute Default */ |
| 3992 | if ((attr->atype == XML_ATTRIBUTE_ID)&& |
| 3993 | (attr->def != XML_ATTRIBUTE_IMPLIED) && |
| 3994 | (attr->def != XML_ATTRIBUTE_REQUIRED)) { |
| 3995 | xmlErrValidNode(ctxt, (xmlNodePtr) attr, XML_DTD_ID_FIXED, |
| 3996 | "ID attribute %s of %s is not valid must be #IMPLIED or #REQUIRED\n", |
| 3997 | attr->name, attr->elem, NULL); |
| 3998 | ret = 0; |
| 3999 | } |
| 4000 | |
| 4001 | /* One ID per Element Type */ |
| 4002 | if (attr->atype == XML_ATTRIBUTE_ID) { |
| 4003 | xmlElementPtr elem = NULL; |
| 4004 | const xmlChar *elemLocalName; |
| 4005 | xmlChar *elemPrefix; |
| 4006 | int nbId; |
| 4007 | |
| 4008 | elemLocalName = xmlSplitQName4(attr->elem, &elemPrefix); |
| 4009 | if (elemLocalName == NULL) { |
| 4010 | xmlVErrMemory(ctxt); |
| 4011 | return(0); |
| 4012 | } |
| 4013 | |
| 4014 | /* the trick is that we parse DtD as their own internal subset */ |
| 4015 | if (doc->intSubset != NULL) |
| 4016 | elem = xmlHashLookup2(doc->intSubset->elements, |
| 4017 | elemLocalName, elemPrefix); |
| 4018 | if (elem != NULL) { |
| 4019 | nbId = xmlScanIDAttributeDecl(ctxt, elem, 0); |
| 4020 | } else { |
| 4021 | xmlAttributeTablePtr table; |
| 4022 | |
| 4023 | /* |
| 4024 | * The attribute may be declared in the internal subset and the |
| 4025 | * element in the external subset. |
| 4026 | */ |
| 4027 | nbId = 0; |
no test coverage detected