+ xpdone = 0;
+ flen = 0;
+
+ /* we have to fetch the whole path to the data tag */
+ for (nn = n; nn; nn = nn->parent) {
+ if (nn->which == DATA1N_tag) {
+ size_t tlen = strlen(nn->u.tag.tag);
+ if (tlen + flen > (sizeof(tag_path_full)-2)) return;
+ memcpy (tag_path_full + flen, nn->u.tag.tag, tlen);
+ flen += tlen;
+ tag_path_full[flen++] = '/';
+ }
+ else if (nn->which == DATA1N_root) break;
+ }
+
+ tag_path_full[flen] = 0;
+
+ /* If we have a matching termlist... */
+ if (n->root->u.root.absyn &&
+ (tl = xpath_termlist_by_tagpath(tag_path_full, n)))
+ {
+ for (; tl; tl = tl->next)
+ {
+ /* need to copy recword because it may be changed */
+ RecWord wrd_tl;
+ wrd->reg_type = *tl->structure;
+ /* this is the ! case, so structure is for the xpath index */
+ memcpy (&wrd_tl, wrd, sizeof(*wrd));
+ if (tl->source)
+ sp_parse(n, &wrd_tl, tl->source);
+ if (!tl->att) {
+ wrd_tl.attrSet = VAL_IDXPATH;
+ wrd_tl.attrUse = use;
+ if (p->flagShowRecords)
+ {
+ int i;
+ printf("%*sXPath index", (level + 1) * 4, "");
+ printf (" XData:\"");
+ for (i = 0; i<wrd_tl.length && i < 40; i++)
+ fputc (wrd_tl.string[i], stdout);
+ fputc ('"', stdout);
+ if (wrd_tl.length > 40)
+ printf (" ...");
+ fputc ('\n', stdout);
+ }
+ else
+ (*p->tokenAdd)(&wrd_tl);
+ xpdone = 1;
+ } else {
+ /* this is just the old fashioned attribute based index */
+ wrd_tl.attrSet = (int) (tl->att->parent->reference);
+ wrd_tl.attrUse = tl->att->locals->local;
+ if (p->flagShowRecords)
+ {
+ int i;
+ printf("%*sIdx: [%s]", (level + 1) * 4, "",
+ tl->structure);
+ printf("%s:%s [%d] %s",
+ tl->att->parent->name,
+ tl->att->name, tl->att->value,
+ tl->source);
+ printf (" XData:\"");
+ for (i = 0; i<wrd_tl.length && i < 40; i++)
+ fputc (wrd_tl.string[i], stdout);
+ fputc ('"', stdout);
+ if (wrd_tl.length > 40)
+ printf (" ...");
+ fputc ('\n', stdout);
+ }
+ else
+ (*p->tokenAdd)(&wrd_tl);
+ }
+ }
+ }
+ /* xpath indexing is done, if there was no termlist given,
+ or no ! in the termlist, and default indexing is enabled... */
+ if (!p->flagShowRecords && !xpdone && !termlist_only)
+ {
+ wrd->attrSet = VAL_IDXPATH;
+ wrd->attrUse = use;
+ wrd->reg_type = 'w';
+ (*p->tokenAdd)(wrd);
+ }