10 cout << "Test 1: RosegardenPatchFile.xml: Find all banks in the file" << endl;
11 XMLTree doc("./RosegardenPatchFile.xml");
12 // "//bank" gives as last element an empty element libxml bug????
13 boost::shared_ptr<XMLSharedNodeList> result = doc.root()->find("//bank[@name]");
15 cout << "Found " << result->size() << " banks" << endl;
16 assert(result->size() == 8);
18 for(XMLSharedNodeList::const_iterator i = result->begin(); i != result->end(); ++i) {
19 assert((*i)->name() == "bank");
20 assert((*i)->property("name"));
21 cout << "Found bank number " << counter++ << " with name: " << (*i)->property("name")->value() << endl;
22 for(XMLNodeList::const_iterator j = (*i)->children().begin(); j != (*i)->children().end(); ++j) {
23 cout << "\t found program " << (*j)->property("id")->value() <<
24 " with name: " << (*j)->property("name")->value() << endl;
28 cout << endl << endl << "Test 2: RosegardenPatchFile.xml: Find all programs whose program name contains 'Latin'" << endl;
30 result = doc.root()->find("/rosegarden-data/studio/device/bank/program[contains(@name, 'Latin')]");
31 assert(result->size() == 5);
33 for(XMLSharedNodeList::const_iterator i = result->begin(); i != result->end(); ++i) {
34 cout << "\t found program " << (*i)->property("id")->value() <<
35 " with name: " << (*i)->property("name")->value() << endl;
38 cout << endl << endl << "Test 3: TestSession.ardour: find all Sources where captured-for contains the string 'Guitar'" << endl;
40 // We have to allocate a new document here, or we get segfaults
41 XMLTree doc2("./TestSession.ardour");
42 result = doc2.root()->find("/Session/Sources/Source[contains(@captured-for, 'Guitar')]");
43 assert(result->size() == 16);
45 for(XMLSharedNodeList::const_iterator i = result->begin(); i != result->end(); ++i) {
46 cout << "\t found source '" << (*i)->property("name")->value() <<
47 "' with id: " << (*i)->property("id")->value() << endl;
50 cout << endl << endl << "Test 4: TestSession.ardour: Find all elements with an 'id' and 'name' attribute" << endl;
52 result = doc2.root()->find("//*[@id and @name]");
54 for(XMLSharedNodeList::const_iterator i = result->begin(); i != result->end(); ++i) {
55 assert((*i)->property("id"));
56 assert((*i)->property("name"));
57 cout << "\t found element '" << (*i)->name() <<
58 "' with id: " << (*i)->property("id")->value() <<
59 "' and name: " << (*i)->property("name")->value() << endl;
62 cout << endl << endl << "Test 5: ProtoolsPatchFile.midnam: Get Banks and Patches for 'Name Set 1'" << endl;
64 // We have to allocate a new document here, or we get segfaults
65 XMLTree doc3("./ProtoolsPatchFile.midnam");
66 result = doc3.root()->find("/MIDINameDocument/MasterDeviceNames/ChannelNameSet[@Name='Name Set 1']/PatchBank");
67 assert(result->size() == 16);
69 for(XMLSharedNodeList::const_iterator i = result->begin(); i != result->end(); ++i) {
70 cout << "\t found Patchbank " << (*i)->property("Name")->value() << endl;
71 boost::shared_ptr<XMLSharedNodeList> patches = (*i)->find("//Patch[@Name]");
72 for(XMLSharedNodeList::const_iterator p = patches->begin(); p != patches->end(); ++p) {
73 cout << "\t\t found patch number " << (*p)->property("Number")->value()
74 << " with name: " << (*p)->property("Name")->value() << endl;
78 cout << endl << endl << "Test 5: ProtoolsPatchFile.midnam: Find attribute nodes" << endl;
79 result = doc3.root()->find("//@Value");
81 for(XMLSharedNodeList::const_iterator i = result->begin(); i != result->end(); ++i) {
82 boost::shared_ptr<XMLNode> node = (*i);
83 cout << "\t found attribute node: " << node->name()
84 << " value: " << node->attribute_value() << endl;
87 cout << endl << endl << "Test 6: ProtoolsPatchFile.midnam: Find available channels on 'Name Set 1'" << endl;
88 result = doc3.root()->find(
89 "//ChannelNameSet[@Name = 'Name Set 1']//AvailableChannel[@Available = 'true']/@Channel");
91 assert(result->size() == 15);
92 for(XMLSharedNodeList::const_iterator i = result->begin(); i != result->end(); ++i) {
93 boost::shared_ptr<XMLNode> node = (*i);
94 cout << "\t found available Channel: " << node->name()
95 << " value: " << node->attribute_value() << endl;