summaryrefslogtreecommitdiff
path: root/tree.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2003-02-05 13:19:53 +0000
committerDaniel Veillard <veillard@src.gnome.org>2003-02-05 13:19:53 +0000
commit71531f33450f9a809eab050104e55c84b77b2a9e (patch)
tree8c469e513e2e72b999e9a64a9f5177b8ace88c4b /tree.c
parentec498e1b33ffef0246296491642facb95b77a743 (diff)
downloadlibxml2-71531f33450f9a809eab050104e55c84b77b2a9e.tar.gz
comments cleanups use xmllint for doing the RelaxNG tests preparing 2.5.2
* HTMLparser.c tree.c xmlIO.c: comments cleanups * Makefile.am: use xmllint for doing the RelaxNG tests * configure.in: preparing 2.5.2 made schemas support default to on instead of off * relaxng.c: removed the verbosity * xmllint.c: added --relaxng option * python/generator.py python/libxml_wrap.h: prepared the integration of the new RelaxNG module and schemas * result/relaxng/*: less verbose output Daniel
Diffstat (limited to 'tree.c')
-rw-r--r--tree.c60
1 files changed, 59 insertions, 1 deletions
diff --git a/tree.c b/tree.c
index 023b8072..61c5759e 100644
--- a/tree.c
+++ b/tree.c
@@ -5201,6 +5201,9 @@ xmlHasNsProp(xmlNodePtr node, const xmlChar *name, const xmlChar *nameSpace) {
* This does the entity substitution.
* This function looks in DTD attribute declaration for #FIXED or
* default declaration values unless DTD use has been turned off.
+ * NOTE: this function acts independantly of namespaces associated
+ * to the attribute. Use xmlGetNsProp() or xmlGetNoNsProp()
+ * for namespace aware processing.
*
* Returns the attribute value or NULL if not found.
* It's up to the caller to free the memory with xmlFree().
@@ -5246,6 +5249,61 @@ xmlGetProp(xmlNodePtr node, const xmlChar *name) {
}
/**
+ * xmlGetNoNsProp:
+ * @node: the node
+ * @name: the attribute name
+ *
+ * Search and get the value of an attribute associated to a node
+ * This does the entity substitution.
+ * This function looks in DTD attribute declaration for #FIXED or
+ * default declaration values unless DTD use has been turned off.
+ * This function is similar to xmlGetProp except it will accept only
+ * an attribute in no namespace.
+ *
+ * Returns the attribute value or NULL if not found.
+ * It's up to the caller to free the memory with xmlFree().
+ */
+xmlChar *
+xmlGetNoNsProp(xmlNodePtr node, const xmlChar *name) {
+ xmlAttrPtr prop;
+ xmlDocPtr doc;
+
+ if ((node == NULL) || (name == NULL)) return(NULL);
+ /*
+ * Check on the properties attached to the node
+ */
+ prop = node->properties;
+ while (prop != NULL) {
+ if ((prop->ns == NULL) && (xmlStrEqual(prop->name, name))) {
+ xmlChar *ret;
+
+ ret = xmlNodeListGetString(node->doc, prop->children, 1);
+ if (ret == NULL) return(xmlStrdup((xmlChar *)""));
+ return(ret);
+ }
+ prop = prop->next;
+ }
+ if (!xmlCheckDTD) return(NULL);
+
+ /*
+ * Check if there is a default declaration in the internal
+ * or external subsets
+ */
+ doc = node->doc;
+ if (doc != NULL) {
+ 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)
+ return(xmlStrdup(attrDecl->defaultValue));
+ }
+ }
+ return(NULL);
+}
+
+/**
* xmlGetNsProp:
* @node: the node
* @name: the attribute name
@@ -5271,7 +5329,7 @@ xmlGetNsProp(xmlNodePtr node, const xmlChar *name, const xmlChar *nameSpace) {
prop = node->properties;
if (nameSpace == NULL)
- return(xmlGetProp(node, name));
+ return(xmlGetNoNsProp(node, name));
while (prop != NULL) {
/*
* One need to have