Update of /cvsroot/monetdb/MonetDB5/src/modules/mal
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv23755
Modified Files:
batxml.mx
Log Message:
XMLoptions requires some more study of the standard to get the semantics
right upon code generation.
Index: batxml.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/modules/mal/batxml.mx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- batxml.mx 25 Aug 2007 08:59:27 -0000 1.9
+++ batxml.mx 25 Aug 2007 13:38:02 -0000 1.10
@@ -82,6 +82,11 @@
attributes and a sequence of xml elements. The name space and
the attributes may be left unspecified.";
+command xml.options(tag:str, option:str,left:bat[:oid,:xml]):bat[:oid,:xml]
+address BATXMLoptions
+comment "Create the components including NULL conversions";
+
+
command xml.element(name:str, ns:xml, attr:xml,
s:bat[:oid,:xml]):bat[:oid,:xml]
address BATXMLelement
comment "The basic building block for XML elements are namespaces,
@@ -92,10 +97,6 @@
address BATXMLconcat
comment "Concatenate the xml values";
-command xml.options(option:str,left:bat[:oid,:xml]):bat[:oid,:xml]
-address BATXMLoptions
-comment "Handle the NULLs";
-
pattern xml.forest(val:bat[:oid,:xml]...):bat[:oid,:xml]
address BATXMLforest
comment "Construct an element list");
@@ -149,7 +150,7 @@
batxml_export str BATXMLstr2xml(int *x, int *s);
batxml_export str BATXMLisdocument(int *x, int *s);
batxml_export str BATXMLtag(int *x, str *name, int *s);
-batxml_export str BATXMLoptions(int *x, str *name, int *s);
+batxml_export str BATXMLoptions(int *x, str *name, str *options, int *s);
batxml_export str BATXMLcomment(int *x, int *s);
batxml_export str BATXMLparse(int *x, int *s);
batxml_export str BATXMLxquery(int *x, int *s, str *expr);
@@ -277,7 +278,7 @@
BBPreleaseref(b->batCacheid);
BBPunfix(bn->batCacheid);
GDKfree(buf);
- throw(MAL, "batstr.comment", "bunins failed");
+ throw(MAL, "batstr.xml", "bunins failed");
}
str
@@ -318,47 +319,62 @@
BBPreleaseref(b->batCacheid);
BBPunfix(bn->batCacheid);
GDKfree(buf);
- throw(MAL, "batstr.comment", "bunins failed");
+ throw(MAL, "batstr.tag", "bunins failed");
}
@-
The standard supports specific mappings for
NULL values,i.e. {null,abscent,empty,nil,niloncontent)
+in the context of an element and forest construction.
+The standard should be studied in more detail, because
+the syntax(rules) seem ambiguous.
+It applies to all components of an element or their
+concatenation.
+
+For the time being, the variaton on XMLtag seems the
+most reasonable interpretation.
@c
str
-BATXMLoptions(int *ret, str *options, int *bid)
+BATXMLoptions(int *ret, str *name, str *options, int *bid)
{
BAT *b,*bn;
BUN p,q;
int xx;
str buf= GDKmalloc(BUFSIZ);
- int abscent=0,size= BUFSIZ;
+ str val= GDKmalloc(BUFSIZ);
+ int size= BUFSIZ, len=strlen(*name);
- prepareOperand(b,bid,"tag");
- prepareResult(bn,b,TYPE_str,"tag");
+ prepareOperand(b,bid,"options");
+ prepareResult(bn,b,TYPE_str,"options");
if( strcmp(*options,"abscent")==0)
- abscent=1;
+ buf[0]=0;
else
if( strcmp(*options,"empty")==0)
- buf[0]=0;
+ snprintf(buf,size,"<%s></%s>",*name,*name);
else
if( strcmp(*options,"null")==0)
snprintf(buf,size,"null");
else
+ if( strcmp(*options,"nil")==0)
+ snprintf(buf,size,"nil");
+ else
+ /*if( strcmp(*options,"niloncontent")==0) */
throw(MAL,"xml.options","Not yet implemented");
+ snprintf(val,size,"<%s>",*name);
BATloopFast(b,p,q,xx){
ptr h= BUNhead(b,p);
str t= (str) BUNtail(b,p);
-
- if( !strNil(t)){
- bunfastins(bn,h,t);
- continue;
+ if(strNil(t)){
+ bunfastins(bn,h,buf);
+ } else {
+ if( (int)strlen(t)> size-2*len-6){
+ size+= strlen(t);
+ val= (char*) GDKrealloc(val, size+strlen(t));
+ }
+ snprintf(val+len+2,size-len,"%s</%s>",t,*name);
+ bunfastins(bn,h, val);
}
-
- if( abscent)
- continue;
- bunfastins(bn,h,buf);
}
GDKfree(buf);
finalizeResult(ret,bn,b);
@@ -367,7 +383,7 @@
BBPreleaseref(b->batCacheid);
BBPunfix(bn->batCacheid);
GDKfree(buf);
- throw(MAL, "batstr.comment", "bunins failed");
+ throw(MAL, "batxml.options", "bunins failed");
}
str
@@ -464,7 +480,7 @@
BBPreleaseref(b->batCacheid);
BBPunfix(bn->batCacheid);
GDKfree(buf);
- throw(MAL, "batstr.comment", "bunins failed");
+ throw(MAL, "batstr.root", "bunins failed");
}
str
@@ -584,7 +600,7 @@
if( i!= pci->argc) {
for( i--; i>=pci->retc; i--)
BBPunfix(b[i]->batCacheid);
- throw(MAL,"xml.element","Can not access BAT");
+ throw(MAL,"xml.forest","Can not access BAT");
}
prepareResult(bn,b[pci->retc],TYPE_str,"attribute");
@@ -678,7 +694,7 @@
BBPreleaseref(b->batCacheid);
BBPunfix(bn->batCacheid);
GDKfree(buf);
- throw(MAL, "xml.element", "bunins failed");
+ throw(MAL, "xml.concat", "bunins failed");
}
str
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins