This file contains some examples that demonstrate how the XmlDataManager can be used to load files, create collection, etc.
#include <iostream>
#include <sstream>
using namespace zorba;
bool
{
try {
std::stringstream lInStream;
lInStream
<< "<books>" << std::endl
<< " <book>Book 1</book>" << std::endl
<< " <book>Book 2</book>" << std::endl
<< "</books>";
lDocMgr->
put(
"books.xml", lDoc);
std::cout << lQuery << std::endl;
if (lAvailable)
return false;
std::cerr << e << std::endl;
return false;
}
return true;
}
bool
{
try {
"http://www.zorba-xquery.com/collections", "mybooks");
lIter->open();
while (lIter->next(lColName)) {
}
if (lAvailable)
return false;
std::cerr << e << std::endl;
return false;
}
return true;
}
bool
{
try {
"http://www.zorba-xquery.com/collections", "mybooks");
std::stringstream lInStream;
lInStream
<< "<books>" << std::endl
<< " <book>Book 1</book>" << std::endl
<< " <book>Book 2</book>" << std::endl
<< "</books>";
if (!lColl) {
return false;
}
std::vector<Annotation_t> lAnnotations;
lColl->getAnnotations(lAnnotations);
size_t num_annotations = 0;
for (std::vector<Annotation_t>::const_iterator lIter = lAnnotations.begin();
lIter != lAnnotations.end(); ++lIter)
{
std::cout << "Annotation QName "
<< (*lIter)->getQName().getStringValue() << std::endl;
++num_annotations;
}
if (num_annotations != 3)
{
return false;
}
lIter->open();
while (lIter->next(lDoc)) {
std::cout << "node found at position "
<< lColl->indexOf(lDoc) << std::endl;
}
lColl->deleteNodeLast();
lIter->close();
lIter->open();
while (lIter->next(lDoc)) {
return false;
}
std::cerr << e << std::endl;
return false;
}
return true;
}
bool
{
try {
"http://www.blub.com/");
lIter->open();
while (lIter->next(lColName)) {
}
if (lAvailable)
return false;
std::cerr << e << std::endl;
return false;
}
return true;
}
bool
{
try {
std::stringstream lStream;
lStream
<< "<book><title>XQuery From The Experts</title></book>"
<< "<book><title>XQuery Kick Start</title></book>"
<< "<book><title>Querying XML</title></book>";
lIter->open();
while (lIter->next(lItem)) {
}
std::cerr << e << std::endl;
return false;
}
return true;
}
int
datamanager(int argc, char* argv[])
{
bool res = false;
std::cout << "executing example 1" << std::endl;
res = datamanager_example_1(lZorba, lDataManager);
if (!res) return 1;
std::cout << std::endl;
std::cout << "executing example 2" << std::endl;
res = datamanager_example_2(lZorba, lDataManager);
if (!res) return 2;
std::cout << std::endl;
std::cout << "executing example 3" << std::endl;
res = datamanager_example_3(lZorba, lDataManager);
if (!res) return 3;
std::cout << std::endl;
std::cout << "executing example 4" << std::endl;
res = datamanager_example_4(lZorba, lDataManager);
if (!res) return 4;
std::cout << std::endl;
std::cout << "executing example 5" << std::endl;
res = datamanager_example_5(lZorba, lDataManager);
if (!res) return 5;
std::cout << std::endl;
return 0;
}