xml_GList*
xml_path_node_to_list (xml_GNode* node, const gchar* xpath, xml_GList* list)
{
if (! node) return list;
if (! xpath) xpath = ".";
if (xpath[0] == '.') xpath++;
if (! xpath[0]) return xml_g_list_prepend (list, node);
___ int depth = 0;
while (xpath[0] == '/')
___ const gchar* end = advance_to_name_end (xpath);
if (end == xpath) return (*end ? list : xml_g_list_prepend (list, node));
___ int len = end-xpath;
if (end[0] == '@' && len == 1 && xpath[0] == '*')
{
const gchar* nxt = end; if ((nxt = attr(node, nxt)))
{ return xml_path_node_to_list (node, nxt, list); } |
} |
___ int serial = 0;
if (end[0] == '[' && g_ascii_isdigit (end[1]))
{
serial = strtol (&end[1], (gchar**) &end, 0);
if (! end[0] == ']') return list; else end++;
} |
if (0) {
if (serial)
g_printerr ("<?:'%.*s[%i]'>", len, xpath, serial);
else
g_printerr ("<?:'%.*s'>", len, xpath);
} |
node = node->children;
for (; node ; node = node->next)
{
if (! node->name) continue; // X(("<%s>", node->name));
if (memcmp (node->name, xpath, len) || node->name[len])
goto match;
found:
if (--serial > 0) continue;
___ const gchar* nxt = end;
if (*nxt == '@') if (!(nxt = attr(node, nxt))) goto deeper;
list = xml_path_node_to_list (node, nxt, list); ____;
if (! serial) return list;
continue;
match:
if (*xpath == '*' && (len == 1 || contains (node, xpath, len)))
goto found;
deeper:
if (depth > 1)
list = xml_path_node_to_list (node, xpath-depth, list);
} |
return list;
____;____;____;____;
} |
|