lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [6144] Make version available for schema selection


From: Greg Chicares
Subject: [lmi-commits] [6144] Make version available for schema selection
Date: Thu, 19 Mar 2015 15:10:42 +0000

Revision: 6144
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=6144
Author:   chicares
Date:     2015-03-19 15:10:42 +0000 (Thu, 19 Mar 2015)
Log Message:
-----------
Make version available for schema selection

Modified Paths:
--------------
    lmi/trunk/multiple_cell_document.cpp
    lmi/trunk/single_cell_document.cpp

Modified: lmi/trunk/multiple_cell_document.cpp
===================================================================
--- lmi/trunk/multiple_cell_document.cpp        2015-03-19 14:27:46 UTC (rev 
6143)
+++ lmi/trunk/multiple_cell_document.cpp        2015-03-19 15:10:42 UTC (rev 
6144)
@@ -131,12 +131,6 @@
         return;
         }
 
-    if(data_source_is_external(parser.document()))
-        {
-        int version = 0; // Not yet available.
-        validate_with_xsd_schema(parser.document(), xsd_schema_name(version));
-        }
-
     // Version 0 should have been handled above.
     LMI_ASSERT(0 < file_version);
     if(class_version() < file_version)
@@ -144,6 +138,11 @@
         fatal_error() << "Incompatible file version." << LMI_FLUSH;
         }
 
+    if(data_source_is_external(parser.document()))
+        {
+        validate_with_xsd_schema(parser.document(), 
xsd_schema_name(file_version));
+        }
+
     case_parms_ .clear();
     class_parms_.clear();
     cell_parms_ .clear();

Modified: lmi/trunk/single_cell_document.cpp
===================================================================
--- lmi/trunk/single_cell_document.cpp  2015-03-19 14:27:46 UTC (rev 6143)
+++ lmi/trunk/single_cell_document.cpp  2015-03-19 15:10:42 UTC (rev 6144)
@@ -90,14 +90,29 @@
 //============================================================================
 void single_cell_document::parse(xml_lmi::dom_parser const& parser)
 {
+    xml::element const& root(parser.root_node(xml_root_name()));
+
+    int file_version = 0;
+    if(!xml_lmi::get_attr(root, "version", file_version))
+        {
+        // Do nothing. Ancient lmi files have no "version" attribute,
+        // and that's okay. Here, 'file_version' is used only for
+        // schema validation, which is performed iff a "data_source"
+        // attribute exists and has a nondefault value--but
+        // "data_source" is a newer attribute than "version", so there
+        // can be no "data_source" without "version".
+        }
+
+    if(class_version() < file_version)
+        {
+        fatal_error() << "Incompatible file version." << LMI_FLUSH;
+        }
+
     if(data_source_is_external(parser.document()))
         {
-        int version = 0; // Not yet available.
-        validate_with_xsd_schema(parser.document(), xsd_schema_name(version));
+        validate_with_xsd_schema(parser.document(), 
xsd_schema_name(file_version));
         }
 
-    xml::element const& root(parser.root_node(xml_root_name()));
-
     xml::const_nodes_view const elements(root.elements());
     LMI_ASSERT(!elements.empty());
     xml::const_nodes_view::const_iterator i(elements.begin());




reply via email to

[Prev in Thread] Current Thread [Next in Thread]