XML reader for data1 (EXPAT)
[yaz-moved-to-github.git] / retrieval / d1_grs.c
index a222aee..774b188 100644 (file)
@@ -4,7 +4,19 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: d1_grs.c,v $
- * Revision 1.16  1999-08-27 09:40:32  adam
+ * Revision 1.20  2002-05-13 14:13:37  adam
+ * XML reader for data1 (EXPAT)
+ *
+ * Revision 1.19  2002/04/15 09:06:30  adam
+ * Fix explain tags for XML writer
+ *
+ * Revision 1.18  2002/04/12 14:40:07  adam
+ * GRS-1 writer accepts non-abs
+ *
+ * Revision 1.17  1999/11/30 13:47:12  adam
+ * Improved installation. Moved header files to include/yaz.
+ *
+ * Revision 1.16  1999/08/27 09:40:32  adam
  * Renamed logf function to yaz_log. Removed VC++ project files.
  *
  * Revision 1.15  1999/03/31 11:18:25  adam
 #include <assert.h>
 #include <stdlib.h>
 
-#include <proto.h>
-#include <log.h>
-
-#include <data1.h>
+#include <yaz/proto.h>
+#include <yaz/log.h>
+#include <yaz/data1.h>
 
 #define D1_VARIANTARRAY 20 /* fixed max length on sup'd variant-list. Lazy me */
 
@@ -196,7 +207,7 @@ static Z_ElementData *nodetoelementdata(data1_handle dh, data1_node *n,
                break;
            case DATA1I_text:
                toget = n->u.data.len;
-               if (p->u.tag.get_bytes > 0 && p->u.tag.get_bytes < toget)
+               if (p && p->u.tag.get_bytes > 0 && p->u.tag.get_bytes < toget)
                    toget = p->u.tag.get_bytes;
                res->which = Z_ElementData_string;
                res->u.string = (char *)odr_malloc(o, toget+1);
@@ -247,7 +258,8 @@ static Z_TaggedElement *nodetotaggedelement(data1_handle dh, data1_node *n,
      */
     else if (n->which == DATA1N_data || n->which == DATA1N_variant)
     {
-       if (!(tag = data1_gettagbyname (dh, n->root->u.root.absyn->tagset,
+       if (n->root->u.root.absyn &&
+            !(tag = data1_gettagbyname (dh, n->root->u.root.absyn->tagset,
                                        "wellKnown")))
        {
            yaz_log(LOG_WARN, "Unable to locate tag for 'wellKnown'");
@@ -280,7 +292,7 @@ static Z_TaggedElement *nodetotaggedelement(data1_handle dh, data1_node *n,
        else if (tag)                    
            tagstr = tag->value.string;  /* no take from well-known */
        else
-           tagstr = "?";                /* no tag at all! */
+           tagstr = "???";                /* no tag at all! */
        res->tagValue->which = Z_StringOrNumeric_string;
        res->tagValue->u.string = odr_strdup(o, tagstr);
     }