[PATCH 2/4] Move model tagging to xslt

Anton Lundin glance at acc.umu.se
Sat Jun 27 14:38:11 PDT 2015


Instead of replacing all the empty model tags after a csv to xml
transform with some text, just produce that text in the csv to xml
transform instead.

Signed-off-by: Anton Lundin <glance at acc.umu.se>
---
 file.c            |  5 -----
 xslt/csv2xml.xslt | 13 +++++++------
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/file.c b/file.c
index 816002e..48936e2 100644
--- a/file.c
+++ b/file.c
@@ -927,11 +927,6 @@ int parse_csv_file(const char *filename, int timef, int depthf, int tempf, int p
 	previous = dive_table.nr;
 	ret = parse_xml_buffer(filename, mem.buffer, mem.size, &dive_table, (const char **)params);
 
-	// mark imported dives as imported from CSV
-	for (int i = previous; i < dive_table.nr; i++)
-		if (same_string(get_dive(i)->dc.model, ""))
-			get_dive(i)->dc.model = copy_string("Imported from CSV");
-
 	free(mem.buffer);
 	return ret;
 }
diff --git a/xslt/csv2xml.xslt b/xslt/csv2xml.xslt
index 29ebbce..b3dbc7a 100644
--- a/xslt/csv2xml.xslt
+++ b/xslt/csv2xml.xslt
@@ -42,12 +42,13 @@
           <xsl:attribute name="time">
             <xsl:value-of select="concat(substring($time, 2, 2), ':', substring($time, 4, 2))"/>
           </xsl:attribute>
-          <divecomputerid deviceid="ffffffff" model="csv" />
-          <xsl:call-template name="printLine">
-            <xsl:with-param name="line" select="substring-before(//csv, $lf)"/>
-            <xsl:with-param name="lineno" select="'1'"/>
-            <xsl:with-param name="remaining" select="substring-after(//csv, $lf)"/>
-          </xsl:call-template>
+          <divecomputer model="Imported from CSV" deviceid="ffffffff">
+            <xsl:call-template name="printLine">
+              <xsl:with-param name="line" select="substring-before(//csv, $lf)"/>
+              <xsl:with-param name="lineno" select="'1'"/>
+              <xsl:with-param name="remaining" select="substring-after(//csv, $lf)"/>
+            </xsl:call-template>
+          </divecomputer>
         </dive>
       </dives>
     </divelog>
-- 
2.1.4



More information about the subsurface mailing list