- xmlChar *sortkey = xmlGetProp(n, (xmlChar *) "sortkey");
- num_metadata++;
- if (sortkey && strcmp((const char *) sortkey, "no"))
- num_sortkeys++;
- xmlFree(sortkey);
+ if (n->children) // This is a <metadata> container, look at its contents.
+ {
+ xmlNode *m;
+ for (m = n->children; m; m = m->next)
+ {
+ if (m->type == XML_ELEMENT_NODE &&
+ !strcmp((const char *) m->name, "metadata"))
+ count_metadata(m, &num_metadata, &num_sortkeys);
+ }
+ }
+ else // This is a metadata-element proper, count it right away.
+ count_metadata(n, &num_metadata, &num_sortkeys);