SourceForge.net Logo
xqc-basic.c

This example executes a simple XQuery expression ("1 to 100"), which returns the numbers from 1 to 100 inclusive.

int main(int argc, char *argv[])
{
XQC_Error err;
const char *value;
// XQilla specific way to create an XQC_Implementation struct
if(impl == 0) return 1;
// Prepare an XQuery expression
err = impl->prepare(impl, "1 to 100", 0, &expr);
if(err != 0) goto free_impl;
// Execute the query
err = expr->execute(expr, 0, &seq);
if(err != 0) goto free_expr;
// Iterate over the results, printing them
while((err = seq->next(seq)) == XQC_NO_ERROR) {
seq->string_value(seq, &value);
printf("%s\n", value);
}
err = XQC_NO_ERROR;
// free everything
seq->free(seq);
free_expr:
expr->free(expr);
free_impl:
impl->free(impl);
return err;
}