mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	CSV export: quote quotes
If a text field contains quotation mark ("), encode this with double
quote ("").
Fixes #1679
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
			
			
This commit is contained in:
		
							parent
							
								
									90b019bc8d
								
							
						
					
					
						commit
						c44ece0ea1
					
				
					 1 changed files with 42 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -216,7 +216,10 @@
 | 
			
		|||
 | 
			
		||||
    <xsl:value-of select="$fs"/>
 | 
			
		||||
    <xsl:text>"</xsl:text>
 | 
			
		||||
    <xsl:value-of select="@tags"/>
 | 
			
		||||
    <xsl:call-template name="quote">
 | 
			
		||||
      <xsl:with-param name="line" select="substring-before(translate(translate(@tags, $fs, ' '), $lf, ' '), '"')"/>
 | 
			
		||||
      <xsl:with-param name="remaining" select="substring-after(translate(translate(@tags, $fs, ' '), $lf, ' '), '"')"/>
 | 
			
		||||
    </xsl:call-template>
 | 
			
		||||
    <xsl:text>"</xsl:text>
 | 
			
		||||
 | 
			
		||||
    <xsl:text>
 | 
			
		||||
| 
						 | 
				
			
			@ -330,25 +333,59 @@
 | 
			
		|||
  <xsl:template match="divemaster">
 | 
			
		||||
    <xsl:value-of select="$fs"/>
 | 
			
		||||
    <xsl:text>"</xsl:text>
 | 
			
		||||
    <xsl:value-of select="."/>
 | 
			
		||||
    <xsl:call-template name="quote">
 | 
			
		||||
      <xsl:with-param name="line" select="substring-before(translate(translate(., $fs, ' '), $lf, ' '), '"')"/>
 | 
			
		||||
      <xsl:with-param name="remaining" select="substring-after(translate(translate(., $fs, ' '), $lf, ' '), '"')"/>
 | 
			
		||||
    </xsl:call-template>
 | 
			
		||||
    <xsl:text>"</xsl:text>
 | 
			
		||||
  </xsl:template>
 | 
			
		||||
  <xsl:template match="buddy">
 | 
			
		||||
    <xsl:value-of select="$fs"/>
 | 
			
		||||
    <xsl:text>"</xsl:text>
 | 
			
		||||
    <xsl:value-of select="."/>
 | 
			
		||||
    <xsl:call-template name="quote">
 | 
			
		||||
      <xsl:with-param name="line" select="substring-before(translate(translate(., $fs, ' '), $lf, ' '), '"')"/>
 | 
			
		||||
      <xsl:with-param name="remaining" select="substring-after(translate(translate(., $fs, ' '), $lf, ' '), '"')"/>
 | 
			
		||||
    </xsl:call-template>
 | 
			
		||||
    <xsl:text>"</xsl:text>
 | 
			
		||||
  </xsl:template>
 | 
			
		||||
  <xsl:template match="suit">
 | 
			
		||||
    <xsl:value-of select="$fs"/>
 | 
			
		||||
    <xsl:text>"</xsl:text>
 | 
			
		||||
    <xsl:value-of select="."/>
 | 
			
		||||
    <xsl:call-template name="quote">
 | 
			
		||||
      <xsl:with-param name="line" select="substring-before(translate(translate(., $fs, ' '), $lf, ' '), '"')"/>
 | 
			
		||||
      <xsl:with-param name="remaining" select="substring-after(translate(translate(., $fs, ' '), $lf, ' '), '"')"/>
 | 
			
		||||
    </xsl:call-template>
 | 
			
		||||
    <xsl:text>"</xsl:text>
 | 
			
		||||
  </xsl:template>
 | 
			
		||||
  <xsl:template match="notes">
 | 
			
		||||
    <xsl:value-of select="$fs"/>
 | 
			
		||||
    <xsl:text>"</xsl:text>
 | 
			
		||||
    <xsl:value-of select="translate(translate(., $fs, ' '), $lf, ' ')"/>
 | 
			
		||||
    <xsl:call-template name="quote">
 | 
			
		||||
      <xsl:with-param name="line" select="substring-before(translate(translate(., $fs, ' '), $lf, '\n'), '"')"/>
 | 
			
		||||
      <xsl:with-param name="remaining" select="substring-after(translate(translate(., $fs, ' '), $lf, '\n'), '"')"/>
 | 
			
		||||
    </xsl:call-template>
 | 
			
		||||
    <xsl:text>"</xsl:text>
 | 
			
		||||
  </xsl:template>
 | 
			
		||||
 | 
			
		||||
  <xsl:template name="quote">
 | 
			
		||||
    <xsl:param name="line"/>
 | 
			
		||||
    <xsl:param name="remaining"/>
 | 
			
		||||
 | 
			
		||||
    <xsl:if test="$line != ''">
 | 
			
		||||
      <xsl:value-of select="concat($line, '"', '"')"/>
 | 
			
		||||
    </xsl:if>
 | 
			
		||||
    <xsl:if test="$remaining != ''">
 | 
			
		||||
	    <xsl:choose>
 | 
			
		||||
		    <xsl:when test="substring-before($remaining, '"') != ''">
 | 
			
		||||
			    <xsl:call-template name="quote">
 | 
			
		||||
				    <xsl:with-param name="line" select="substring-before($remaining, '"')"/>
 | 
			
		||||
				    <xsl:with-param name="remaining" select="substring-after($remaining, '"')"/>
 | 
			
		||||
			    </xsl:call-template>
 | 
			
		||||
		    </xsl:when>
 | 
			
		||||
		    <xsl:otherwise>
 | 
			
		||||
			    <xsl:value-of select="$remaining" />
 | 
			
		||||
		    </xsl:otherwise>
 | 
			
		||||
	    </xsl:choose>
 | 
			
		||||
    </xsl:if>
 | 
			
		||||
  </xsl:template>
 | 
			
		||||
</xsl:stylesheet>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue