|
From: <tbr...@us...> - 2012-03-20 01:38:52
|
Revision: 197
http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=197&view=rev
Author: tbrowder2
Date: 2012-03-20 01:38:42 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
more C++ source file suffix changes from .cxx to .cc
Modified Paths:
--------------
trunk/examples/02-event_parsing/Makefile.am
trunk/examples/03-xml_generation/Makefile.am
trunk/examples/04-xslt/Makefile.am
trunk/tests/Makefile.am
Added Paths:
-----------
trunk/examples/01-tree_parsing/example.cc
trunk/examples/02-event_parsing/example.cc
trunk/examples/03-xml_generation/example.cc
trunk/examples/04-xslt/example.cc
trunk/tests/attributes/test_attributes.cc
trunk/tests/document/test_document.cc
trunk/tests/event/test_event.cc
trunk/tests/node/test_node.cc
trunk/tests/test_main.cc
trunk/tests/tree/test_tree.cc
trunk/tests/xslt/test_xslt.cc
Removed Paths:
-------------
trunk/examples/01-tree_parsing/example.cxx
trunk/examples/02-event_parsing/example.cxx
trunk/examples/03-xml_generation/example.cxx
trunk/examples/04-xslt/example.cxx
trunk/tests/attributes/test_attributes.cxx
trunk/tests/document/test_document.cxx
trunk/tests/event/test_event.cxx
trunk/tests/node/test_node.cxx
trunk/tests/test_main.cxx
trunk/tests/tree/test_tree.cxx
trunk/tests/xslt/test_xslt.cxx
Copied: trunk/examples/01-tree_parsing/example.cc (from rev 186, trunk/examples/01-tree_parsing/example.cxx)
===================================================================
--- trunk/examples/01-tree_parsing/example.cc (rev 0)
+++ trunk/examples/01-tree_parsing/example.cc 2012-03-20 01:38:42 UTC (rev 197)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...)
+ * All Rights Reserved
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of the Author nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * This file demonstrates how to use the xml::tree_parser class to parse XML
+ * data and create a tree of xml::node objects. It also shows how you can
+ * walk the tree using xml::node iterators.
+ */
+
+// xmlwrapp include
+#include <xmlwrapp/xmlwrapp.h>
+
+// standard includes
+#include <iostream>
+#include <exception>
+
+int main (int argc, char *argv[]) {
+ if (argc != 2) {
+ std::cerr << argv[0] << ": you must give one and only one XML file name\n";
+ return 1;
+ }
+
+ try {
+
+ xml::tree_parser parser(argv[1]);
+
+ xml::node &root = parser.get_document().get_root_node();
+ std::cout << "root node is '" << root.get_name() << "'\n";
+
+ xml::node::const_iterator child(root.begin()), child_end(root.end());
+ for (; child != child_end; ++child) {
+ if (child->is_text()) continue;
+ std::cout << "child node '" << child->get_name() << "'\n";
+ }
+
+ } catch (std::exception &e) {
+ std::cerr << argv[0] << ": " << e.what() << "\n";
+ return 1;
+ }
+
+ return 0;
+}
Deleted: trunk/examples/01-tree_parsing/example.cxx
===================================================================
--- trunk/examples/01-tree_parsing/example.cxx 2012-03-20 01:20:13 UTC (rev 196)
+++ trunk/examples/01-tree_parsing/example.cxx 2012-03-20 01:38:42 UTC (rev 197)
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...)
- * All Rights Reserved
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of the Author nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * This file demonstrates how to use the xml::tree_parser class to parse XML
- * data and create a tree of xml::node objects. It also shows how you can
- * walk the tree using xml::node iterators.
- */
-
-// xmlwrapp include
-#include <xmlwrapp/xmlwrapp.h>
-
-// standard includes
-#include <iostream>
-#include <exception>
-
-int main (int argc, char *argv[]) {
- if (argc != 2) {
- std::cerr << argv[0] << ": you must give one and only one XML file name\n";
- return 1;
- }
-
- try {
-
- xml::tree_parser parser(argv[1]);
-
- xml::node &root = parser.get_document().get_root_node();
- std::cout << "root node is '" << root.get_name() << "'\n";
-
- xml::node::const_iterator child(root.begin()), child_end(root.end());
- for (; child != child_end; ++child) {
- if (child->is_text()) continue;
- std::cout << "child node '" << child->get_name() << "'\n";
- }
-
- } catch (std::exception &e) {
- std::cerr << argv[0] << ": " << e.what() << "\n";
- return 1;
- }
-
- return 0;
-}
Modified: trunk/examples/02-event_parsing/Makefile.am
===================================================================
--- trunk/examples/02-event_parsing/Makefile.am 2012-03-20 01:20:13 UTC (rev 196)
+++ trunk/examples/02-event_parsing/Makefile.am 2012-03-20 01:38:42 UTC (rev 197)
@@ -1,6 +1,6 @@
noinst_PROGRAMS = example
-example_SOURCES = example.cxx
+example_SOURCES = example.cc
example_CPPFLAGS = -I$(top_srcdir)/include
example_LDADD = ../../src/libxmlwrapp.la
Copied: trunk/examples/02-event_parsing/example.cc (from rev 186, trunk/examples/02-event_parsing/example.cxx)
===================================================================
--- trunk/examples/02-event_parsing/example.cc (rev 0)
+++ trunk/examples/02-event_parsing/example.cc 2012-03-20 01:38:42 UTC (rev 197)
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...)
+ * All Rights Reserved
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of the Author nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * The following code demonstrates the usage of the xml::event_parser class.
+ * This class must be derived from and the new subclass must implement the
+ * pure virtual member functions from xml::event_parser. These member
+ * functions are called when parsing events occur.
+ */
+
+// xmlwrapp include
+#include <xmlwrapp/xmlwrapp.h>
+
+// standard includes
+#include <iostream>
+#include <exception>
+
+/*
+ * Here we create a class that will receive the parsing events.
+ */
+class myparser : public xml::event_parser {
+public:
+ myparser (void)
+ { std::cout << "myparser constructor\n"; }
+
+ ~myparser (void)
+ { std::cout << "myparser destructor\n"; }
+private:
+ bool start_element (const std::string &name, const attrs_type&)
+ { std::cout << "begin tag '" << name << "'\n"; return true; }
+
+ bool end_element (const std::string &name)
+ { std::cout << "end tag '" << name << "'\n"; return true; }
+
+ bool text (const std::string&)
+ { return true; }
+};
+
+/*
+ * And here is good ol' main.
+ */
+int main (int argc, char *argv[]) {
+ if (argc != 2) {
+ std::cerr << argv[0] << ": you must give one and only one XML file name\n";
+ return 1;
+ }
+
+ myparser parser;
+
+ if (!parser.parse_file(argv[1])) {
+ std::cerr << argv[0] << ": error parsing XML file\n";
+ return 1;
+ }
+
+ return 0;
+}
Deleted: trunk/examples/02-event_parsing/example.cxx
===================================================================
--- trunk/examples/02-event_parsing/example.cxx 2012-03-20 01:20:13 UTC (rev 196)
+++ trunk/examples/02-event_parsing/example.cxx 2012-03-20 01:38:42 UTC (rev 197)
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...)
- * All Rights Reserved
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of the Author nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * The following code demonstrates the usage of the xml::event_parser class.
- * This class must be derived from and the new subclass must implement the
- * pure virtual member functions from xml::event_parser. These member
- * functions are called when parsing events occur.
- */
-
-// xmlwrapp include
-#include <xmlwrapp/xmlwrapp.h>
-
-// standard includes
-#include <iostream>
-#include <exception>
-
-/*
- * Here we create a class that will receive the parsing events.
- */
-class myparser : public xml::event_parser {
-public:
- myparser (void)
- { std::cout << "myparser constructor\n"; }
-
- ~myparser (void)
- { std::cout << "myparser destructor\n"; }
-private:
- bool start_element (const std::string &name, const attrs_type&)
- { std::cout << "begin tag '" << name << "'\n"; return true; }
-
- bool end_element (const std::string &name)
- { std::cout << "end tag '" << name << "'\n"; return true; }
-
- bool text (const std::string&)
- { return true; }
-};
-
-/*
- * And here is good ol' main.
- */
-int main (int argc, char *argv[]) {
- if (argc != 2) {
- std::cerr << argv[0] << ": you must give one and only one XML file name\n";
- return 1;
- }
-
- myparser parser;
-
- if (!parser.parse_file(argv[1])) {
- std::cerr << argv[0] << ": error parsing XML file\n";
- return 1;
- }
-
- return 0;
-}
Modified: trunk/examples/03-xml_generation/Makefile.am
===================================================================
--- trunk/examples/03-xml_generation/Makefile.am 2012-03-20 01:20:13 UTC (rev 196)
+++ trunk/examples/03-xml_generation/Makefile.am 2012-03-20 01:38:42 UTC (rev 197)
@@ -1,6 +1,6 @@
noinst_PROGRAMS = example
-example_SOURCES = example.cxx
+example_SOURCES = example.cc
example_CPPFLAGS = -I$(top_srcdir)/include
example_LDADD = ../../src/libxmlwrapp.la
Copied: trunk/examples/03-xml_generation/example.cc (from rev 186, trunk/examples/03-xml_generation/example.cxx)
===================================================================
--- trunk/examples/03-xml_generation/example.cc (rev 0)
+++ trunk/examples/03-xml_generation/example.cc 2012-03-20 01:38:42 UTC (rev 197)
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...)
+ * All Rights Reserved
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of the Author nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * The following code demonstrates how to use the xml::node class to build
+ * an XML tree and then convert it to XML text.
+ *
+ * Here is what we want to create:
+ *
+ * <abook>
+ * <person id="01" name="Peter Jones">
+ * <email>pj...@pm...</email>
+ * <!-- Fake Phone Number -->
+ * <phone type="home">555-1212</phone>
+ * </person>
+ * </abook>
+ */
+
+// xmlwrapp include
+#include <xmlwrapp/xmlwrapp.h>
+
+// standard includes
+#include <iostream>
+#include <exception>
+
+int main (void) {
+ // create a new XML document and set the root node
+ xml::document xmldoc("abook");
+ xml::node &root = xmldoc.get_root_node();
+
+ // add a child to the root node, <person>
+ xml::node::iterator it = root.insert(root.begin(), xml::node("person"));
+
+ /*
+ * set the attributes for this new <person> element using the
+ * xml::attributes object returned from xml::node::get_attributes
+ */
+ it->get_attributes().insert("id", "01");
+ it->get_attributes().insert("name", "Peter Jones");
+
+ // add a node and set the content for that new node
+ it->push_back(xml::node("email", "pj...@pm..."));
+
+ // add an XML comment
+ it->push_back(xml::node(xml::node::comment(" Fake Phone Number ")));
+
+ // build a node one member function at a time
+ it = it->insert(xml::node("phone"));
+ it->get_attributes().insert("type", "home");
+ it->set_content("555-1212");
+
+ // set some document settings
+ xmldoc.set_is_standalone(true);
+ xmldoc.set_encoding("ISO-8859-1");
+
+ // convert the document to XML
+ std::cout << xmldoc;
+ return 0;
+}
Deleted: trunk/examples/03-xml_generation/example.cxx
===================================================================
--- trunk/examples/03-xml_generation/example.cxx 2012-03-20 01:20:13 UTC (rev 196)
+++ trunk/examples/03-xml_generation/example.cxx 2012-03-20 01:38:42 UTC (rev 197)
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...)
- * All Rights Reserved
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of the Author nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * The following code demonstrates how to use the xml::node class to build
- * an XML tree and then convert it to XML text.
- *
- * Here is what we want to create:
- *
- * <abook>
- * <person id="01" name="Peter Jones">
- * <email>pj...@pm...</email>
- * <!-- Fake Phone Number -->
- * <phone type="home">555-1212</phone>
- * </person>
- * </abook>
- */
-
-// xmlwrapp include
-#include <xmlwrapp/xmlwrapp.h>
-
-// standard includes
-#include <iostream>
-#include <exception>
-
-int main (void) {
- // create a new XML document and set the root node
- xml::document xmldoc("abook");
- xml::node &root = xmldoc.get_root_node();
-
- // add a child to the root node, <person>
- xml::node::iterator it = root.insert(root.begin(), xml::node("person"));
-
- /*
- * set the attributes for this new <person> element using the
- * xml::attributes object returned from xml::node::get_attributes
- */
- it->get_attributes().insert("id", "01");
- it->get_attributes().insert("name", "Peter Jones");
-
- // add a node and set the content for that new node
- it->push_back(xml::node("email", "pj...@pm..."));
-
- // add an XML comment
- it->push_back(xml::node(xml::node::comment(" Fake Phone Number ")));
-
- // build a node one member function at a time
- it = it->insert(xml::node("phone"));
- it->get_attributes().insert("type", "home");
- it->set_content("555-1212");
-
- // set some document settings
- xmldoc.set_is_standalone(true);
- xmldoc.set_encoding("ISO-8859-1");
-
- // convert the document to XML
- std::cout << xmldoc;
- return 0;
-}
Modified: trunk/examples/04-xslt/Makefile.am
===================================================================
--- trunk/examples/04-xslt/Makefile.am 2012-03-20 01:20:13 UTC (rev 196)
+++ trunk/examples/04-xslt/Makefile.am 2012-03-20 01:38:42 UTC (rev 197)
@@ -3,7 +3,7 @@
noinst_PROGRAMS = example
-example_SOURCES = example.cxx
+example_SOURCES = example.cc
example_CPPFLAGS = -I$(top_srcdir)/include
example_LDADD = ../../src/libxsltwrapp.la ../../src/libxmlwrapp.la
Copied: trunk/examples/04-xslt/example.cc (from rev 186, trunk/examples/04-xslt/example.cxx)
===================================================================
--- trunk/examples/04-xslt/example.cc (rev 0)
+++ trunk/examples/04-xslt/example.cc 2012-03-20 01:38:42 UTC (rev 197)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...)
+ * All Rights Reserved
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of the Author nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * The following code demonstrates how to use the xsltwrapp code to trasform
+ * an XML document into something else using XSLT.
+ */
+
+// xsltwrapp include
+#include <xsltwrapp/xsltwrapp.h>
+
+// standard includes
+#include <iostream>
+#include <exception>
+
+int main (void) {
+ try {
+ // parse the input XML document
+ xml::tree_parser parser("example.xml");
+ xml::document &doc = parser.get_document();
+
+ // parse the stylesheet
+ xslt::stylesheet style("example.xsl");
+
+ // transform the XML document using the stylesheet
+ xml::document &result = style.apply(doc);
+
+ std::cout << result;
+
+ } catch (const std::exception &e) {
+ std::cerr << e.what() << "\n";
+ return 1;
+ }
+
+ return 0;
+}
Deleted: trunk/examples/04-xslt/example.cxx
===================================================================
--- trunk/examples/04-xslt/example.cxx 2012-03-20 01:20:13 UTC (rev 196)
+++ trunk/examples/04-xslt/example.cxx 2012-03-20 01:38:42 UTC (rev 197)
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...)
- * All Rights Reserved
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of the Author nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * The following code demonstrates how to use the xsltwrapp code to trasform
- * an XML document into something else using XSLT.
- */
-
-// xsltwrapp include
-#include <xsltwrapp/xsltwrapp.h>
-
-// standard includes
-#include <iostream>
-#include <exception>
-
-int main (void) {
- try {
- // parse the input XML document
- xml::tree_parser parser("example.xml");
- xml::document &doc = parser.get_document();
-
- // parse the stylesheet
- xslt::stylesheet style("example.xsl");
-
- // transform the XML document using the stylesheet
- xml::document &result = style.apply(doc);
-
- std::cout << result;
-
- } catch (const std::exception &e) {
- std::cerr << e.what() << "\n";
- return 1;
- }
-
- return 0;
-}
Modified: trunk/tests/Makefile.am
===================================================================
--- trunk/tests/Makefile.am 2012-03-20 01:20:13 UTC (rev 196)
+++ trunk/tests/Makefile.am 2012-03-20 01:38:42 UTC (rev 197)
@@ -10,16 +10,16 @@
test_SOURCES = \
test.h \
- test_main.cxx \
- attributes/test_attributes.cxx \
- document/test_document.cxx \
- event/test_event.cxx \
- node/test_node.cxx \
- tree/test_tree.cxx
+ test_main.cc \
+ attributes/test_attributes.cc \
+ document/test_document.cc \
+ event/test_event.cc \
+ node/test_node.cc \
+ tree/test_tree.cc
if WITH_XSLT
LIBS += $(top_builddir)/src/libxsltwrapp.la
-test_SOURCES += xslt/test_xslt.cxx
+test_SOURCES += xslt/test_xslt.cc
endif
EXTRA_DIST = \
Copied: trunk/tests/attributes/test_attributes.cc (from rev 188, trunk/tests/attributes/test_attributes.cxx)
===================================================================
--- trunk/tests/attributes/test_attributes.cc (rev 0)
+++ trunk/tests/attributes/test_attributes.cc 2012-03-20 01:38:42 UTC (rev 197)
@@ -0,0 +1,288 @@
+/*
+ * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...)
+ * Copyright (C) 2009 Vaclav Slavik (vs...@gm...)
+ * All Rights Reserved
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of the Author nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "../test.h"
+
+
+BOOST_AUTO_TEST_SUITE( attributes )
+
+/*
+ * Test to see if the xml::attributes function can see all the attributes of
+ * a node.
+ */
+
+static void do_attr_read(const std::string& prefix)
+{
+ std::ostringstream ostr;
+
+ xml::tree_parser parser(test_file_path(prefix + ".xml").c_str());
+
+ const xml::attributes &attrs = parser.get_document().get_root_node().get_attributes();
+ xml::attributes::const_iterator i=attrs.begin(), end=attrs.end();
+ for (; i!=end; ++i)
+ {
+ ostr << i->get_name() << "=" << i->get_value() << "\n";
+ }
+
+ BOOST_CHECK( is_same_as_file(ostr, prefix + ".out") );
+}
+
+BOOST_AUTO_TEST_CASE( read )
+{
+ do_attr_read("attributes/data/01a");
+ do_attr_read("attributes/data/01b");
+ do_attr_read("attributes/data/01c");
+}
+
+
+/*
+ * Test to see if the xml::attributes::insert function works.
+ */
+
+BOOST_AUTO_TEST_CASE( insert )
+{
+ xml::tree_parser parser(test_file_path("attributes/data/02.xml").c_str());
+
+ xml::attributes &attrs = parser.get_document().get_root_node().get_attributes();
+ attrs.insert("b", "b");
+
+ BOOST_CHECK( is_same_as_file(parser.get_document(), "attributes/data/02.out") );
+}
+
+
+/*
+ * Test to see if the xml::attributes::find works.
+ */
+
+static bool do_attr_find(const xml::document& doc,
+ const char *to_find,
+ const char *expected_value)
+{
+ const xml::attributes &attrs = doc.get_root_node().get_attributes();
+ xml::attributes::const_iterator i = attrs.find(to_find);
+
+ if ( i == attrs.end() )
+ return false;
+
+ BOOST_CHECK_EQUAL( i->get_name(), to_find );
+ BOOST_CHECK_EQUAL( i->get_value(), expected_value );
+
+ return true;
+}
+
+BOOST_AUTO_TEST_CASE( find )
+{
+ xml::tree_parser parser(test_file_path("attributes/data/03.xml").c_str());
+ const xml::document& doc = parser.get_document();
+
+ BOOST_CHECK( do_attr_find(doc, "one", "1") == true );
+ BOOST_CHECK( do_attr_find(doc, "two", "2") == true );
+ BOOST_CHECK( do_attr_find(doc, "three", "3") == true );
+ BOOST_CHECK( do_attr_find(doc, "missing", NULL) == false );
+ BOOST_CHECK( do_attr_find(doc, "also_missing", NULL) == false );
+}
+
+
+/*
+ * Test to see if the xml::attributes::remove(iterator) works.
+ */
+
+static void do_remove_by_iter(const char *name, const char *outfile)
+{
+ xml::tree_parser parser(test_file_path("attributes/data/04.xml").c_str());
+
+ xml::attributes &attrs = parser.get_document().get_root_node().get_attributes();
+ xml::attributes::iterator i = attrs.find(name);
+
+ BOOST_REQUIRE( i != attrs.end() );
+ attrs.erase(i);
+
+ BOOST_CHECK( is_same_as_file(parser.get_document(), outfile) );
+}
+
+BOOST_AUTO_TEST_CASE( remove_by_iter )
+{
+ do_remove_by_iter("attr_one", "attributes/data/04a.out");
+ do_remove_by_iter("attr_two", "attributes/data/04b.out");
+ do_remove_by_iter("attr_three", "attributes/data/04c.out");
+ do_remove_by_iter("attr_four", "attributes/data/04d.out");
+}
+
+
+/*
+ * Test to see if the xml::attributes::remove(const char*) works.
+ */
+
+static void do_remove_by_name(const char *name, const char *outfile)
+{
+ xml::tree_parser parser(test_file_path("attributes/data/04.xml").c_str());
+
+ xml::attributes &attrs = parser.get_document().get_root_node().get_attributes();
+
+ attrs.erase(name);
+
+ BOOST_CHECK( is_same_as_file(parser.get_document(), outfile) );
+}
+
+BOOST_AUTO_TEST_CASE( remove_by_name )
+{
+ do_remove_by_name("attr_one", "attributes/data/04a.out");
+ do_remove_by_name("attr_two", "attributes/data/04b.out");
+ do_remove_by_name("attr_three", "attributes/data/04c.out");
+ do_remove_by_name("attr_four", "attributes/data/04d.out");
+}
+
+
+/*
+ * Test to see if xml::attributes::find() can see DTD default attributes
+ */
+
+BOOST_AUTO_TEST_CASE( find_dtd_default_attr )
+{
+ xml::tree_parser parser(test_file_path("attributes/data/09.xml").c_str());
+
+ BOOST_CHECK( parser.get_document().has_internal_subset() );
+ BOOST_CHECK( parser.get_document().validate() );
+
+ const xml::attributes &attrs =
+ parser.get_document().get_root_node().get_attributes();
+
+ {
+ xml::attributes::const_iterator i = attrs.find("one");
+ BOOST_REQUIRE( i != attrs.end() );
+ BOOST_CHECK_EQUAL( i->get_value(), "1" );
+ ++i;
+ BOOST_CHECK( i == attrs.end() );
+ }
+
+ {
+ xml::attributes::const_iterator i = attrs.find("two");
+ BOOST_REQUIRE( i != attrs.end() );
+ BOOST_CHECK_EQUAL( i->get_value(), "two" );
+ ++i;
+ BOOST_CHECK( i == attrs.end() );
+ }
+
+ {
+ xml::attributes::const_iterator i = attrs.find("three");
+ BOOST_REQUIRE( i != attrs.end() );
+ BOOST_CHECK_EQUAL( i->get_value(), "three" );
+ ++i;
+ BOOST_CHECK( i == attrs.end() );
+ }
+}
+
+
+/*
+ * Test to see if xml::attributes::find() will die when DTD default
+ * attributes are really implied.
+ */
+
+BOOST_AUTO_TEST_CASE( dtd_implied )
+{
+ xml::tree_parser parser(test_file_path("attributes/data/10.xml").c_str());
+
+ BOOST_CHECK( parser.get_document().has_internal_subset() );
+ BOOST_CHECK( parser.get_document().validate() );
+
+ const xml::attributes &attrs =
+ parser.get_document().get_root_node().get_attributes();
+
+ BOOST_CHECK( attrs.find("optional") == attrs.end() );
+}
+
+
+/*
+ * Test to see if the xml::attributes copy constructor works.
+ */
+
+BOOST_AUTO_TEST_CASE( attr_copy_ctor )
+{
+ std::ostringstream ostr;
+ xml::tree_parser parser(test_file_path("attributes/data/08.xml").c_str());
+
+ // make a copy
+ xml::attributes attrs = parser.get_document().get_root_node().get_attributes();
+ xml::attributes::const_iterator i = attrs.begin(), end = attrs.end();
+
+ for ( ; i != end; ++i )
+ ostr << i->get_name() << "=" << i->get_value() << "\n";
+
+ BOOST_CHECK( is_same_as_file(ostr, "attributes/data/08.out") );
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+
+/*
+ * Test to see if the xml::attributes::empty() works.
+ */
+
+BOOST_AUTO_TEST_CASE( attr_empty_a )
+{
+ xml::tree_parser parser(test_file_path("attributes/data/06a.xml").c_str());
+
+ xml::attributes &attrs = parser.get_document().get_root_node().get_attributes();
+
+ BOOST_CHECK( attrs.empty() );
+}
+
+BOOST_AUTO_TEST_CASE( attr_empty_b )
+{
+ xml::tree_parser parser(test_file_path("attributes/data/06b.xml").c_str());
+
+ xml::attributes &attrs = parser.get_document().get_root_node().get_attributes();
+
+ BOOST_CHECK( !attrs.empty() );
+}
+
+
+/*
+ * Test to see if xml::attributes::size() works.
+ */
+
+static int do_get_attr_size(const char *testfile)
+{
+ xml::tree_parser parser(test_file_path(testfile).c_str());
+
+ xml::attributes &attrs = parser.get_document().get_root_node().get_attributes();
+ return attrs.size();
+}
+
+BOOST_AUTO_TEST_CASE( attr_size )
+{
+ BOOST_CHECK_EQUAL( do_get_attr_size("attributes/data/07a.xml"), 0 );
+ BOOST_CHECK_EQUAL( do_get_attr_size("attributes/data/07b.xml"), 1 );
+ BOOST_CHECK_EQUAL( do_get_attr_size("attributes/data/07c.xml"), 2 );
+ BOOST_CHECK_EQUAL( do_get_attr_size("attributes/data/07d.xml"), 3 );
+}
Deleted: trunk/tests/attributes/test_attributes.cxx
===================================================================
--- trunk/tests/attributes/test_attributes.cxx 2012-03-20 01:20:13 UTC (rev 196)
+++ trunk/tests/attributes/test_attributes.cxx 2012-03-20 01:38:42 UTC (rev 197)
@@ -1,288 +0,0 @@
-/*
- * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...)
- * Copyright (C) 2009 Vaclav Slavik (vs...@gm...)
- * All Rights Reserved
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of the Author nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "../test.h"
-
-
-BOOST_AUTO_TEST_SUITE( attributes )
-
-/*
- * Test to see if the xml::attributes function can see all the attributes of
- * a node.
- */
-
-static void do_attr_read(const std::string& prefix)
-{
- std::ostringstream ostr;
-
- xml::tree_parser parser(test_file_path(prefix + ".xml").c_str());
-
- const xml::attributes &attrs = parser.get_document().get_root_node().get_attributes();
- xml::attributes::const_iterator i=attrs.begin(), end=attrs.end();
- for (; i!=end; ++i)
- {
- ostr << i->get_name() << "=" << i->get_value() << "\n";
- }
-
- BOOST_CHECK( is_same_as_file(ostr, prefix + ".out") );
-}
-
-BOOST_AUTO_TEST_CASE( read )
-{
- do_attr_read("attributes/data/01a");
- do_attr_read("attributes/data/01b");
- do_attr_read("attributes/data/01c");
-}
-
-
-/*
- * Test to see if the xml::attributes::insert function works.
- */
-
-BOOST_AUTO_TEST_CASE( insert )
-{
- xml::tree_parser parser(test_file_path("attributes/data/02.xml").c_str());
-
- xml::attributes &attrs = parser.get_document().get_root_node().get_attributes();
- attrs.insert("b", "b");
-
- BOOST_CHECK( is_same_as_file(parser.get_document(), "attributes/data/02.out") );
-}
-
-
-/*
- * Test to see if the xml::attributes::find works.
- */
-
-static bool do_attr_find(const xml::document& doc,
- const char *to_find,
- const char *expected_value)
-{
- const xml::attributes &attrs = doc.get_root_node().get_attributes();
- xml::attributes::const_iterator i = attrs.find(to_find);
-
- if ( i == attrs.end() )
- return false;
-
- BOOST_CHECK_EQUAL( i->get_name(), to_find );
- BOOST_CHECK_EQUAL( i->get_value(), expected_value );
-
- return true;
-}
-
-BOOST_AUTO_TEST_CASE( find )
-{
- xml::tree_parser parser(test_file_path("attributes/data/03.xml").c_str());
- const xml::document& doc = parser.get_document();
-
- BOOST_CHECK( do_attr_find(doc, "one", "1") == true );
- BOOST_CHECK( do_attr_find(doc, "two", "2") == true );
- BOOST_CHECK( do_attr_find(doc, "three", "3") == true );
- BOOST_CHECK( do_attr_find(doc, "missing", NULL) == false );
- BOOST_CHECK( do_attr_find(doc, "also_missing", NULL) == false );
-}
-
-
-/*
- * Test to see if the xml::attributes::remove(iterator) works.
- */
-
-static void do_remove_by_iter(const char *name, const char *outfile)
-{
- xml::tree_parser parser(test_file_path("attributes/data/04.xml").c_str());
-
- xml::attributes &attrs = parser.get_document().get_root_node().get_attributes();
- xml::attributes::iterator i = attrs.find(name);
-
- BOOST_REQUIRE( i != attrs.end() );
- attrs.erase(i);
-
- BOOST_CHECK( is_same_as_file(parser.get_document(), outfile) );
-}
-
-BOOST_AUTO_TEST_CASE( remove_by_iter )
-{
- do_remove_by_iter("attr_one", "attributes/data/04a.out");
- do_remove_by_iter("attr_two", "attributes/data/04b.out");
- do_remove_by_iter("attr_three", "attributes/data/04c.out");
- do_remove_by_iter("attr_four", "attributes/data/04d.out");
-}
-
-
-/*
- * Test to see if the xml::attributes::remove(const char*) works.
- */
-
-static void do_remove_by_name(const char *name, const char *outfile)
-{
- xml::tree_parser parser(test_file_path("attributes/data/04.xml").c_str());
-
- xml::attributes &attrs = parser.get_document().get_root_node().get_attributes();
-
- attrs.erase(name);
-
- BOOST_CHECK( is_same_as_file(parser.get_document(), outfile) );
-}
-
-BOOST_AUTO_TEST_CASE( remove_by_name )
-{
- do_remove_by_name("attr_one", "attributes/data/04a.out");
- do_remove_by_name("attr_two", "attributes/data/04b.out");
- do_remove_by_name("attr_three", "attributes/data/04c.out");
- do_remove_by_name("attr_four", "attributes/data/04d.out");
-}
-
-
-/*
- * Test to see if xml::attributes::find() can see DTD default attributes
- */
-
-BOOST_AUTO_TEST_CASE( find_dtd_default_attr )
-{
- xml::tree_parser parser(test_file_path("attributes/data/09.xml").c_str());
-
- BOOST_CHECK( parser.get_document().has_internal_subset() );
- BOOST_CHECK( parser.get_document().validate() );
-
- const xml::attributes &attrs =
- parser.get_document().get_root_node().get_attributes();
-
- {
- xml::attributes::const_iterator i = attrs.find("one");
- BOOST_REQUIRE( i != attrs.end() );
- BOOST_CHECK_EQUAL( i->get_value(), "1" );
- ++i;
- BOOST_CHECK( i == attrs.end() );
- }
-
- {
- xml::attributes::const_iterator i = attrs.find("two");
- BOOST_REQUIRE( i != attrs.end() );
- BOOST_CHECK_EQUAL( i->get_value(), "two" );
- ++i;
- BOOST_CHECK( i == attrs.end() );
- }
-
- {
- xml::attributes::const_iterator i = attrs.find("three");
- BOOST_REQUIRE( i != attrs.end() );
- BOOST_CHECK_EQUAL( i->get_value(), "three" );
- ++i;
- BOOST_CHECK( i == attrs.end() );
- }
-}
-
-
-/*
- * Test to see if xml::attributes::find() will die when DTD default
- * attributes are really implied.
- */
-
-BOOST_AUTO_TEST_CASE( dtd_implied )
-{
- xml::tree_parser parser(test_file_path("attributes/data/10.xml").c_str());
-
- BOOST_CHECK( parser.get_document().has_internal_subset() );
- BOOST_CHECK( parser.get_document().validate() );
-
- const xml::attributes &attrs =
- parser.get_document().get_root_node().get_attributes();
-
- BOOST_CHECK( attrs.find("optional") == attrs.end() );
-}
-
-
-/*
- * Test to see if the xml::attributes copy constructor works.
- */
-
-BOOST_AUTO_TEST_CASE( attr_copy_ctor )
-{
- std::ostringstream ostr;
- xml::tree_parser parser(test_file_path("attributes/data/08.xml").c_str());
-
- // make a copy
- xml::attributes attrs = parser.get_document().get_root_node().get_attributes();
- xml::attributes::const_iterator i = attrs.begin(), end = attrs.end();
-
- for ( ; i != end; ++i )
- ostr << i->get_name() << "=" << i->get_value() << "\n";
-
- BOOST_CHECK( is_same_as_file(ostr, "attributes/data/08.out") );
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-
-/*
- * Test to see if the xml::attributes::empty() works.
- */
-
-BOOST_AUTO_TEST_CASE( attr_empty_a )
-{
- xml::tree_parser parser(test_file_path("attributes/data/06a.xml").c_str());
-
- xml::attributes &attrs = parser.get_document().get_root_node().get_attributes();
-
- BOOST_CHECK( attrs.empty() );
-}
-
-BOOST_AUTO_TEST_CASE( attr_empty_b )
-{
- xml::tree_parser parser(test_file_path("attributes/data/06b.xml").c_str());
-
- xml::attributes &attrs = parser.get_document().get_root_node().get_attributes();
-
- BOOST_CHECK( !attrs.empty() );
-}
-
-
-/*
- * Test to see if xml::attributes::size() works.
- */
-
-static int do_get_attr_size(const char *testfile)
-{
- xml::tree_parser parser(test_file_path(testfile).c_str());
-
- xml::attributes &attrs = parser.get_document().get_root_node().get_attributes();
- return attrs.size();
-}
-
-BOOST_AUTO_TEST_CASE( attr_size )
-{
- BOOST_CHECK_EQUAL( do_get_attr_size("attributes/data/07a.xml"), 0 );
- BOOST_CHECK_EQUAL( do_get_attr_size("attributes/data/07b.xml"), 1 );
- BOOST_CHECK_EQUAL( do_get_attr_size("attributes/data/07c.xml"), 2 );
- BOOST_CHECK_EQUAL( do_get_attr_size("attributes/data/07d.xml"), 3 );
-}
Copied: trunk/tests/document/test_document.cc (from rev 186, trunk/tests/document/test_document.cxx)
===================================================================
--- trunk/tests/document/test_document.cc (rev 0)
+++ trunk/tests/document/test_document.cc 2012-03-20 01:38:42 UTC (rev 197)
@@ -0,0 +1,439 @@
+/*
+ * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...)
+ * Copyright (C) 2009 Vaclav Slavik (vs...@fa...)
+ * All Rights Reserved
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of the Author nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "../test.h"
+
+#include <boost/iostreams/filtering_stream.hpp>
+#include <boost/iostreams/filter/gzip.hpp>
+
+BOOST_AUTO_TEST_SUITE( document )
+
+/*
+ * This test checks xml::document iteration.
+ */
+
+BOOST_AUTO_TEST_CASE( dump_type )
+{
+ xml::init::substitute_entities(false);
+
+ xml::tree_parser parser(test_file_path("document/data/01.xml").c_str());
+
+ std::ostringstream ostr;
+ xml::node::iterator i = parser.get_document().begin(),
+ end = parser.get_document().end();
+ for (; i!=end; ++i)
+ dump_node_type(ostr, *i);
+
+ BOOST_CHECK( is_same_as_file(ostr, "document/data/01.out") );
+}
+
+
+/*
+ * This test checks xml::document default constructor.
+ */
+
+BOOST_AUTO_TEST_CASE( default_ctor )
+{
+ xml::document doc;
+ BOOST_CHECK( is_same_as_file( doc, "document/data/02.out") );
+}
+
+
+/*
+ * This test checks xml::document constructor that takes the name of the root
+ * node.
+ */
+
+BOOST_AUTO_TEST_CASE( ctor_root_name )
+{
+ xml::document doc("root");
+ BOOST_CHECK( is_same_as_file( doc, "document/data/03.out") );
+}
+
+
+/*
+ * This test checks xml::document constructor that takes a node.
+ */
+
+BOOST_AUTO_TEST_CASE( ctor_root_node )
+{
+ xml::node n("root", "pcdata");
+ xml::document doc(n);
+ BOOST_CHECK( is_same_as_file( doc, "document/data/04.out") );
+}
+
+
+/*
+ * This test checks xml::document copy constructor.
+ */
+
+BOOST_AUTO_TEST_CASE( copy_ctor )
+{
+ xml::node n("root", "pcdata");
+ xml::document doc(n);
+
+ xml::document doc_copy(doc);
+
+ BOOST_CHECK( is_same_as_file( doc_copy, "document/data/04.out") );
+}
+
+
+/*
+ * This test checks xml::document assignment operator.
+ */
+
+BOOST_AUTO_TEST_CASE( assignment_operator )
+{
+ xml::node n("root", "pcdata");
+ xml::document doc(n);
+
+ xml::document doc_copy;
+ doc_copy = doc;
+
+ BOOST_CHECK( is_same_as_file( doc_copy, "document/data/04.out") );
+}
+
+
+/*
+ * This test checks xml::document::get_root_node.
+ */
+
+BOOST_AUTO_TEST_CASE( get_root_node )
+{
+ xml::node n("root", "pcdata");
+ xml::document doc(n);
+
+ BOOST_CHECK( is_same_as_file( doc.get_root_node(), "document/data/04.out") );
+}
+
+
+/*
+ * This test checks xml::document::set_root_node().
+ */
+
+BOOST_AUTO_TEST_CASE( set_root_node )
+{
+ std::ostringstream ostr;
+
+ xml::node n("root", "pcdata");
+
+ xml::document doc;
+ ostr << doc; // blank document
+
+ doc.set_root_node(n);
+ ostr << doc;
+
+ BOOST_CHECK( is_same_as_file( ostr, "document/data/08.out") );
+}
+
+
+/*
+ * This test checks xml::document::get_version().
+ */
+
+BOOST_AUTO_TEST_CASE( get_version )
+{
+ xml::tree_parser parser(test_file_path("document/data/09.xml").c_str());
+
+ BOOST_CHECK_EQUAL( parser.get_document().get_version(), "1.1" );
+}
+
+
+/*
+ * This test checks xml::document::set_version().
+ */
+
+BOOST_AUTO_TEST_CASE( set_version )
+{
+ xml::document doc("root");
+ doc.set_version("1.1");
+
+ BOOST_CHECK( is_same_as_file( doc, "document/data/10.out") );
+}
+
+
+/*
+ * This test checks xml::document::get_encoding().
+ */
+
+BOOST_AUTO_TEST_CASE( get_encoding )
+{
+ xml::tree_parser parser(test_file_path("document/data/11.xml").c_str());
+
+ BOOST_CHECK_EQUAL( parser.get_document().get_encoding(), "UTF-8" );
+}
+
+
+/*
+ * This test checks xml::document::set_encoding().
+ */
+
+BOOST_AUTO_TEST_CASE( set_encoding )
+{
+ xml::document doc("root");
+ doc.set_encoding("UTF-8");
+
+ BOOST_CHECK( is_same_as_file( doc, "document/data/12.out") );
+}
+
+
+/*
+ * This test checks xml::document::get_is_standalone().
+ */
+
+BOOST_AUTO_TEST_CASE( get_is_standalone )
+{
+ xml::tree_parser parser1(test_file_path("document/data/13a.xml").c_str());
+ BOOST_CHECK_EQUAL( parser1.get_document().get_is_standalone(), false );
+
+ xml::tree_parser parser2(test_file_path("document/data/13b.xml").c_str());
+ BOOST_CHECK_EQUAL( parser2.get_document().get_is_standalone(), true );
+}
+
+
+/*
+ * This test checks xml::document::set_is_standalone().
+ */
+
+BOOST_AUTO_TEST_CASE( set_is_standalone )
+{
+ xml::document doc1("root");
+ doc1.set_is_standalone(true);
+ BOOST_CHECK( is_same_as_file( doc1, "document/data/13a.out") );
+
+ xml::document doc2("root");
+ doc2.set_is_standalone(false);
+ BOOST_CHECK( is_same_as_file( doc2, "document/data/13b.out") );
+}
+
+
+/*
+ * This test checks xml::document::process_xinclude()
+ */
+BOOST_AUTO_TEST_CASE( process_xinclude )
+{
+ xml::tree_parser parser(test_file_path("document/data/14.xml").c_str());
+
+ BOOST_CHECK( parser.get_document().process_xinclude() );
+ BOOST_CHECK( is_same_as_file( parser.get_document(), "document/data/14.out") );
+}
+
+
+/*
+ * This test checks xml::document::size()
+ */
+
+BOOST_AUTO_TEST_CASE( size )
+{
+ xml::document doc_01("root");
+ BOOST_CHECK_EQUAL( doc_01.size(), 1 );
+
+ doc_01.push_back(xml::node(xml::node::comment("This is a comment")));
+ BOOST_CHECK_EQUAL( doc_01.size(), 2 );
+
+ xml::document doc_02(doc_01);
+ BOOST_CHECK_EQUAL( doc_02.size(), 2 );
+
+ xml::document doc_03;
+ BOOST_CHECK_EQUAL( doc_03.size(), 1 );
+
+ xml::node n("root");
+ xml::document doc_04(n);
+ BOOST_CHECK_EQUAL( doc_04.size(), 1 );
+}
+
+
+/*
+ * This test checks xml::document::push_back and insert
+ */
+
+BOOST_AUTO_TEST_CASE( push_back_and_insert )
+{
+ xml::document doc("root");
+
+ doc.push_back(xml::node(xml::node::comment(" Comment From push_back ")));
+
+ xml::node::iterator n(doc.insert(xml::node(xml::node::comment("This Will Be Changed"))));
+ n->set_content(" Comment From insert ");
+
+ n = doc.insert(doc.begin(), xml::node(xml::node::pi("test")));
+ n->set_content("one=\"1\"");
+
+ BOOST_CHECK( is_same_as_file( doc, "document/data/17.out") );
+}
+
+
+/*
+ * This test checks xml::document::push_back and insert to make sure they
+ * throw exceptions
+ */
+
+BOOST_AUTO_TEST_CASE( push_back_and_insert_throw )
+{
+ xml::document doc("root");
+
+ BOOST_CHECK_THROW
+ (
+ doc.push_back(xml::node("noway")),
+ xml::exception
+ );
+
+ BOOST_CHECK_THROW
+ (
+ doc.insert(xml::node("noway")),
+ xml::exception
+ );
+
+ BOOST_CHECK_THROW
+ (
+ doc.insert(doc.end(), xml::node("noway")),
+ xml::exception
+ );
+}
+
+
+/*
+ * This test checks xml::document::replace()
+ */
+
+BOOST_AUTO_TEST_CASE( replace )
+{
+ xml::document doc("root");
+
+ xml::node::iterator n(doc.insert(xml::node(xml::node::comment(" To Be Replaced "))));
+ doc.replace(n, xml::node(xml::node::comment(" This is the replacement comment ")));
+
+ BOOST_CHECK( is_same_as_file( doc, "document/data/19.out") );
+}
+
+
+/*
+ * This test checks xml::document::replace() to make sure it throws exceptions
+ */
+
+BOOST_AUTO_TEST_CASE( replace_throw )
+{
+ xml::document doc("root");
+ xml::node::iterator n(doc.insert(xml::node(xml::node::comment(" To Be Replaced "))));
+
+ BOOST_CHECK_THROW
+ (
+ doc.replace(n, xml::node("noway")),
+ xml::exception
+ );
+
+ BOOST_CHECK_THROW
+ (
+ doc.replace(doc.begin(), xml::node(xml::node::comment(" no way "))),
+ xml::exception
+ );
+}
+
+
+/*
+ * This test checks xml::document::erase().
+ */
+
+BOOST_AUTO_TEST_CASE( erase )
+{
+ xml::document doc("root");
+ doc.push_back(xml::node(xml::node::comment(" Comment from push_back ")));
+
+ xml::node::iterator n(doc.insert(xml::node(xml::node::comment(" You should not see me "))));
+ doc.erase(n);
+
+ BOOST_CHECK( is_same_as_file(doc, "document/data/21.out") );
+}
+
+/*
+ * This test checks xml::document::erase() to make sure it throws an
+ * exception.
+ */
+
+BOOST_AUTO_TEST_CASE( cant_erase_root )
+{
+ xml::document doc("root");
+ doc.push_back(xml::node(xml::node::comment(" Comment from push_back ")));
+
+ BOOST_CHECK_THROW
+ (
+ doc.erase(doc.begin(), doc.end()),
+ xml::exception
+ );
+}
+
+
+static const char *TEST_FILE = "test_temp_file";
+
+/*
+ * These tests check xml::docment::save_to_file()
+ */
+
+BOOST_AUTO_TEST_CASE( save_to_file )
+{
+ xml::document doc("root");
+ doc.get_root_node().push_back(xml::node("child"));
+
+ doc.save_to_file(TEST_FILE);
+
+ std::ifstream stream(TEST_FILE);
+ BOOST_CHECK( is_same_as_file(read_file_into_string(stream), "document/data/15.out") );
+
+ remove(TEST_FILE);
+}
+
+
+#ifndef __SUNPRO_CC // SunCC can't compile gzip_decompressor
+BOOST_AUTO_TEST_CASE( save_to_file_gzip )
+{
+ xml::document doc("root");
+ doc.get_root_node().push_back(xml::node("child"));
+
+ doc.save_to_file(TEST_FILE, 9);
+
+ // verify that the file was can be read back as compressed
+ std::ifstream stream(TEST_FILE);
+ boost::iostreams::filtering_stream<boost::iostreams::input> filter;
+ filter.push(boost::iostreams::gzip_decompressor());
+ filter.push(stream);
+ BOOST_CHECK( is_same_as_file(read_file_into_string(filter), "document/data/15.out") );
+
+ // ...and by libxml2 directly too
+ xml::tree_parser parser(TEST_FILE);
+
+ remove(TEST_FILE);
+}
+#endif // !__SUNPRO_CC
+
+
+BOOST_AUTO_TEST_SUITE_END()
Deleted: trunk/tests/document/test_document.cxx
===================================================================
--- trunk/tests/document/test_document.cxx 2012-03-20 01:20:13 UTC (rev 196)
+++ trunk/tests/document/test_document.cxx 2012-03-20 01:38:42 UTC (rev 197)
@@ -1,439 +0,0 @@
-/*
- * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...)
- * Copyright (C) 2009 Vaclav Slavik (vs...@fa...)
- * All Rights Reserved
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of the Author nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "../test.h"
-
-#include <boost/iostreams/filtering_stream.hpp>
-#include <boost/iostreams/filter/gzip.hpp>
-
-BOOST_AUTO_TEST_SUITE( document )
-
-/*
- * This test checks xml::document iteration.
- */
-
-BOOST_AUTO_TEST_CASE( dump_type )
-...
[truncated message content] |