Hello Daniel, hello @all,
well, as the subject says...
The reference for xmlHasProp() (and xmlHasNsProp()) says that
"This function also looks in DTD attribute declaration for
#FIXED or default declaration values unless DTD use has been
turned off."
and i guess this (and *exactly* this) is the correct and
intended behaviour.
But if an attribute isn't specified at the requested node,
xmlHasProp() (resp. xmlHasNsProp()) does a lookup for a DTD
declaration calling xmlGetDtdAttrDesc() (resp.
xmlGetDtdQAttrDesc()) and therefore returns a non-null
attribute declaration if *any* declaration is found (that is,
also for #IMPLIED declarations w/o default).
If i'm right and this isn't the intended behaviour, i'd
suggest the attached patch that provides the documented
behaviour (it's against v2.5.7):
==============================================================
--- tree_orig.c 2003-06-27 16:54:15.000000000 +0200
+++ tree.c 2003-07-07 14:25:38.000000000 +0200
@@ -5556,11 +5556,13 @@
xmlAttributePtr attrDecl;
if (doc->intSubset != NULL) {
attrDecl = xmlGetDtdAttrDesc(doc->intSubset, node->name, name);
if ((attrDecl == NULL) && (doc->extSubset != NULL))
attrDecl = xmlGetDtdAttrDesc(doc->extSubset, node->name, name);
- if (attrDecl != NULL)
+ if ((attrDecl != NULL) && (attrDecl->defaultValue != NULL))
+ /* return attribute declaration only if a default value is given
+ (that includes #FIXED declarations) */
return((xmlAttrPtr) attrDecl);
}
}
return(NULL);
}
@@ -5642,10 +5644,13 @@
}
cur++;
}
xmlFree(nsList);
xmlFree(ename);
+ if ((attrDecl != NULL) && (attrDecl->defaultValue != NULL))
+ /* return attribute declaration only if a default value is given
+ (that includes #FIXED declarations) */
return((xmlAttrPtr) attrDecl);
}
}
return(NULL);
}
==============================================================
Ciao, Markus
Mit freundlichen Gruessen - Kind regards
Markus Keim
________________________Addressed by:________________________
ORDAT GmbH & Co. KG - Serversystems / eCom
Dipl.-Inf. (FH) Markus Keim Fon: +49 (641) 7941-0
Rathenaustr. 1 Fax: +49 (641) 7941-132
35394 Gießen mailto:markus_keim ordat com
See: http://www.ordat.com
_____________________________________________________________
I love deadlines. I like the whooshing sound they make as
they fly by. -- Douglas Adams
Attachment:
tree.diff
Description: Binary data