Changeset 154
- Timestamp:
- 07/04/08 10:53:14 (6 months ago)
- Files:
-
- trunk/dba/dba.bkl (modified) (2 diffs)
- trunk/dba/dba/xmlarchive.cpp (modified) (3 diffs)
- trunk/dba/dba/xmlarchive.h (modified) (3 diffs)
- trunk/dba/dba/xmlistream.cpp (modified) (5 diffs)
- trunk/dba/dba/xmlistream.h (modified) (3 diffs)
- trunk/dba/dba/xmlostream.cpp (modified) (7 diffs)
- trunk/dba/dba/xmlostream.h (modified) (2 diffs)
- trunk/dba/dba/xmlutils.cpp (added)
- trunk/dba/dba/xmlutils.h (added)
- trunk/dba/test/main.cpp (modified) (1 diff)
- trunk/dba/test/testobject.cpp (modified) (1 diff)
- trunk/dba/test/testobject.h (modified) (1 diff)
- trunk/dba/test/xmltestcase.cpp (modified) (2 diffs)
- trunk/dba/test/xmltestcase.h (modified) (2 diffs)
- trunk/presets/syslibs.bkl (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/dba/dba.bkl
r151 r154 199 199 dba/xmlistream.cpp 200 200 dba/xmlostream.cpp 201 dba/xmlutils.cpp 201 202 </sources> 202 203 <msvc-headers> … … 206 207 dba/xmlistream.h 207 208 dba/xmlostream.h 209 dba/xmlutils.h 208 210 </msvc-headers> 209 211 </template> trunk/dba/dba/xmlarchive.cpp
r153 r154 55 55 } else { 56 56 mDocument = xmlNewDoc((const xmlChar*)"1.0"); 57 xmlNodePtr node; 57 58 if (mRootNodeName != NULL) { 58 xmlNodePtr node = xmlNewDocNode(mDocument,NULL,mRootNodeName,NULL); 59 xmlDocSetRootElement(mDocument,node); 59 node = xmlNewDocNode(mDocument,NULL,mRootNodeName,NULL); 60 } else { 61 node = xmlNewDocNode(mDocument,NULL,(xmlChar*)"__dba_for_replace",NULL); 60 62 }; 63 xmlDocSetRootElement(mDocument,node); 61 64 }; 62 65 updateEncoding(); 63 if (mRootNodeName != NULL) { 64 mRootNode = mDocument->children; 65 } else { 66 mRootNode = xmlDocGetRootElement(mDocument); 67 }; 66 mRootNode = xmlDocGetRootElement(mDocument); 67 }; 68 69 void 70 XMLArchive::addNamespace(const char* pName, const char* pPrefix) { 71 if (!isOpen()) 72 throw APIException("XMLArchive must be open to add namespace to it"); 73 xmlNsPtr ret = xmlNewNs(mRootNode, (xmlChar*)pName, (xmlChar*)pPrefix); 74 if (ret == NULL) 75 throw XMLException("Failed to add namespace to archive"); 68 76 }; 69 77 … … 82 90 if (mRootNodeName != NULL) 83 91 root = root->children; 84 return new XMLIStream( root,mConvSpecs);92 return new XMLIStream(mDocument,root,mConvSpecs); 85 93 }; 86 94 87 95 OStream* 88 96 XMLArchive::getOutputStream() { 89 return new XMLOStream(mDocument,mRootNode,m ConvSpecs);97 return new XMLOStream(mDocument,mRootNode,mRootNodeName != NULL,mConvSpecs); 90 98 }; 91 99 … … 95 103 if (mRootNodeName != NULL) 96 104 root = root->children; 97 return XMLIStream( root,mConvSpecs);105 return XMLIStream(mDocument,root,mConvSpecs); 98 106 }; 99 107 100 108 XMLOStream 101 109 XMLArchive::getOStream() { 102 XMLOStream ret(mDocument,mRootNode,m ConvSpecs);110 XMLOStream ret(mDocument,mRootNode,mRootNodeName == NULL,mConvSpecs); 103 111 return ret; 104 112 }; trunk/dba/dba/xmlarchive.h
r150 r154 18 18 #include "xmlerrorhandler.h" 19 19 #include <libxml/tree.h> 20 #include <list> 20 21 21 22 namespace dba { … … 27 28 public: 28 29 XMLArchive(); 30 /** 31 Set name of root node. If set to NULL then it is possible to IStream::get 32 only one object from archive file pointed by root element, 33 otherwise archive will try to get list of objects from subelement of root 34 element in xml file 35 @param pName name of root object or NULL if elements from second level should be retrieved 36 */ 29 37 void setRootNodeName(const char* pName); 38 /** 39 Add namespace to document. You have to call this method 40 if there are namespace prefixed members in class store table 41 */ 42 void addNamespace(const char* pName, const char* pPrefix); 30 43 virtual void open(const char* pOpenStr); 31 44 /** … … 33 46 */ 34 47 void close(); 35 virtual bool isOpen() const { return m RootNode!= NULL; }48 virtual bool isOpen() const { return mDocument != NULL; } 36 49 XMLOStream getOStream(); 37 50 XMLIStream getIStream(); trunk/dba/dba/xmlistream.cpp
r153 r154 11 11 // 12 12 #include "xmlistream.h" 13 #include "xmlutils.h" 13 14 #include "collectionfilter.h" 14 15 #include <iostream> … … 16 17 namespace dba { 17 18 18 XMLIStream::XMLIStream(xml NodePtr pNode, const ConvSpec& pSpecs)19 XMLIStream::XMLIStream(xmlDocPtr pDocument, xmlNodePtr pNode, const ConvSpec& pSpecs) 19 20 : IStream(), 20 21 ConvSpecContainer(pSpecs), 21 mParentNode(pNode) 22 mDocument(pDocument), 23 mParentNode(pNode), 24 mIgnoreNonMappedNodes(false), 25 mIgnoreOrder(false) 22 26 { 23 27 mCurrentNode = findNonTextNode(mParentNode); … … 158 162 }; 159 163 164 xmlAttrPtr 165 XMLIStream::findAttribute(xmlNodePtr pNode, const char* pMemberName) { 166 char* ns = XMLUtils::getNsFromName(pMemberName); 167 168 xmlAttrPtr ret = NULL; 169 if (ns != NULL) { 170 xmlNsPtr nsptr = xmlSearchNs(mDocument,pNode,(xmlChar*)ns); 171 if (nsptr == NULL) { 172 std::string err("Error loading data from node '"); 173 err += pMemberName; 174 err += "'. Namespace not added, call addNamespace on XMLArchive first"; 175 throw APIException(err.c_str()); 176 }; 177 char* name = XMLUtils::getNameWithoutNs(pMemberName); 178 ret = xmlHasNsProp(pNode,(xmlChar*)name,nsptr->href); 179 delete [] name; 180 } else { 181 ret = xmlHasProp(pNode,(xmlChar*)pMemberName); 182 }; 183 delete [] ns; 184 return ret; 185 }; 186 160 187 void 161 188 XMLIStream::applyFilters(Storeable* pObject) { … … 171 198 dba::StoreableFilterBase* filter(member->getFilter()); 172 199 setFilterPtr(*filter,(char*)pObject + (int)(member->getMemberOffset() + tbl->getClassOffset())); 173 xmlAttrPtr attr = xmlHasProp(mCurrentNode, (xmlChar*)member->getMemberName());200 xmlAttrPtr attr = findAttribute(mCurrentNode,member->getMemberName()); 174 201 if (attr != NULL) { 175 202 xmlChar* xmldata = xmlNodeGetContent(attr->children); … … 205 232 for(VarMap::iterator it = mBindings.begin(); it != mBindings.end(); it++) { 206 233 if (!xmlStrcmp((xmlChar*)(it->mTable), mCurrentNode->name)) { 207 xmlAttrPtr attr = xmlHasProp(mCurrentNode, (xmlChar*)it->mField);234 xmlAttrPtr attr = findAttribute(mCurrentNode, it->mField); 208 235 dba::StoreableFilterBase& filter(*(it->mFilter)); 209 236 if (attr != NULL) { trunk/dba/dba/xmlistream.h
r139 r154 24 24 class XMLIStream : public IStream, public XMLErrorHandler, public ConvSpecContainer { 25 25 public: 26 XMLIStream(xmlNodePtr pNode, const ConvSpec& pSpecs); 26 XMLIStream(xmlDocPtr pDocument, xmlNodePtr pNode, const ConvSpec& pSpecs); 27 /** 28 If set to true, then stream will igore all nodes that are not mapped to class 29 members or binded to variables. Default value is false. 30 */ 31 void ignoreNonMappedNodes(bool pFlag); 32 /** 33 If set to true, then stream will igore order of readed elements and try to 34 find element using its name among all elements on single level. Otherwise 35 element order in xml file has to be the same as store table layout. Elements 36 from parent store table should be placed before elements in child store table. 37 Default value is false. 38 */ 39 void ignoreNodeOrder(bool pFlag); 27 40 virtual void close(); 28 41 virtual void destroy(); … … 34 47 virtual ~XMLIStream(); 35 48 private: 49 xmlDocPtr mDocument; 36 50 xmlNodePtr mParentNode; 37 51 xmlNodePtr mCurrentNode; 52 bool mIgnoreNonMappedNodes; 53 bool mIgnoreOrder; 38 54 39 55 virtual void setIdsCondition(const char* pFKeyName, id pRelationId, const std::vector<id>& pIds); … … 45 61 bool isClassMember(Storeable* pObject, xmlNodePtr pNode); 46 62 void getChildren(Storeable* pParent, xmlNodePtr pNode); 63 xmlAttrPtr findAttribute(xmlNodePtr pNode, const char* pMemberName); 47 64 }; 48 65 trunk/dba/dba/xmlostream.cpp
r153 r154 13 13 #include "conversion.h" 14 14 #include "collectionfilter.h" 15 #include "xmlutils.h" 15 16 16 17 namespace dba { 17 18 18 XMLOStream::XMLOStream(xmlDocPtr pDocument, xmlNodePtr pNode, const ConvSpec& pSpecs)19 XMLOStream::XMLOStream(xmlDocPtr pDocument, xmlNodePtr pNode, bool pReplaceParentNode, const ConvSpec& pSpecs) 19 20 : OStream(), 20 21 ConvSpecContainer(pSpecs), 21 22 mDocument(pDocument), 22 mParentNode(pNode) 23 mParentNode(pNode), 24 mReplaceParentNode(pReplaceParentNode) 23 25 { 24 26 } … … 49 51 //file is always created from scratch 50 52 return store(pObject); 53 }; 54 55 void 56 XMLOStream::setAttribute(xmlNodePtr pNode, const char* pName, const xmlChar* pData) { 57 char* nsname(XMLUtils::getNsFromName(pName)); 58 if (nsname == NULL) { 59 xmlNewProp(pNode,(xmlChar*)pName,pData); 60 } else { 61 xmlNsPtr ns = xmlSearchNs(mDocument,pNode,(xmlChar*)nsname); 62 delete [] nsname; 63 if (ns == NULL) { 64 std::string err("Error setting attribute '"); 65 err += pName; 66 err += "'. Namespace not added, call addNamespace on XMLArchive first"; 67 throw APIException(err.c_str()); 68 }; 69 char* propname(XMLUtils::getNameWithoutNs(pName)); 70 xmlNewNsProp(pNode,ns,(xmlChar*)propname,pData); 71 delete [] propname; 72 }; 73 }; 74 75 xmlNodePtr 76 XMLOStream::createNode(const char* pName) { 77 char* nsname(XMLUtils::getNsFromName(pName)); 78 xmlNsPtr ns = NULL; 79 xmlNodePtr node = NULL; 80 if (nsname != NULL) { 81 ns = xmlSearchNs(mDocument,mParentNode,(xmlChar*)nsname); 82 delete [] nsname; 83 if (ns == NULL) { 84 std::string err("Error creating node '"); 85 err += pName; 86 err += "'. Namespace not added, call addNamespace on XMLArchive first"; 87 throw APIException(err.c_str()); 88 }; 89 char* nodename(XMLUtils::getNameWithoutNs(pName)); 90 node = xmlNewNode(ns, (xmlChar*)nodename); 91 delete [] nodename; 92 } else { 93 node = xmlNewNode(ns, (xmlChar*)pName); 94 }; 95 return node; 51 96 }; 52 97 … … 60 105 if (!filter.isNull()) { 61 106 std::string strdata(filter.toString(getConversionSpecs())); 62 xmlNewProp(pNode,(xmlChar*)member->name,(xmlChar*)strdata.c_str());107 setAttribute(pNode,member->name,(xmlChar*)strdata.c_str()); 63 108 }; 64 109 member = member->next; … … 76 121 data = filter.toString(mConvSpecs); 77 122 if (!data.empty()) { 78 xmlNewProp(pNode,(xmlChar*)it->mField,(xmlChar*)data.c_str());123 setAttribute(pNode,it->mField,(xmlChar*)data.c_str()); 79 124 }; 80 125 }; … … 89 134 90 135 mt_class* current = mMemberList->mFirst; 91 xmlNodePtr node = xmlNewNode(NULL, (xmlChar*)current->name); 136 xmlNodePtr node = createNode(current->name); 137 if (!mReplaceParentNode) { 138 //store table is readed from last element to first 139 //and from child table to parent. 140 //but we want to add elements in oposite order 141 xmlNodePtr last = xmlGetLastChild(mParentNode); 142 if (last == NULL) 143 xmlAddChild(mParentNode, node); 144 else 145 xmlAddPrevSibling(last,node); 146 } else { 147 node->nsDef = xmlCopyNamespaceList(mParentNode->nsDef); 148 xmlFree(xmlDocSetRootElement(mDocument,node)); 149 mReplaceParentNode = false; 150 }; 92 151 //FIXME add configuration for storing id? 93 152 //xmlNewProp(node,(xmlChar*)"id",(xmlChar*)(toStr(id).c_str())); … … 99 158 break; 100 159 }; 101 if (mParentNode != NULL)102 xmlAddChild(mParentNode, node);103 else104 xmlDocSetRootElement(mDocument,node);105 160 return true; 106 161 }; … … 144 199 if (iterator->hasNext()) { 145 200 if (pMember.getFKeyName() != NULL) { 146 xmlAddChild(mParentNode, xmlNewNode(NULL, (xmlChar*)pMember.getFKeyName()));201 xmlAddChild(mParentNode, createNode(pMember.getFKeyName())); 147 202 mParentNode = mParentNode->children; 148 203 }; trunk/dba/dba/xmlostream.h
r153 r154 24 24 class XMLOStream : public OStream, public XMLErrorHandler, public ConvSpecContainer { 25 25 public: 26 XMLOStream(xmlDocPtr pDocument, xmlNodePtr pNode, const ConvSpec& pSpecs);26 XMLOStream(xmlDocPtr pDocument, xmlNodePtr pNode, bool pReplaceParentNode, const ConvSpec& pSpecs); 27 27 virtual void close(); 28 28 virtual void destroy(); … … 45 45 xmlDocPtr mDocument; 46 46 xmlNodePtr mParentNode; 47 bool mReplaceParentNode; 47 48 48 49 void updateNodeFromVars(xmlNodePtr pNode, mt_class* pTable); 49 50 void updateNodeFromObject(xmlNodePtr pNode, const Storeable& pObject, mt_class* pTable); 51 void setAttribute(xmlNodePtr pNode, const char* pName, const xmlChar* pData); 52 xmlNodePtr createNode(const char* pName); 50 53 }; 51 54 trunk/dba/test/main.cpp
r153 r154 150 150 //runner.addTest(new CppUnit::TestCaller<dba_tests::CSVTestCase>("debug_test",&dba_tests::CSVTestCase::manual)); 151 151 //runner.addTest(new CppUnit::TestCaller<SQLite3SQLArchiveTestCase>("debug_test",&SQLite3SQLArchiveTestCase::transactions_rollback)); 152 runner.addTest(dba_tests::XMLTestCase::suite()); 153 //runner.addTest(new CppUnit::TestCaller<dba_tests::XMLTestCase>("debug_test",&dba_tests::XMLTestCase::simpleOneLoad)); 152 //runner.addTest(dba_tests::XMLTestCase::suite()); 153 runner.addTest(new CppUnit::TestCaller<dba_tests::XMLTestCase>("debug_test",&dba_tests::XMLTestCase::load_two_inverted)); 154 //runner.addTest(new CppUnit::TestCaller<dba_tests::XMLTestCase>("debug_test",&dba_tests::XMLTestCase::store_two)); 154 155 //runner.addTest(new CppUnit::TestCaller<OdbcPluginTestCase>("debug_test",&OdbcPluginTestCase::dbConnection)); 155 156 //runner.addTest(new CppUnit::TestCaller<PostgresSQLArchiveTestCase>("debug_test",&PostgresSQLArchiveTestCase::sqlError)); trunk/dba/test/testobject.cpp
r139 r154 122 122 END_STORE_TABLE() 123 123 124 } 124 } //namespace 125 trunk/dba/test/testobject.h
r141 r154 605 605 }; 606 606 607 } 607 } //namespace 608 608 609 609 #endif trunk/dba/test/xmltestcase.cpp
r153 r154 16 16 #include "dba/string_filter.h" 17 17 #include "dba/stdlist.h" 18 #include "dba/single.h" 18 19 19 20 #include <fstream> … … 531 532 }; 532 533 534 class NsObject: public dba::Storeable { 535 DECLARE_STORE_TABLE(); 536 public: 537 NsObject() { } 538 NsObject(const std::string& pNsName) 539 : mNsName(pNsName) 540 { 541 } 542 virtual bool operator ==(const NsObject& pNsObject) const { 543 return (mNsName == pNsObject.mNsName); 544 } 545 std::string mNsName; 546 }; 547 548 BEGIN_STORE_TABLE(NsObject, dba::Storeable, "nsobject") 549 BIND_STR(NsObject::mNsName, dba::String , "ns:name") 550 END_STORE_TABLE(); 551 552 void 553 XMLTestCase::load_missing_ns() { 554 const char* nsdata = 555 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" 556 " <nsobject name=\"test\" ns:name=\"namespace\">\n" 557 " </nsobject>\n"; 558 { 559 std::ofstream file("ns_missing.xml"); 560 file << nsdata; 561 }; 562 { 563 dba::XMLArchive xmlArch; 564 xmlArch.setRootNodeName("nsobject"); 565 xmlArch.open("ns_missing.xml"); 566 NsObject loaded; 567 dba::XMLIStream stream(xmlArch.getIStream()); 568 try { 569 stream.get(&loaded); 570 } catch (const dba::APIException& pEx) { 571 }; 572 }; 573 } 574 575 void 576 XMLTestCase::load_ns_single() { 577 const char* nsdata = 578 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" 579 " <nsobject xmlns:ns='http://bogus_ns_namespace' ns:name=\"namespace\" />\n" 580 ; 581 { 582 std::ofstream file("ns_load.xml"); 583 file << nsdata; 584 }; 585 { 586 NsObject expected("namespace"); 587 588 dba::XMLArchive xmlArch; 589 xmlArch.setRootNodeName(NULL); 590 xmlArch.open("ns_load.xml"); 591 NsObject loaded; 592 dba::XMLIStream stream(xmlArch.getIStream()); 593 stream.get(&loaded); 594 CPPUNIT_ASSERT(loaded == expected); 595 }; 596 } 597 598 void 599 XMLTestCase::store_ns_single() { 600 const char* nsdata = 601 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" 602 "<nsobject xmlns:ns=\"http://bogus_ns_namespace\" ns:name=\"namespace\"/>\n" 603 ; 604 { 605 dba::XMLArchive xmlArch; 606 xmlArch.setRootNodeName(NULL); 607 unlink("ns_store.xml"); 608 xmlArch.open("ns_store.xml"); 609 xmlArch.addNamespace("http://bogus_ns_namespace","ns"); 610 NsObject obj("namespace"); 611 dba::XMLOStream stream(xmlArch.getOStream()); 612 stream.put(&obj); 613 }; 614 CPPUNIT_ASSERT(compareXML("ns_store.xml",nsdata)); 615 } 616 617 void 618 XMLTestCase::load_ns() { 619 const char* nsdata = 620 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" 621 "<dba xmlns:ns=\"http://bogus_ns_namespace\">\n" 622 " <nsobject ns:name=\"namespace\"/>\n" 623 "</dba>\n" 624 ; 625 { 626 std::ofstream file("ns_load.xml"); 627 file << nsdata; 628 }; 629 { 630 NsObject expected("namespace"); 631 632 dba::XMLArchive xmlArch; 633 xmlArch.open("ns_load.xml"); 634 NsObject loaded; 635 dba::XMLIStream stream(xmlArch.getIStream()); 636 stream.get(&loaded); 637 CPPUNIT_ASSERT(loaded == expected); 638 }; 639 } 640 641 void 642 XMLTestCase::store_ns() { 643 const char* nsdata = 644 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" 645 "<dba xmlns:ns=\"http://bogus_ns_namespace\">\n" 646 " <nsobject ns:name=\"namespace\"/>\n" 647 "</dba>\n" 648 ; 649 { 650 dba::XMLArchive xmlArch; 651 unlink("ns_store.xml"); 652 xmlArch.open("ns_store.xml"); 653 xmlArch.addNamespace("http://bogus_ns_namespace","ns"); 654 NsObject obj("namespace"); 655 dba::XMLOStream stream(xmlArch.getOStream()); 656 stream.put(&obj); 657 }; 658 CPPUNIT_ASSERT(compareXML("ns_store.xml",nsdata)); 659 } 660 661 class TwoSingles : public dba::Storeable { 662 DECLARE_STORE_TABLE(); 663 public: 664 TwoSingles() {}; 665 TwoSingles(const char* pName) 666 : mName(pName), 667 mObj1(TestObject(1,1,"1",Utils::getDate(2008,1,1,0,0,0))), 668 mObj2(TestObject(20,20,"20",Utils::getDate(2008,2,2,0,0,0))) 669 {}; 670 bool operator==(const TwoSingles& pObj) { 671 if (mName != pObj.mName) 672 return false; 673 return mObj1 == pObj.mObj1 && mObj2 == pObj.mObj2; 674 }; 675 std::string mName; 676 TestObject mObj1; 677 TestObject mObj2; 678 }; 679 680 BEGIN_STORE_TABLE(TwoSingles,dba::Storeable,"twosingles") 681 BIND_STR(TwoSingles::mName, dba::String, "parent") 682 BIND_COL(TwoSingles::mObj1, dba::Single, NULL) 683 BIND_COL(TwoSingles::mObj2, dba::Single, NULL) 684 END_STORE_TABLE() 685 686 void 687 XMLTestCase::load_two() { 688 const char* nsdata = 689 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" 690 "<dba>\n" 691 " <twosingles parent=\"parent_name\">\n" 692 " <test_objects i_value=\"1\" f_value=\"1\" s_value=\"1\" d_value=\"2008-01-01Z00:00:00\"/>\n" 693 " <test_objects i_value=\"20\" f_value=\"20\" s_value=\"20\" d_value=\"2008-02-02Z00:00:00\"/>\n" 694 " </twosingles>\n" 695 "</dba>\n" 696 ; 697 { 698 std::ofstream file("load_two.xml"); 699 file << nsdata; 700 }; 701 { 702 TwoSingles expected("parent_name"); 703 704 dba::XMLArchive xmlArch; 705 xmlArch.open("load_two.xml"); 706 TwoSingles loaded; 707 dba::XMLIStream stream(xmlArch.getIStream()); 708 stream.get(&loaded); 709 CPPUNIT_ASSERT(loaded == expected); 710 }; 711 }; 712 713 void 714 XMLTestCase::store_two() { 715 const char* nsdata = 716 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" 717 "<dba>\n" 718 " <twosingles parent=\"parent_name\">\n" 719 " <test_objects i_value=\"1\" f_value=\"1\" s_value=\"1\" d_value=\"2008-01-01Z00:00:00\"/>\n" 720 " <test_objects i_value=\"20\" f_value=\"20\" s_value=\"20\" d_value=\"2008-02-02Z00:00:00\"/>\n" 721 " </twosingles>\n" 722 "</dba>\n" 723 ; 724 { 725 dba::XMLArchive xmlArch; 726 unlink("store_two.xml"); 727 xmlArch.open("store_two.xml"); 728 TwoSingles obj("parent_name"); 729 dba::XMLOStream stream(xmlArch.getOStream()); 730 stream.put(&obj); 731 }; 732 CPPUNIT_ASSERT(compareXML("store_two.xml",nsdata)); 733 } 734 735 void 736 XMLTestCase::load_two_inverted() { 737 const char* nsdata = 738 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" 739 "<dba>\n" 740 " <twosingles parent=\"parent_name\">\n" 741 " <test_objects i_value=\"20\" f_value=\"20\" s_value=\"20\" d_value=\"2008-02-02Z00:00:00\"/>\n" 742 " <test_objects i_value=\"1\" f_value=\"1\" s_value=\"1\" d_value=\"2008-01-01Z00:00:00\"/>\n" 743 " </twosingles>\n" 744 "</dba>\n" 745 ; 746 { 747 std::ofstream file("load_two_inverted.xml"); 748 file << nsdata; 749 }; 750 { 751 TwoSingles expected("parent_name"); 752 753 dba::XMLArchive xmlArch; 754 xmlArch.open("load_two_inverted.xml"); 755 TwoSingles loaded; 756 dba::XMLIStream stream(xmlArch.getIStream()); 757 stream.get(&loaded); 758 CPPUNIT_ASSERT(loaded == expected); 759 }; 760 }; 761 533 762 534 763 } //namespace trunk/dba/test/xmltestcase.h
r153 r154 45 45 CPPUNIT_TEST(sublist_tree_load); 46 46 CPPUNIT_TEST(sublist_three_simple_load); 47 CPPUNIT_TEST(load_missing_ns); 48 CPPUNIT_TEST(load_ns_single); 49 CPPUNIT_TEST(store_ns_single); 50 CPPUNIT_TEST(load_ns); 51 CPPUNIT_TEST(store_ns); 52 CPPUNIT_TEST(load_two); 47 53 CPPUNIT_TEST_SUITE_END(); 48 54 public: … … 71 77 void sublist_tree_load(); 72 78 void sublist_three_simple_load(); 79 void load_missing_ns(); 80 void load_ns_single(); 81 void store_ns_single(); 82 void load_ns(); 83 void store_ns(); 84 void load_two(); 85 void load_two_inverted(); 86 void store_two(); 73 87 private: 74 88 bool compareXML(const char* pFilename, const char* pData); trunk/presets/syslibs.bkl
r151 r154 21 21 <if cond="FORMAT=='autoconf'"> 22 22 <cxxflags>$(xml2_CXXFLAGS)</cxxflags> 23 <cxxflags>$(xslt_CXXFLAGS)</cxxflags>24 23 </if> 25 24 </template> … … 29 28 <if cond="TOOLSET=='win32'"> 30 29 <sys-lib>libxml2</sys-lib> 31 <sys-lib>libexslt</sys-lib>32 <sys-lib>libxslt</sys-lib>33 30 </if> 34 31 </if> 35 32 <if cond="FORMAT=='autoconf'"> 36 33 <ldlibs>$(xml2_LIBS)</ldlibs> 37 <ldlibs>$(xslt_LIBS)</ldlibs>38 34 </if> 39 35 </template>
