[glom] Document: Avoid accumulating old nodes in the XML.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Document: Avoid accumulating old nodes in the XML.
- Date: Wed, 25 Jan 2012 21:15:47 +0000 (UTC)
commit 1e5b559e7941293ff9abef4c485c9654f1d39142
Author: Murray Cumming <murrayc murrayc com>
Date: Wed Jan 25 22:15:34 2012 +0100
Document: Avoid accumulating old nodes in the XML.
* glom/glom_document.dtd: <connection>: Port and server should be
optional because the document can specify a SQLite file instead.
* glom/libglom/document/document.cc: save_before(): Remove all
children of the root node before recreating them, to avoid keeping
old stuff.
ChangeLog | 10 ++++++++++
examples/example_film_manager.glom | 2 +-
examples/example_lesson_planner.glom | 2 +-
examples/example_music_collection.glom | 2 +-
examples/example_project_manager.glom | 2 +-
examples/example_smallbusiness.glom | 3 +--
glom/glom_document.dtd | 6 +++---
glom/libglom/document/document.cc | 11 ++++++++---
8 files changed, 26 insertions(+), 12 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index dd10317..1947202 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2012-01-25 Murray Cumming <murrayc murrayc com>
+ Document: Avoid accumulating old nodes in the XML.
+
+ * glom/glom_document.dtd: <connection>: Port and server should be
+ optional because the document can specify a SQLite file instead.
+ * glom/libglom/document/document.cc: save_before(): Remove all
+ children of the root node before recreating them, to avoid keeping
+ old stuff.
+
+2012-01-25 Murray Cumming <murrayc murrayc com>
+
Examples: Remove multiple trans_set nodes.
* examples/example_film_manager.glom:
diff --git a/examples/example_film_manager.glom b/examples/example_film_manager.glom
index 77bd709..56e61e5 100644
--- a/examples/example_film_manager.glom
+++ b/examples/example_film_manager.glom
@@ -4,7 +4,7 @@
<trans loc="es" val="Gestor de pelÃculas Openismus"/>
<trans loc="sl" val="Upravljalnik filmov Openismus"/>
</trans_set>
- <connection server="localhost" user="" database="glom_film_production_manager" self_hosted="true" port="5435" try_other_ports="false" hosting_mode="postgres_self"/>
+ <connection hosting_mode="postgres_self" server="localhost" port="5435" try_other_ports="false" database="glom_film_production_manager"/>
<table name="accommodation" title="Accommodation">
<example_rows/>
<trans_set>
diff --git a/examples/example_lesson_planner.glom b/examples/example_lesson_planner.glom
index 6b270b3..96966e7 100644
--- a/examples/example_lesson_planner.glom
+++ b/examples/example_lesson_planner.glom
@@ -4,7 +4,7 @@
<trans loc="es" val="Planificador de lecciones"/>
<trans loc="sl" val="Planer pouka"/>
</trans_set>
- <connection server="localhost" user="" database="glom_example_lessonplanner_v2" self_hosted="true" port="5433" try_other_ports="false" hosting_mode="postgres_self"/>
+ <connection hosting_mode="postgres_self" server="localhost" port="5433" try_other_ports="false" database="glom_example_lessonplanner_v2"/>
<table name="invoice_lines" hidden="true">
<example_rows>
<example_row>
diff --git a/examples/example_music_collection.glom b/examples/example_music_collection.glom
index 856ff5b..a6731de 100644
--- a/examples/example_music_collection.glom
+++ b/examples/example_music_collection.glom
@@ -4,7 +4,7 @@
<trans loc="es" val="ColecciÃn de mÃsica"/>
<trans loc="sl" val="Zbirka glasbe"/>
</trans_set>
- <connection server="localhost" database="glom_musiccollection211" port="5433" self_hosted="true" try_other_ports="false" hosting_mode="postgres_self"/>
+ <connection hosting_mode="postgres_self" server="localhost" port="5433" try_other_ports="false" database="glom_musiccollection211"/>
<table name="albums" overview_x="15" overview_y="9" title="Albums">
<example_rows>
<example_row>
diff --git a/examples/example_project_manager.glom b/examples/example_project_manager.glom
index 45477ac..ad6ad86 100644
--- a/examples/example_project_manager.glom
+++ b/examples/example_project_manager.glom
@@ -4,7 +4,7 @@
<trans loc="es" val="Ejemplo de gestor de proyectos"/>
<trans loc="sl" val="Primer zbirke upravljalnika projektov"/>
</trans_set>
- <connection server="localhost" user="" database="glom_example_project_manager_v3" self_hosted="true" port="5433" try_other_ports="false" hosting_mode="postgres_self"/>
+ <connection hosting_mode="postgres_self" server="localhost" port="5433" try_other_ports="false" database="glom_example_project_manager_v3"/>
<table name="contacts" title="Contacts">
<example_rows>
<example_row>
diff --git a/examples/example_smallbusiness.glom b/examples/example_smallbusiness.glom
index 09c5888..c28a60d 100644
--- a/examples/example_smallbusiness.glom
+++ b/examples/example_smallbusiness.glom
@@ -4,8 +4,7 @@
<trans loc="es" val="Ejemplo de negocio pequeÃo"/>
<trans loc="sl" val="Primer zbirke za mala podjetja."/>
</trans_set>
- <connection server="localhost" user="" database="glom_example_smallbusiness_v2" self_hosted="true" port="5433" try_other_ports="false" hosting_mode="postgres_self"/>
- <startup_script/>
+ <connection hosting_mode="postgres_self" server="localhost" port="5433" try_other_ports="false" database="glom_example_smallbusiness_v2"/>
<table name="contacts" default="true" title="Contacts">
<example_rows>
<example_row>
diff --git a/glom/glom_document.dtd b/glom/glom_document.dtd
index a84851f..979f537 100644
--- a/glom/glom_document.dtd
+++ b/glom/glom_document.dtd
@@ -15,7 +15,7 @@ TODO: Should we specify the presence of child text nodes in the ELEMENT somehow?
format_version: The version of this document's format. Older versions of Glom cannot open documents saved in newer versions of the document format.
is_example: Whether this is an example document. Opening an example document causes a new database (and document) to be created.
-->
- <!ELEMENT glom_document (connection?, trans_set?, startup_script?, table*, groups?, library_modules?) >
+ <!ELEMENT glom_document (trans_set?, connection?, startup_script?, table*, groups?, library_modules?) >
<!ATTLIST glom_document
xmlns CDATA #IMPLIED
title CDATA #IMPLIED
@@ -36,10 +36,10 @@ TODO: Should we specify the presence of child text nodes in the ELEMENT somehow?
-->
<!ELEMENT connection EMPTY >
<!ATTLIST connection
- server CDATA "localhost"
+ server CDATA #IMPLIED
user CDATA #IMPLIED
database CDATA #REQUIRED
- port CDATA #REQUIRED
+ port CDATA #IMPLIED
try_other_ports (true|false) "true"
self_hosted (true|false) "false"
hosting_mode CDATA #IMPLIED
diff --git a/glom/libglom/document/document.cc b/glom/libglom/document/document.cc
index 7b7f7dc..b4bcc59 100644
--- a/glom/libglom/document/document.cc
+++ b/glom/libglom/document/document.cc
@@ -3719,10 +3719,16 @@ bool Document::save_before()
auto_cursor = std::auto_ptr<BusyCursor>( new BusyCursor(m_parent_window) );
*/
+ //TODO: Add xmlpp::Document::remove_root_node() to libxml++
xmlpp::Element* nodeRoot = get_node_document();
if(nodeRoot)
{
+ // Remove existing child nodes:
+ xmlpp::Node::NodeList listNodesToRemove = nodeRoot->get_children();
+ for(xmlpp::Node::NodeList::iterator iter = listNodesToRemove.begin(); iter != listNodesToRemove.end(); ++iter)
+ nodeRoot->remove_child(*iter);
+
//Always save as the latest format,
//possibly making it impossible to open this document in older versions of Glom:
m_document_format_version = get_latest_known_document_format_version();
@@ -3730,13 +3736,12 @@ bool Document::save_before()
set_node_attribute_value_as_bool(nodeRoot, GLOM_ATTRIBUTE_IS_EXAMPLE, m_is_example);
set_node_attribute_value_as_bool(nodeRoot, GLOM_ATTRIBUTE_IS_BACKUP, m_is_backup);
+ set_node_attribute_value(nodeRoot, GLOM_ATTRIBUTE_TRANSLATION_ORIGINAL_LOCALE, m_translation_original_locale);
- save_before_translations(nodeRoot, m_database_title);
+ save_before_translations(nodeRoot, m_database_title);
set_child_text_node(nodeRoot, GLOM_NODE_STARTUP_SCRIPT, m_startup_script);
- set_node_attribute_value(nodeRoot, GLOM_ATTRIBUTE_TRANSLATION_ORIGINAL_LOCALE, m_translation_original_locale);
-
xmlpp::Element* nodeConnection = get_node_child_named_with_add(nodeRoot, GLOM_NODE_CONNECTION);
switch(m_hosting_mode)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]