Update of /cvsroot/monetdb/pathfinder/src/tools/xml-shred
In directory sc8-pr-cvs16:/tmp/cvs-serv18444
Modified Files:
xml-shred.c
Log Message:
We support only names with length <= 32 and content with length <= 32000.
We are working on these restrictions.
Index: xml-shred.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/src/tools/xml-shred/xml-shred.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- xml-shred.c 8 May 2007 08:32:40 -0000 1.2
+++ xml-shred.c 8 May 2007 09:50:31 -0000 1.3
@@ -41,7 +41,9 @@
#include "libxml/parserInternals.h"
#define STACK_MAX 100
-#define PROPSIZE 31999
+#define PROPSIZE 32000
+#define TEXT_SIZE 32000
+#define TAG_SIZE 32
#define MIN(a,b) ((a) < (b) ? (a) : (b))
@@ -218,6 +220,14 @@
static void
start_element (void *ctx, const xmlChar *tagname, const xmlChar **atts)
{
+ /* check if tagname is larger than TAG_SIZE characters */
+ if ( strlen((char*)tagname) > TAG_SIZE) {
+ fprintf(stderr, "We support only tagnames with length <= %i\n",
TAG_SIZE);
+
+ free_hash (hash_table);
+ exit(1);
+ }
+
flush_buffer ();
pre++;
@@ -274,6 +284,21 @@
/* handle attributes as we need for sql generation */
else
while (*atts) {
+ /* check if tagname is larger than TEXT_SIZE characters */
+ if ( strlen((char*)atts[1]) > TEXT_SIZE) {
+ fprintf(stderr, "We support only attribute content with
length <= %i\n", TEXT_SIZE);
+
+ free_hash(hash_table);
+ exit(1);
+ }
+ /* check if tagname is larger than TAG_SIZE characters */
+ if ( strlen((char*)atts[0]) > TAG_SIZE) {
+ fprintf(stderr, "We support only attributes with length
<= %i\n", TAG_SIZE);
+
+ free_hash(hash_table);
+ exit(1);
+ }
+
/* try to find the tagname in the
* hashtable */
name_id = find_element(hash_table, (char*)tagname);
@@ -286,6 +311,7 @@
printf("NOKEY, %i\n", name_id);
hashtable_insert(hash_table, (char*)atts[0], name_id);
+ fprintf (out_attr, "%i, \"%s\"\n", name_id,
strndup((char*)tagname,PROPSIZE));
}
pre++;
@@ -301,7 +327,7 @@
.kind = attr,
.prop = (char*)atts[1]});
atts += 2;
- }
+ }
}
static void
@@ -337,6 +363,14 @@
static void
flush_buffer (void)
{
+ /* check if tagname is larger than TEXT_SIZE characters */
+ if ( strlen((char*)buf) > TEXT_SIZE) {
+ fprintf(stderr, "We support text with length <= %i\n", TEXT_SIZE);
+
+ free_hash(hash_table);
+ exit(1);
+ }
+
if (buf[0]) {
pre++;
rank += 2;
@@ -545,7 +579,7 @@
if (outfile_given) {
out = fopen (outfile, "w");
- snprintf (outfile_atts, FILENAME_MAX, "%s_atts", outfile);
+ snprintf (outfile_atts, FILENAME_MAX, (!sql_atts)?"%s_atts":"%_names",
outfile);
out_attr = fopen (outfile_atts, "w");
if (!out || !out_attr) {
@@ -580,7 +614,7 @@
fprintf (stderr, "tree height was %i\n", max_level);
if (sql_atts)
- fprintf(stderr, "There are %i tagnames and attribute names in the
document\n", --new_nameid());
+ fprintf(stderr, "There are %i tagnames and attribute names in the
document\n", new_nameid());
if (sql_atts)
free_hash(hash_table);
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins