summaryrefslogtreecommitdiffstats
path: root/xslt
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2015-01-26 18:44:38 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-01-26 09:25:29 -0800
commit793758c483210cd472406acbadaf1f4019b019fe (patch)
tree9c8fab3a7f08daebe2be4ae93e4e6bc3ce4afbff /xslt
parent99d95c3436261d37aba4a2a5375fb9af618f3b08 (diff)
downloadsubsurface-793758c483210cd472406acbadaf1f4019b019fe.tar.gz
Move getFieldByIndex template to common templates
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'xslt')
-rw-r--r--xslt/commonTemplates.xsl62
-rw-r--r--xslt/manualcsv2xml.xslt61
2 files changed, 62 insertions, 61 deletions
diff --git a/xslt/commonTemplates.xsl b/xslt/commonTemplates.xsl
index 9900e44d7..7185ce3c0 100644
--- a/xslt/commonTemplates.xsl
+++ b/xslt/commonTemplates.xsl
@@ -205,4 +205,66 @@
<xsl:value-of select="concat($year, '-', $month, '-', $day, ' ', $time)"/>
</xsl:template>
+
+ <xsl:template name="getFieldByIndex">
+ <xsl:param name="index"/>
+ <xsl:param name="line"/>
+ <xsl:param name="remaining"/>
+ <xsl:choose>
+ <xsl:when test="$index > 0">
+ <xsl:choose>
+ <xsl:when test="substring($line, 1, 1) = '&quot;'">
+ <xsl:call-template name="getFieldByIndex">
+ <xsl:with-param name="index" select="$index -1"/>
+ <xsl:with-param name="line" select="substring-after($line, $fs)"/>
+ <xsl:with-param name="remaining" select="$remaining"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="getFieldByIndex">
+ <xsl:with-param name="index" select="$index -1"/>
+ <xsl:with-param name="line" select="substring-after($line, $fs)"/>
+ <xsl:with-param name="remaining" select="$remaining"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="substring($line, 1, 1) = '&quot;'">
+ <xsl:choose>
+ <xsl:when test="substring-before(substring-after($line, '&quot;'), '&quot;') != ''">
+ <xsl:value-of select="substring-before(substring-after($line, '&quot;'), '&quot;')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <!-- quoted string has new line -->
+ <xsl:when test="string-length(substring-after($line, '&quot;')) = string-length(translate(substring-after($line, '&quot;'), '&#34;', ''))">
+ <xsl:value-of select="concat(substring-after($line, '&quot;'), substring-before($remaining, '&quot;'))"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="''"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="substring-before($line,$fs) != ''">
+ <xsl:value-of select="substring-before($line,$fs)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:if test="substring-after($line, $fs) = ''">
+ <xsl:value-of select="$line"/>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
</xsl:stylesheet>
diff --git a/xslt/manualcsv2xml.xslt b/xslt/manualcsv2xml.xslt
index f771df56f..15eb8f00d 100644
--- a/xslt/manualcsv2xml.xslt
+++ b/xslt/manualcsv2xml.xslt
@@ -378,65 +378,4 @@
</xsl:if>
</xsl:template>
- <xsl:template name="getFieldByIndex">
- <xsl:param name="index"/>
- <xsl:param name="line"/>
- <xsl:param name="remaining"/>
- <xsl:choose>
- <xsl:when test="$index > 0">
- <xsl:choose>
- <xsl:when test="substring($line, 1, 1) = '&quot;'">
- <xsl:call-template name="getFieldByIndex">
- <xsl:with-param name="index" select="$index -1"/>
- <xsl:with-param name="line" select="substring-after($line, $fs)"/>
- <xsl:with-param name="remaining" select="$remaining"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="getFieldByIndex">
- <xsl:with-param name="index" select="$index -1"/>
- <xsl:with-param name="line" select="substring-after($line, $fs)"/>
- <xsl:with-param name="remaining" select="$remaining"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test="substring($line, 1, 1) = '&quot;'">
- <xsl:choose>
- <xsl:when test="substring-before(substring-after($line, '&quot;'), '&quot;') != ''">
- <xsl:value-of select="substring-before(substring-after($line, '&quot;'), '&quot;')"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <!-- quoted string has new line -->
- <xsl:when test="string-length(substring-after($line, '&quot;')) = string-length(translate(substring-after($line, '&quot;'), '&#34;', ''))">
- <xsl:value-of select="concat(substring-after($line, '&quot;'), substring-before($remaining, '&quot;'))"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="''"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
-
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test="substring-before($line,$fs) != ''">
- <xsl:value-of select="substring-before($line,$fs)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:if test="substring-after($line, $fs) = ''">
- <xsl:value-of select="$line"/>
- </xsl:if>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
-
- </xsl:template>
</xsl:stylesheet>