mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	CSV export: include unquoted quotable fields
Turns out that the initial quoting implementation discarded the fields without quoting. This one ensures we should be getting also that data exported. Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
This commit is contained in:
		
							parent
							
								
									c44ece0ea1
								
							
						
					
					
						commit
						f96d155759
					
				
					 1 changed files with 28 additions and 16 deletions
				
			
		|  | @ -219,6 +219,7 @@ | |||
|     <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:with-param name="all" select="@tags"/> | ||||
|     </xsl:call-template> | ||||
|     <xsl:text>"</xsl:text> | ||||
| 
 | ||||
|  | @ -336,6 +337,7 @@ | |||
|     <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:with-param name="all" select="translate(., $fs, ' ')"/> | ||||
|     </xsl:call-template> | ||||
|     <xsl:text>"</xsl:text> | ||||
|   </xsl:template> | ||||
|  | @ -345,6 +347,7 @@ | |||
|     <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:with-param name="all" select="."/> | ||||
|     </xsl:call-template> | ||||
|     <xsl:text>"</xsl:text> | ||||
|   </xsl:template> | ||||
|  | @ -354,6 +357,7 @@ | |||
|     <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:with-param name="all" select="."/> | ||||
|     </xsl:call-template> | ||||
|     <xsl:text>"</xsl:text> | ||||
|   </xsl:template> | ||||
|  | @ -363,6 +367,7 @@ | |||
|     <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:with-param name="all" select="translate(translate(., $fs, ' '), $lf, '\n')"/> | ||||
|     </xsl:call-template> | ||||
|     <xsl:text>"</xsl:text> | ||||
|   </xsl:template> | ||||
|  | @ -370,22 +375,29 @@ | |||
|   <xsl:template name="quote"> | ||||
|     <xsl:param name="line"/> | ||||
|     <xsl:param name="remaining"/> | ||||
|     <xsl:param name="all"/> | ||||
| 
 | ||||
|     <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:choose> | ||||
|       <xsl:when test="$line = ''"> | ||||
|         <xsl:value-of select="$all"/> | ||||
|       </xsl:when> | ||||
|       <xsl:otherwise> | ||||
|         <xsl:value-of select="concat($line, '"', '"')"/> | ||||
|         <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:with-param name="all" select="$remaining"/> | ||||
|               </xsl:call-template> | ||||
|             </xsl:when> | ||||
|             <xsl:otherwise> | ||||
|               <xsl:value-of select="$remaining" /> | ||||
|             </xsl:otherwise> | ||||
|           </xsl:choose> | ||||
|         </xsl:if> | ||||
|       </xsl:otherwise> | ||||
|     </xsl:choose> | ||||
|   </xsl:template> | ||||
| </xsl:stylesheet> | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue