* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*
- * $Id: data1.h,v 1.14 2002-07-25 12:52:53 adam Exp $
+ * $Id: data1.h,v 1.15 2002-07-29 20:04:08 adam Exp $
*/
#ifndef DATA1_H
} data1_node;
YAZ_EXPORT data1_handle data1_create (void);
+
+#define DATA1_FLAG_XML 1
+YAZ_EXPORT data1_handle data1_createx (int flags);
+
YAZ_EXPORT void data1_destroy(data1_handle dh);
YAZ_EXPORT data1_node *get_parent_tag(data1_handle dh, data1_node *n);
YAZ_EXPORT data1_node *data1_read_node(data1_handle dh, const char **buf,
YAZ_EXPORT const char *data1_get_encoding (data1_handle dh, data1_node *n);
+YAZ_EXPORT int data1_is_xmlmode(data1_handle dh);
+
YAZ_END_CDECL
#endif
* Copyright (c) 1995-2002, Index Data.
* See the file LICENSE for details.
*
- * $Id: d1_handle.c,v 1.8 2002-04-05 12:46:07 adam Exp $
+ * $Id: d1_handle.c,v 1.9 2002-07-29 20:04:08 adam Exp $
*/
#include <stdio.h>
int map_len;
NMEM mem;
+ int flags;
};
data1_handle data1_create (void)
{
+ return data1_createx(0);
+}
+
+data1_handle data1_createx (int flags)
+{
data1_handle p = (data1_handle)xmalloc (sizeof(*p));
if (!p)
return NULL;
p->absyn_cache = NULL;
p->attset_cache = NULL;
p->mem = nmem_create ();
+ p->flags = flags;
return p;
}
const char *root = data1_get_tabroot(dh);
return yaz_fopen (path, file, "r", root);
}
+
+int data1_is_xmlmode(data1_handle dh)
+{
+ return dh->flags & DATA1_FLAG_XML;
+}
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: d1_map.c,v 1.23 2002-07-03 14:09:34 adam Exp $
+ * $Id: d1_map.c,v 1.24 2002-07-29 20:04:08 adam Exp $
*/
#include <stdio.h>
yaz_log(LOG_WARN, "%s: Failed to load target absyn '%s'",
map->name, map->target_absyn_name);
}
- n = n->child;
- if (!n)
- return 0;
- res1 = data1_mk_tag (dh, m, map->target_absyn_name, 0, res);
+ if (data1_is_xmlmode(dh))
+ {
+ n = n->child;
+ if (!n)
+ return 0;
+ res1 = data1_mk_tag (dh, m, map->target_absyn_name, 0, res);
+ }
+ else
+ res1 = res;
if (map_children(dh, n, map, res1, m) < 0)
{
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: d1_read.c,v 1.46 2002-07-25 12:52:53 adam Exp $
+ * $Id: d1_read.c,v 1.47 2002-07-29 20:04:08 adam Exp $
*/
#include <assert.h>
{
if (!n)
return 0;
- n = n->child;
- while (n && n->which != DATA1N_tag)
- n = n->next;
+ if (data1_is_xmlmode(dh))
+ {
+ n = n->child;
+ while (n && n->which != DATA1N_tag)
+ n = n->next;
+ }
return n;
}
break;
}
}
- if (level <= 1)
- return d1_stack[0];
+ if (data1_is_xmlmode(dh))
+ {
+ if (level <= 1)
+ return d1_stack[0];
+ }
+ else
+ {
+ if (level <= 0)
+ return d1_stack[0];
+ }
continue;
}
else if (!strcmp(tag, "var"))
if (level == 0)
{
parent = data1_mk_root (dh, m, tag);
- d1_stack[level++] = parent;
+ res = d1_stack[level] = parent;
+
+ if (data1_is_xmlmode(dh))
+ {
+ level++;
+ res = data1_mk_tag (dh, m, tag, 0 /* attr */, parent);
+ res->u.tag.attributes = xattr;
+ }
+ }
+ else
+ {
+ res = data1_mk_tag (dh, m, tag, 0 /* attr */, parent);
+ res->u.tag.attributes = xattr;
}
- res = data1_mk_tag (dh, m, tag, 0 /* attr */, parent);
- res->u.tag.attributes = xattr;
}
d1_stack[level] = res;
d1_stack[level+1] = 0;
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: d1_write.c,v 1.15 2002-07-25 12:52:53 adam Exp $
+ * $Id: d1_write.c,v 1.16 2002-07-29 20:04:08 adam Exp $
*/
#include <string.h>
wrbuf_rewind(b);
+ if (!data1_is_xmlmode (dh))
+ {
+ wrbuf_puts (b, "<");
+ wrbuf_puts (b, n->u.root.type);
+ wrbuf_puts (b, ">\n");
+ }
if (nodetoidsgml(n, select, b, 0, 0 /* no pretty format */))
return 0;
+ if (!data1_is_xmlmode (dh))
+ {
+ wrbuf_puts (b, "</");
+ wrbuf_puts (b, n->u.root.type);
+ wrbuf_puts (b, ">\n");
+ }
*len = wrbuf_len(b);
return wrbuf_buf(b);
}