From 4dfc5a603e5f56d62b2d2db6abf01161815ed48a Mon Sep 17 00:00:00 2001 From: kim Date: Thu, 2 Apr 2009 03:08:52 +0000 Subject: [PATCH] Add a testing program git-svn-id: svn+ssh://idea.nguyen.vg/svn/sxsi/trunk/xpathcomp@305 3cdefd35-fc62-479d-8e8d-bae585ffb9ca --- Makefile | 5 ++++- testXMLTree.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ tests/test.xml | 5 +---- 3 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 testXMLTree.cpp diff --git a/Makefile b/Makefile index 9d2f39a..bcd3f92 100644 --- a/Makefile +++ b/Makefile @@ -110,7 +110,7 @@ clean: $(HIDE) rm -rf .libs -timeXMLTree: $(CXXOBJECTS) XMLTree/XMLTree.a timeXMLTree.cpp +timeXMLTree: $(CXXOBJECTS) XMLTree/XMLTree.a timeXMLTree.cpp testXMLTree.cpp mkdir -p .libs/ cd .libs/ && ar x ../XMLTree/XMLTree.a $(CXX) -o timeXMLTree $(CXXFLAGS) $(CXXINCLUDES) XMLDocShredder.o \ @@ -119,6 +119,9 @@ timeXMLTree: $(CXXOBJECTS) XMLTree/XMLTree.a timeXMLTree.cpp $(CXX) -o myTimeXMLTree $(CXXFLAGS) $(CXXINCLUDES) XMLDocShredder.o \ SXSIStorageInterface.o StorageInterface.o ./.libs/*.o \ $(LIBS) myTimeXMLTree.cpp + $(CXX) -o testXMLTree $(CXXFLAGS) $(CXXINCLUDES) XMLDocShredder.o \ + SXSIStorageInterface.o StorageInterface.o ./.libs/*.o \ + $(LIBS) testXMLTree.cpp rm -rf .libs SXSIStorageInterface.o: SXSIStorageInterface.h SXSIStorageInterface.cpp StorageInterface.h diff --git a/testXMLTree.cpp b/testXMLTree.cpp new file mode 100644 index 0000000..3e98c8b --- /dev/null +++ b/testXMLTree.cpp @@ -0,0 +1,43 @@ +#include "XMLDocShredder.h" +#include "XMLTree.h" +#include "Utils.h" + + +void print_structure(XMLTree* tree, treeNode x){ + DocID text; + if (x != NULLT){ + std::cout << "Par idx: " << x << ", preorder: " << + tree->NodeXMLId(x) << ", tag='" << tree->GetTagName(tree->Tag(x)) + << "'\n"; + text = tree->PrevText(x); + std::cout << "PrevText(" << x << ")= " << text + << ", value='" << ((text == NULLT) ? "" : (const char*)tree->GetText(text)) + << "'\n"; + text = tree->MyText(x); + std::cout << "MyText(" << x << ")= " << text + << ", value='" << ((text == NULLT) ? "" : (const char*)tree->GetText(text)) + << "'\n"; + text = tree->NextText(x); + std::cout << "NextText(" << x << ")= " << text + << ", value='" << ((text == NULLT) ? "" : (const char*)tree->GetText(text)) + << "'\n"; + print_structure(tree,tree->FirstChild(x)); + print_structure(tree,tree->NextSibling(x)); + }; +} + +int main(int argc, char** argv){ + XMLTree * tree; + if (argc != 2){ + std::cout << "Usage " << argv[0] << " filename.xml" << std::endl; + return 1; + }; + + XMLDocShredder shredder(argv[1],64,false,false); + shredder.processStartDocument(""); + shredder.parse(); + shredder.processEndDocument(); + tree = (XMLTree *) shredder.storageIfc_->returnDocument(); + print_structure(tree,tree->Root()); + return 0; +} diff --git a/tests/test.xml b/tests/test.xml index a143ae5..51167ad 100644 --- a/tests/test.xml +++ b/tests/test.xml @@ -1,5 +1,2 @@ - - - - +T0T1T2T3T4T5T6 -- 2.17.1