Esempio n. 1
0
static void yaz_query2xml_attribute_element(const Z_AttributeElement *element,
                                            xmlNodePtr parent)
{
    char formstr[30];
    const char *setname = 0;
    char oid_name_str[OID_STR_MAX];

    if (element->attributeSet)
    {
        setname = yaz_oid_to_string_buf(element->attributeSet,
                                        0, oid_name_str);
    }

    if (element->which == Z_AttributeValue_numeric)
    {
        xmlNodePtr node = xmlNewChild(parent, 0, BAD_CAST "attr", 0);

        if (setname)
            xmlNewProp(node, BAD_CAST "set", BAD_CAST setname);

        assert(*element->attributeType > 0 && *element->attributeType < 20);
        sprintf(formstr, ODR_INT_PRINTF, *element->attributeType);
        xmlNewProp(node, BAD_CAST "type", BAD_CAST formstr);

        sprintf(formstr, ODR_INT_PRINTF, *element->value.numeric);
        xmlNewProp(node, BAD_CAST "value", BAD_CAST formstr);
    }
    else if (element->which == Z_AttributeValue_complex)
    {
        int i;
        for (i = 0; i<element->value.complex->num_list; i++)
        {
            xmlNodePtr node = xmlNewChild(parent, 0, BAD_CAST "attr", 0);

            if (setname)
                xmlNewProp(node, BAD_CAST "set", BAD_CAST setname);

            sprintf(formstr, ODR_INT_PRINTF, *element->attributeType);
            xmlNewProp(node, BAD_CAST "type", BAD_CAST formstr);

            if (element->value.complex->list[i]->which ==
                Z_StringOrNumeric_string)
            {
                xmlNewProp(node, BAD_CAST "value", BAD_CAST
                           element->value.complex->list[i]->u.string);
            }
            else if (element->value.complex->list[i]->which ==
                     Z_StringOrNumeric_numeric)
            {
                sprintf(formstr, ODR_INT_PRINTF,
                        *element->value.complex->list[i]->u.numeric);
                xmlNewProp(node, BAD_CAST "value", BAD_CAST formstr);
            }
        }
    }
}
Esempio n. 2
0
static xmlNodePtr yaz_query2xml_rpn(const Z_RPNQuery *rpn, xmlNodePtr parent)
{
    if (rpn->attributeSetId)
    {
        char oid_name_str[OID_STR_MAX];
        const char *setname = yaz_oid_to_string_buf(rpn->attributeSetId,
                                                    0, oid_name_str);
        if (setname)
            xmlNewProp(parent, BAD_CAST "set", BAD_CAST setname);
    }
    return yaz_query2xml_rpnstructure(rpn->RPNStructure, parent);
}
Esempio n. 3
0
void yaz_rpnquery_to_wrbuf(WRBUF b, const Z_RPNQuery *rpn)
{
    if (rpn->attributeSetId)
    {
        char oid_name_str[OID_STR_MAX];
        const char *oid_name = yaz_oid_to_string_buf(rpn->attributeSetId,
                                                     0, oid_name_str);
        if (oid_name)
            wrbuf_printf(b, "@attrset %s ", oid_name);
    }
    yaz_rpnstructure_to_wrbuf(b, rpn->RPNStructure);
    wrbuf_chop_right(b);
}
Esempio n. 4
0
static void yaz_attribute_element_to_wrbuf(WRBUF b,
                                           const Z_AttributeElement *element)
{
    int i;
    char oid_name_str[OID_STR_MAX];
    const char *setname = 0;
    char *sep = " "; /* optional space after attrset name */
    if (element->attributeSet)
    {
        setname = yaz_oid_to_string_buf(element->attributeSet, 
                                        0, oid_name_str);
    }
    if (!setname)
    {
        setname = "";
        sep = "";
    }
    switch (element->which) 
    {
    case Z_AttributeValue_numeric:
        wrbuf_printf(b,"@attr %s%s" ODR_INT_PRINTF "=" ODR_INT_PRINTF " ",
                     setname, sep,
                     *element->attributeType, *element->value.numeric);
        break;
    case Z_AttributeValue_complex:
        wrbuf_printf(b,"@attr %s%s\""ODR_INT_PRINTF "=", setname, sep,
                     *element->attributeType);
        for (i = 0; i<element->value.complex->num_list; i++)
        {
            if (i)
                wrbuf_printf(b,",");
            if (element->value.complex->list[i]->which ==
                Z_StringOrNumeric_string)
                wrbuf_printf (b, "%s",
                              element->value.complex->list[i]->u.string);
            else if (element->value.complex->list[i]->which ==
                     Z_StringOrNumeric_numeric)
                wrbuf_printf (b, ODR_INT_PRINTF, 
                              *element->value.complex->list[i]->u.numeric);
        }
        wrbuf_printf(b, "\" ");
        break;
    default:
        wrbuf_printf (b, "@attr 1=unknown ");
    }
}
Esempio n. 5
0
static void yaz_attribute_element_to_wrbuf(WRBUF b,
                                           const Z_AttributeElement *element)
{
    int i;

    wrbuf_puts(b, "@attr ");
    if (element->attributeSet)
    {
        char oid_name_str[OID_STR_MAX];
        const char *setname = yaz_oid_to_string_buf(element->attributeSet,
                                                    0, oid_name_str);
        if (setname)
        {
            wrbuf_puts(b, setname);
            wrbuf_puts(b, " ");
        }
    }
    wrbuf_printf(b, ODR_INT_PRINTF "=", *element->attributeType);
    switch (element->which)
    {
    case Z_AttributeValue_numeric:
        wrbuf_printf(b, ODR_INT_PRINTF, *element->value.numeric);
        break;
    case Z_AttributeValue_complex:
        for (i = 0; i < element->value.complex->num_list; i++)
        {
            if (i)
                wrbuf_puts(b, ",");
            if (element->value.complex->list[i]->which ==
                Z_StringOrNumeric_string)
                wrbuf_puts(b, element->value.complex->list[i]->u.string);
            else if (element->value.complex->list[i]->which ==
                     Z_StringOrNumeric_numeric)
                wrbuf_printf(b, ODR_INT_PRINTF,
                             *element->value.complex->list[i]->u.numeric);
        }
        break;
    default:
        wrbuf_puts(b, "@attr 1=unknown");
    }
    wrbuf_puts(b, " ");
}
Esempio n. 6
0
static void display_grs1(WRBUF w, Z_GenericRecord *r, int level)
{
    int i;

    if (!r)
    {
        return;
    }
    for (i = 0; i < r->num_elements; i++)
    {
        Z_TaggedElement *t;

        wrbuf_printf(w, "%*s", level * 4, "");
        t = r->elements[i];
        wrbuf_printf(w, "(");
        if (t->tagType)
            wrbuf_printf(w, ODR_INT_PRINTF, *t->tagType);
        else
            wrbuf_printf(w, "?,");
        if (t->tagValue->which == Z_StringOrNumeric_numeric)
            wrbuf_printf(w, ODR_INT_PRINTF ") ", *t->tagValue->u.numeric);
        else
            wrbuf_printf(w, "%s) ", t->tagValue->u.string);
        if (t->content->which == Z_ElementData_subtree)
        {
            if (!t->content->u.subtree)
                printf (" (no subtree)\n");
            else
            {
                wrbuf_printf(w, "\n");
                display_grs1(w, t->content->u.subtree, level+1);
            }
        }
        else if (t->content->which == Z_ElementData_string)
        {
            wrbuf_puts(w, t->content->u.string);
            wrbuf_puts(w, "\n");
        }
        else if (t->content->which == Z_ElementData_numeric)
        {
            wrbuf_printf(w, ODR_INT_PRINTF "\n", *t->content->u.numeric);
        }
        else if (t->content->which == Z_ElementData_oid)
        {
            Odr_oid *ip = t->content->u.oid;

            if (ip)
            {
                char oid_name_str[OID_STR_MAX];
                oid_class oclass;
                const char *oid_name 
                    = yaz_oid_to_string_buf(ip, &oclass, oid_name_str);
            
                if (oid_name)
                    wrbuf_printf(w, "OID: %s\n", oid_name);
            }
        }
        else if (t->content->which == Z_ElementData_noDataRequested)
            wrbuf_printf(w, "[No data requested]\n");
        else if (t->content->which == Z_ElementData_elementEmpty)
            wrbuf_printf(w, "[Element empty]\n");
        else if (t->content->which == Z_ElementData_elementNotThere)
            wrbuf_printf(w, "[Element not there]\n");
        else if (t->content->which == Z_ElementData_date)
            wrbuf_printf(w, "Date: %s\n", t->content->u.date);
        else if (t->content->which == Z_ElementData_ext)
        {
            printf ("External\n");
            /* we cannot print externals here. Srry */
        } 
        else
            wrbuf_printf(w, "? type = %d\n",t->content->which);
        if (t->appliedVariant)
            display_variant(w, t->appliedVariant, level+1);
        if (t->metaData && t->metaData->supportedVariants)
        {
            int c;

            wrbuf_printf(w, "%*s---- variant list\n", (level+1)*4, "");
            for (c = 0; c < t->metaData->num_supportedVariants; c++)
            {
                wrbuf_printf(w, "%*svariant #%d\n", (level+1)*4, "", c);
                display_variant(w, t->metaData->supportedVariants[c], level+2);
            }
        }
    }
}