First kick with a conversion of two records from YAZ
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 26 May 2014 12:43:32 +0000 (14:43 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 26 May 2014 12:43:32 +0000 (14:43 +0200)
src/.gitignore [new file with mode: 0644]
src/Makefile [new file with mode: 0644]
src/tst.cpp [new file with mode: 0644]

diff --git a/src/.gitignore b/src/.gitignore
new file mode 100644 (file)
index 0000000..75ad7b2
--- /dev/null
@@ -0,0 +1,2 @@
+*.o
+tst
diff --git a/src/Makefile b/src/Makefile
new file mode 100644 (file)
index 0000000..dc991bf
--- /dev/null
@@ -0,0 +1,17 @@
+
+O=tst.o
+
+ZORBA := ../../zorba/zorba-3.0/build/dist
+
+CXXFLAGS=-I$(ZORBA)/include
+
+LIB=-L $(ZORBA)/lib -lzorba_simplestore
+
+tst: $(O)
+       $(CXX) $^ -o $@ $(LIB)
+
+clean:
+       rm -f *.o tst
+
+run: tst
+       LD_LIBRARY_PATH=$(ZORBA)/lib ./tst
diff --git a/src/tst.cpp b/src/tst.cpp
new file mode 100644 (file)
index 0000000..f35415d
--- /dev/null
@@ -0,0 +1,88 @@
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#include <assert.h>
+
+#include <zorba/zorba.h>
+#include <zorba/store_manager.h>
+#include <zorba/serializer.h>
+#include <zorba/singleton_item_sequence.h>
+#include <zorba/zorba_exception.h>
+
+
+using namespace zorba;
+
+bool
+example_1(Zorba* aZorba)
+{
+    XQuery_t lQuery = aZorba->compileQuery("1+2");
+
+    std::cout << lQuery << std::endl;
+
+    return true;
+}
+
+bool
+example_2(Zorba* aZorba)
+{
+    XQuery_t lQuery = aZorba->createQuery();
+    std::string path( "/home/adam/proj/marc2bibframe/xbin/zorba3-0.xqy");
+
+    std::unique_ptr<std::istream> qfile;
+
+    qfile.reset( new std::ifstream( path.c_str() ) );
+
+    Zorba_CompilerHints lHints;
+
+    // lQuery->setFileName("http://base/");
+    lQuery->setFileName("/home/adam/proj/marc2bibframe/xbin/");
+
+    lQuery->compile(*qfile.get(), lHints);
+
+    zorba::DynamicContext* lDynamicContext = lQuery->getDynamicContext();
+
+    zorba::Item lItem = aZorba->getItemFactory()->createString("http://base/");
+    lDynamicContext->setVariable("baseuri", lItem);
+
+    lItem = aZorba->getItemFactory()->createString(
+        "/home/adam/proj/yaz/test/marc6.xml");
+    lDynamicContext->setVariable("marcxmluri", lItem);
+
+    lItem = aZorba->getItemFactory()->createString("rdfxml");
+    lDynamicContext->setVariable("serialization", lItem);
+
+    std::cout << lQuery << std::endl;
+
+    lItem = aZorba->getItemFactory()->createString(
+        "/home/adam/proj/yaz/test/marc7.xml");
+    lDynamicContext->setVariable("marcxmluri", lItem);
+
+    std::cout << lQuery << std::endl;
+
+    return true;
+}
+
+int main(int argc, char **argv)
+{
+    void* lStore = StoreManager::getStore();
+    Zorba *lZorba = Zorba::getInstance(lStore);
+
+    assert(lZorba);
+
+    example_1(lZorba);
+
+    example_2(lZorba);
+
+    lZorba->shutdown();
+    StoreManager::shutdownStore(lStore);
+    return 0;
+}
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+