32 #include <yaz/proto.h>
33 #include <yaz/oid_db.h>
37 Z_Espec1 *e,
int i, Z_ETagUnit **t,
43 Z_ETagUnit **t,
int num)
53 static Z_Triple *
find_triple(Z_Variant *var,
const Odr_oid *universal_oid,
54 const Odr_oid *var_oid,
int zclass,
int type)
58 for (i = 0; i < var->num_triples; i++)
60 const Odr_oid *cur_oid = var->triples[i]->variantSetId;
62 cur_oid = var->globalVariantSetId;
63 if (cur_oid && var_oid
64 && !oid_oidcmp(var_oid, cur_oid) && *var->triples[i]->type == type)
65 return var->triples[i];
71 int get_bytes, Z_Variant *vreq,
int select_flag)
87 n->
u.
tag.node_selected = select_flag;
88 n->
u.
tag.make_variantlist = make_variantlist;
89 n->
u.
tag.no_data_requested = no_data;
90 n->
u.
tag.get_bytes = get_bytes;
98 c->
u.
tag.node_selected = select_flag;
99 c->
u.
tag.make_variantlist = make_variantlist;
100 c->
u.
tag.no_data_requested = no_data;
101 c->
u.
tag.get_bytes = get_bytes;
103 mark_subtree(c, make_variantlist, no_data, get_bytes, vreq,
110 const Odr_oid *def_oid,
127 if ((*c)->u.variant.type->zclass->zclass == 4 &&
128 (*c)->u.variant.type->type == 1)
130 if ((r =
find_triple(vreq, def_oid, var_oid, 4, 1)) &&
131 (r->which == Z_Triple_internationalString))
133 const char *string_value =
134 r->value.internationalString;
135 if (strcmp ((*c)->u.variant.value, string_value))
161 if (c->
u.
tag.element)
162 tag = c->
u.
tag.element->tag;
165 sscanf(spec,
"%63[^[]%c%63[^]]", elem, &dummy_ch, predicate);
169 if (*predicate ==
'\0')
171 else if (sscanf(predicate,
"@%63[^=]=%63s", attr, value) == 2)
174 for (xa = c->
u.
tag.attributes; xa; xa = xa->
next)
175 if (!strcmp(xa->
name, attr) &&
176 !strcmp(xa->
value, value))
180 else if (sscanf(predicate,
"@%63s", attr) == 1)
183 for (xa = c->
u.
tag.attributes; xa; xa = xa->
next)
184 if (!strcmp(xa->
name, attr))
189 yaz_log(YLOG_WARN,
"Bad simpleelement component: '%s'", spec);
196 Z_ETagUnit **t,
int num,
199 int counter = 0, hits = 0;
202 Z_Occurrences *occur;
211 if (tp->which == Z_ETagUnit_specificTag)
213 Z_SpecificTag *want = tp->u.specificTag;
214 occur = want->occurrences;
215 if (c->
u.
tag.element)
216 tag = c->
u.
tag.element->tag;
220 if (want->tagValue->which == Z_StringOrNumeric_numeric)
227 else if (want->tagValue->which == Z_StringOrNumeric_string)
229 const char *str_val = want->tagValue->u.string;
230 if (str_val[0] ==
'!')
248 yaz_log(YLOG_WARN,
"Bad SpecificTag type: %d",
249 want->tagValue->which);
253 else if (tp->which == Z_ETagUnit_wildThing)
254 occur = tp->u.wildThing;
261 if (occur && occur->which == Z_Occurrences_last)
263 yaz_log(YLOG_WARN,
"Can't do occurrences=last (yet)");
266 if (!occur || occur->which == Z_Occurrences_all ||
267 (occur->which == Z_Occurrences_values && counter >=
268 *occur->u.values->start))
272 c->
u.
tag.node_selected = select_flag;
279 int show_variantlist = 0;
284 e->elements[i]->u.simpleElement->variantRequest;
286 const Odr_oid *var_oid = yaz_oid_varset_variant_1;
288 vreq = e->defaultVariantRequest;
299 show_variantlist = 1;
310 if (r->which == Z_Triple_integer)
311 get_bytes = *r->value.integer;
313 if (!show_variantlist)
317 mark_subtree(c, show_variantlist, no_data, get_bytes, vreq,
324 if (!occur || (occur->which == Z_Occurrences_values &&
325 (!occur->u.values->howMany ||
326 counter - *occur->u.values->start >=
327 *occur->u.values->howMany - 1)))
336 int i, Z_ETagUnit **t,
int num,
int select_flag)
344 case Z_ETagUnit_wildThing:
345 case Z_ETagUnit_specificTag:
348 case Z_ETagUnit_wildPath:
362 n->
u.
tag.node_selected = 1;
364 for (i = 0; i < e->num_elements; i++)
366 if (e->elements[i]->which != Z_ERequest_simpleElement)
369 e->elements[i]->
u.simpleElement->path->tags,
370 e->elements[i]->
u.simpleElement->path->num_tags,
static int match_children_here(data1_handle dh, data1_node *n, Z_Espec1 *e, int i, Z_ETagUnit **t, int num, int select_flag)
static void match_triple(data1_handle dh, Z_Variant *vreq, const Odr_oid *def_oid, const Odr_oid *var_oid, data1_node *n)
static int match_children(data1_handle dh, data1_node *n, Z_Espec1 *e, int i, Z_ETagUnit **t, int num, int select_flag)
static int match_node_and_attr(data1_node *c, const char *spec)
static int match_children_wildpath(data1_handle dh, data1_node *n, Z_Espec1 *e, int i, Z_ETagUnit **t, int num)
static Z_Triple * find_triple(Z_Variant *var, const Odr_oid *universal_oid, const Odr_oid *var_oid, int zclass, int type)
int data1_doespec1(data1_handle dh, data1_node *n, Z_Espec1 *e)
static void mark_subtree(data1_node *n, int make_variantlist, int no_data, int get_bytes, Z_Variant *vreq, int select_flag)
#define data1_matchstr(s1, s2)
data1_node * data1_get_root_tag(data1_handle dh, data1_node *n)
struct data1_node * child
struct data1_tagset * tagset
union data1_tag::@1 value
struct data1_xattr * next