subsurface/xslt/DivingLog.xslt

206 lines
6.1 KiB
HTML
Raw Normal View History

Test dives On Tue, Feb 26, 2013 at 6:19 PM, Dirk Hohndel <dirk@hohndel.org> wrote: > Miika Turkia <miika.turkia@gmail.com> writes: > >> On Tue, Feb 26, 2013 at 5:54 PM, Dirk Hohndel <dirk@hohndel.org> wrote: >>> Miika Turkia <miika.turkia@gmail.com> writes: >>> >>>> On Tue, Feb 26, 2013 at 6:45 AM, Dirk Hohndel <dirk@hohndel.org> wrote: >>>>> I added a few test dives exported from other software (Dm3, DiveLog 5.08, >>>>> JDiveLog 10.2 from Mac - last one doesn't parse because of encoding... Also >>>>> a composed XML zip file from DiveLog isn't supported, yet) >>>>> Find them under dives >>>> >>>> Now this gets interesting. Is there ANY logic in the units in the >>>> dives/TestDiveDiveLog5.08.xml? It seems that some of the temperatures >>>> are in C (Airtemp and Watertemp) and some in F (samples). Otherwise I >>>> would guess we are talking metric here, but I do not see any specs >>>> (another log I have seen from DivingLog had all the units in metric, >>>> as far as I could guess). BTW is the Weight in kg or lb? >>> >>> I have purchased DivingLog and should be able to create any combination >>> of data for the test file that we could possibly want. I'll do a set in >>> a moment that describe what SHOULD be there in their notes, maybe that >>> will clear things up. >>> >>> That said, I really want to release 3.0.1 in the next couple of hours, >>> so this may have to wait for 3.0.2 (if we end up needing that) or 3.1. >>> >>>> The divelogs.de UDCF format looks like it shouldn't take long to write >>>> support for. I'll look into it this evening. >>> >>> It is evening for you, right? No pressure, just making sure I understand >>> what may be coming in in patches in the next hour or two >> >> I currently have one version of the DivingLog XSLT. So a bit of >> verification and that could possibly be used as is. However, this >> could use a bit more testing than a new support to make sure things >> are not going to be any worse than they currently are. >> >> I have not started with the UDCF yet, but that could be reasonably >> fast to implement. However, no guarantees. (And yes, it is evening for >> me) > > I can hold off 3.0.1 a couple hours longer if that is a realistic thing > to do. I don't see the UDCF as that important since we have a different > format from them that we support. So I think the best possible DivingLog > support would be my preference. > > I'll add a few more exported dives from DivingLog next (and fix the > naming of the existing ones). In that case, here is the DivingLog XSLT if anyone can give it a test. miika From 4a62058f4f6fd4780f04bce6e1fe45e20abcf33f Mon Sep 17 00:00:00 2001 From: Miika Turkia <miika.turkia@gmail.com> Date: Tue, 26 Feb 2013 17:46:53 +0200 Subject: [PATCH] XSLT for DivingLog Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-26 16:31:22 +00:00
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:strip-space elements="*"/>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<divelog program='subsurface' version='2'>
<dives>
<xsl:apply-templates select="/Divinglog/Logbook/Dive"/>
</dives>
</divelog>
</xsl:template>
<xsl:template match="Dive">
<dive>
<xsl:attribute name="number">
<xsl:value-of select="Number"/>
</xsl:attribute>
<xsl:if test="rating &gt; 0">
<xsl:attribute name="rating">
<xsl:value-of select="Rating"/>
</xsl:attribute>
</xsl:if>
<xsl:attribute name="date">
<xsl:value-of select="Divedate"/>
</xsl:attribute>
<xsl:attribute name="time">
<xsl:value-of select="Entrytime"/>
</xsl:attribute>
<xsl:attribute name="duration">
<xsl:choose>
<xsl:when test="string-length(Divetime) - string-length(translate(./Divetime, '.', '')) = 1">
<xsl:value-of select="concat(substring-before(Divetime, '.'), ':', format-number((substring-after(Divetime, '.') * 60 div 100), '00'), ' min')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat(Divetime, ' min')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<depth>
<xsl:if test="Depth != ''">
<xsl:attribute name="max">
<xsl:value-of select="concat(Depth, ' m')"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="DepthAvg != ''">
<xsl:attribute name="mean">
<xsl:value-of select="concat(DepthAvg, ' m')"/>
</xsl:attribute>
</xsl:if>
Test dives On Tue, Feb 26, 2013 at 6:19 PM, Dirk Hohndel <dirk@hohndel.org> wrote: > Miika Turkia <miika.turkia@gmail.com> writes: > >> On Tue, Feb 26, 2013 at 5:54 PM, Dirk Hohndel <dirk@hohndel.org> wrote: >>> Miika Turkia <miika.turkia@gmail.com> writes: >>> >>>> On Tue, Feb 26, 2013 at 6:45 AM, Dirk Hohndel <dirk@hohndel.org> wrote: >>>>> I added a few test dives exported from other software (Dm3, DiveLog 5.08, >>>>> JDiveLog 10.2 from Mac - last one doesn't parse because of encoding... Also >>>>> a composed XML zip file from DiveLog isn't supported, yet) >>>>> Find them under dives >>>> >>>> Now this gets interesting. Is there ANY logic in the units in the >>>> dives/TestDiveDiveLog5.08.xml? It seems that some of the temperatures >>>> are in C (Airtemp and Watertemp) and some in F (samples). Otherwise I >>>> would guess we are talking metric here, but I do not see any specs >>>> (another log I have seen from DivingLog had all the units in metric, >>>> as far as I could guess). BTW is the Weight in kg or lb? >>> >>> I have purchased DivingLog and should be able to create any combination >>> of data for the test file that we could possibly want. I'll do a set in >>> a moment that describe what SHOULD be there in their notes, maybe that >>> will clear things up. >>> >>> That said, I really want to release 3.0.1 in the next couple of hours, >>> so this may have to wait for 3.0.2 (if we end up needing that) or 3.1. >>> >>>> The divelogs.de UDCF format looks like it shouldn't take long to write >>>> support for. I'll look into it this evening. >>> >>> It is evening for you, right? No pressure, just making sure I understand >>> what may be coming in in patches in the next hour or two >> >> I currently have one version of the DivingLog XSLT. So a bit of >> verification and that could possibly be used as is. However, this >> could use a bit more testing than a new support to make sure things >> are not going to be any worse than they currently are. >> >> I have not started with the UDCF yet, but that could be reasonably >> fast to implement. However, no guarantees. (And yes, it is evening for >> me) > > I can hold off 3.0.1 a couple hours longer if that is a realistic thing > to do. I don't see the UDCF as that important since we have a different > format from them that we support. So I think the best possible DivingLog > support would be my preference. > > I'll add a few more exported dives from DivingLog next (and fix the > naming of the existing ones). In that case, here is the DivingLog XSLT if anyone can give it a test. miika From 4a62058f4f6fd4780f04bce6e1fe45e20abcf33f Mon Sep 17 00:00:00 2001 From: Miika Turkia <miika.turkia@gmail.com> Date: Tue, 26 Feb 2013 17:46:53 +0200 Subject: [PATCH] XSLT for DivingLog Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-26 16:31:22 +00:00
</depth>
<location>
<xsl:for-each select="Country/@Name | City/@Name | Place/@Name">
<xsl:if test="position() != 1"> / </xsl:if>
<xsl:value-of select="."/>
</xsl:for-each>
</location>
<xsl:if test="Place/Lat != ''">
<gps>
<xsl:value-of select="concat(Place/Lat, ' ', Place/Lon)"/>
</gps>
</xsl:if>
<xsl:if test="Buddy/@Names != ''">
<buddy>
<xsl:value-of select="Buddy/@Names"/>
</buddy>
</xsl:if>
<xsl:if test="Divemaster != ''">
<divemaster>
<xsl:value-of select="Divemaster"/>
</divemaster>
</xsl:if>
<cylinder>
<xsl:attribute name="description">
<xsl:value-of select="Tanktype"/>
</xsl:attribute>
<xsl:attribute name="start">
<xsl:value-of select="PresS"/>
</xsl:attribute>
<xsl:attribute name="end">
<xsl:value-of select="PresE"/>
</xsl:attribute>
<xsl:attribute name="size">
<xsl:choose>
<xsl:when test="DblTank = 'False'">
<xsl:value-of select="Tanksize"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="format-number(Tanksize * 2, '#.##')"/>
Test dives On Tue, Feb 26, 2013 at 6:19 PM, Dirk Hohndel <dirk@hohndel.org> wrote: > Miika Turkia <miika.turkia@gmail.com> writes: > >> On Tue, Feb 26, 2013 at 5:54 PM, Dirk Hohndel <dirk@hohndel.org> wrote: >>> Miika Turkia <miika.turkia@gmail.com> writes: >>> >>>> On Tue, Feb 26, 2013 at 6:45 AM, Dirk Hohndel <dirk@hohndel.org> wrote: >>>>> I added a few test dives exported from other software (Dm3, DiveLog 5.08, >>>>> JDiveLog 10.2 from Mac - last one doesn't parse because of encoding... Also >>>>> a composed XML zip file from DiveLog isn't supported, yet) >>>>> Find them under dives >>>> >>>> Now this gets interesting. Is there ANY logic in the units in the >>>> dives/TestDiveDiveLog5.08.xml? It seems that some of the temperatures >>>> are in C (Airtemp and Watertemp) and some in F (samples). Otherwise I >>>> would guess we are talking metric here, but I do not see any specs >>>> (another log I have seen from DivingLog had all the units in metric, >>>> as far as I could guess). BTW is the Weight in kg or lb? >>> >>> I have purchased DivingLog and should be able to create any combination >>> of data for the test file that we could possibly want. I'll do a set in >>> a moment that describe what SHOULD be there in their notes, maybe that >>> will clear things up. >>> >>> That said, I really want to release 3.0.1 in the next couple of hours, >>> so this may have to wait for 3.0.2 (if we end up needing that) or 3.1. >>> >>>> The divelogs.de UDCF format looks like it shouldn't take long to write >>>> support for. I'll look into it this evening. >>> >>> It is evening for you, right? No pressure, just making sure I understand >>> what may be coming in in patches in the next hour or two >> >> I currently have one version of the DivingLog XSLT. So a bit of >> verification and that could possibly be used as is. However, this >> could use a bit more testing than a new support to make sure things >> are not going to be any worse than they currently are. >> >> I have not started with the UDCF yet, but that could be reasonably >> fast to implement. However, no guarantees. (And yes, it is evening for >> me) > > I can hold off 3.0.1 a couple hours longer if that is a realistic thing > to do. I don't see the UDCF as that important since we have a different > format from them that we support. So I think the best possible DivingLog > support would be my preference. > > I'll add a few more exported dives from DivingLog next (and fix the > naming of the existing ones). In that case, here is the DivingLog XSLT if anyone can give it a test. miika From 4a62058f4f6fd4780f04bce6e1fe45e20abcf33f Mon Sep 17 00:00:00 2001 From: Miika Turkia <miika.turkia@gmail.com> Date: Tue, 26 Feb 2013 17:46:53 +0200 Subject: [PATCH] XSLT for DivingLog Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-26 16:31:22 +00:00
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:if test="O2 != ''">
<xsl:attribute name="o2">
<xsl:value-of select="concat(O2, '%')"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="He != ''">
<xsl:attribute name="he">
<xsl:value-of select="concat(He, '%')"/>
</xsl:attribute>
</xsl:if>
</cylinder>
<temperature>
<xsl:if test="Airtemp != ''">
<xsl:attribute name="air">
<xsl:value-of select="concat(Airtemp, ' C')"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="Watertemp != ''">
<xsl:attribute name="water">
<xsl:value-of select="concat(Watertemp, ' C')"/>
</xsl:attribute>
</xsl:if>
</temperature>
<suit>
<xsl:value-of select="Divesuit"/>
</suit>
<xsl:if test="Weight != ''">
<weightsystem>
<!-- Is weight always in kilograms? -->
<xsl:attribute name="weight">
<xsl:value-of select="concat(Weight, ' kg')"/>
</xsl:attribute>
<xsl:attribute name="description">
<xsl:value-of select="'unknown'"/>
</xsl:attribute>
</weightsystem>
</xsl:if>
<notes>
<xsl:value-of select="Comments"/>
</notes>
<divecomputer>
<xsl:if test="Computer != ''">
<xsl:attribute name="model">
<xsl:value-of select="Computer"/>
</xsl:attribute>
</xsl:if>
Test dives On Tue, Feb 26, 2013 at 6:19 PM, Dirk Hohndel <dirk@hohndel.org> wrote: > Miika Turkia <miika.turkia@gmail.com> writes: > >> On Tue, Feb 26, 2013 at 5:54 PM, Dirk Hohndel <dirk@hohndel.org> wrote: >>> Miika Turkia <miika.turkia@gmail.com> writes: >>> >>>> On Tue, Feb 26, 2013 at 6:45 AM, Dirk Hohndel <dirk@hohndel.org> wrote: >>>>> I added a few test dives exported from other software (Dm3, DiveLog 5.08, >>>>> JDiveLog 10.2 from Mac - last one doesn't parse because of encoding... Also >>>>> a composed XML zip file from DiveLog isn't supported, yet) >>>>> Find them under dives >>>> >>>> Now this gets interesting. Is there ANY logic in the units in the >>>> dives/TestDiveDiveLog5.08.xml? It seems that some of the temperatures >>>> are in C (Airtemp and Watertemp) and some in F (samples). Otherwise I >>>> would guess we are talking metric here, but I do not see any specs >>>> (another log I have seen from DivingLog had all the units in metric, >>>> as far as I could guess). BTW is the Weight in kg or lb? >>> >>> I have purchased DivingLog and should be able to create any combination >>> of data for the test file that we could possibly want. I'll do a set in >>> a moment that describe what SHOULD be there in their notes, maybe that >>> will clear things up. >>> >>> That said, I really want to release 3.0.1 in the next couple of hours, >>> so this may have to wait for 3.0.2 (if we end up needing that) or 3.1. >>> >>>> The divelogs.de UDCF format looks like it shouldn't take long to write >>>> support for. I'll look into it this evening. >>> >>> It is evening for you, right? No pressure, just making sure I understand >>> what may be coming in in patches in the next hour or two >> >> I currently have one version of the DivingLog XSLT. So a bit of >> verification and that could possibly be used as is. However, this >> could use a bit more testing than a new support to make sure things >> are not going to be any worse than they currently are. >> >> I have not started with the UDCF yet, but that could be reasonably >> fast to implement. However, no guarantees. (And yes, it is evening for >> me) > > I can hold off 3.0.1 a couple hours longer if that is a realistic thing > to do. I don't see the UDCF as that important since we have a different > format from them that we support. So I think the best possible DivingLog > support would be my preference. > > I'll add a few more exported dives from DivingLog next (and fix the > naming of the existing ones). In that case, here is the DivingLog XSLT if anyone can give it a test. miika From 4a62058f4f6fd4780f04bce6e1fe45e20abcf33f Mon Sep 17 00:00:00 2001 From: Miika Turkia <miika.turkia@gmail.com> Date: Tue, 26 Feb 2013 17:46:53 +0200 Subject: [PATCH] XSLT for DivingLog Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-26 16:31:22 +00:00
<xsl:for-each select="Profile/P">
<sample>
<xsl:attribute name="time">
<xsl:value-of select="concat(floor(number(./@Time) div 60), ':', format-number(floor(number(./@Time) mod 60), '00'), ' min')"/>
</xsl:attribute>
<!-- This looks like pure guess work to figure out the unit -->
<xsl:if test="Temp != ''">
<xsl:attribute name="temp">
<xsl:choose>
<xsl:when test="Temp &gt; 32">
<xsl:value-of select="concat(format-number((Temp - 32) * 5 div 9, '0.0'), ' C')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat(Temp, ' C')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:if>
<!-- How does this pressure information work? How do we know
which pressure information is in use?
Until further information, just grab "randomly" the first
pressure reading -->
<xsl:attribute name="pressure">
<xsl:value-of select="Press1"/>
</xsl:attribute>
<xsl:attribute name="depth">
<xsl:value-of select="Depth"/>
</xsl:attribute>
</sample>
</xsl:for-each>
</divecomputer>
Test dives On Tue, Feb 26, 2013 at 6:19 PM, Dirk Hohndel <dirk@hohndel.org> wrote: > Miika Turkia <miika.turkia@gmail.com> writes: > >> On Tue, Feb 26, 2013 at 5:54 PM, Dirk Hohndel <dirk@hohndel.org> wrote: >>> Miika Turkia <miika.turkia@gmail.com> writes: >>> >>>> On Tue, Feb 26, 2013 at 6:45 AM, Dirk Hohndel <dirk@hohndel.org> wrote: >>>>> I added a few test dives exported from other software (Dm3, DiveLog 5.08, >>>>> JDiveLog 10.2 from Mac - last one doesn't parse because of encoding... Also >>>>> a composed XML zip file from DiveLog isn't supported, yet) >>>>> Find them under dives >>>> >>>> Now this gets interesting. Is there ANY logic in the units in the >>>> dives/TestDiveDiveLog5.08.xml? It seems that some of the temperatures >>>> are in C (Airtemp and Watertemp) and some in F (samples). Otherwise I >>>> would guess we are talking metric here, but I do not see any specs >>>> (another log I have seen from DivingLog had all the units in metric, >>>> as far as I could guess). BTW is the Weight in kg or lb? >>> >>> I have purchased DivingLog and should be able to create any combination >>> of data for the test file that we could possibly want. I'll do a set in >>> a moment that describe what SHOULD be there in their notes, maybe that >>> will clear things up. >>> >>> That said, I really want to release 3.0.1 in the next couple of hours, >>> so this may have to wait for 3.0.2 (if we end up needing that) or 3.1. >>> >>>> The divelogs.de UDCF format looks like it shouldn't take long to write >>>> support for. I'll look into it this evening. >>> >>> It is evening for you, right? No pressure, just making sure I understand >>> what may be coming in in patches in the next hour or two >> >> I currently have one version of the DivingLog XSLT. So a bit of >> verification and that could possibly be used as is. However, this >> could use a bit more testing than a new support to make sure things >> are not going to be any worse than they currently are. >> >> I have not started with the UDCF yet, but that could be reasonably >> fast to implement. However, no guarantees. (And yes, it is evening for >> me) > > I can hold off 3.0.1 a couple hours longer if that is a realistic thing > to do. I don't see the UDCF as that important since we have a different > format from them that we support. So I think the best possible DivingLog > support would be my preference. > > I'll add a few more exported dives from DivingLog next (and fix the > naming of the existing ones). In that case, here is the DivingLog XSLT if anyone can give it a test. miika From 4a62058f4f6fd4780f04bce6e1fe45e20abcf33f Mon Sep 17 00:00:00 2001 From: Miika Turkia <miika.turkia@gmail.com> Date: Tue, 26 Feb 2013 17:46:53 +0200 Subject: [PATCH] XSLT for DivingLog Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-26 16:31:22 +00:00
</dive>
</xsl:template>
<!-- convert depth to meters -->
<xsl:template name="depthConvert">
<xsl:param name="depth"/>
<xsl:if test="$depth != ''">
<xsl:value-of select="concat($depth, ' m')"/>
</xsl:if>
</xsl:template>
<!-- end convert depth -->
</xsl:stylesheet>