Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. Looking for a way to output CSV

Looking for a way to output CSV

Scheduled Pinned Locked Moved XML / XSL
xmlcsharpquestionlearning
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Online
    P Online
    PIEBALDconsult
    wrote on last edited by
    #1

    I'm working on an XSL stylesheet to transform data from XML to CSV. (With .net 2.0) I have everything working except being able to double-up or escape quote characters within strings. What I understand from the book I have I would need to use EXSLT; A) str:replace B) str:split and str:concat C) regexp:replace I don't want to have to install anything "extra" onto client systems. What other options are there?

    P 1 Reply Last reply
    0
    • P PIEBALDconsult

      I'm working on an XSL stylesheet to transform data from XML to CSV. (With .net 2.0) I have everything working except being able to double-up or escape quote characters within strings. What I understand from the book I have I would need to use EXSLT; A) str:replace B) str:split and str:concat C) regexp:replace I don't want to have to install anything "extra" onto client systems. What other options are there?

      P Online
      P Online
      PIEBALDconsult
      wrote on last edited by
      #2

      Alright, I got it working by using a param with my template and calling it recursively as required.

      <xsl:template match="*">
      <xsl:param name="Cont" select="."/>
      <xsl:if test="@Null='false'">
      xsl:text"</xsl:text><xsl:value-of select="substring-before(concat($Cont,'"'),'"')"/>xsl:text"</xsl:text>
      <xsl:if test="contains($Cont,'"')">
      <xsl:apply-templates select=".">
      <xsl:with-param name="Cont" select="substring-after($Cont,'"')"/>
      </xsl:apply-templates>
      </xsl:if>
      </xsl:if>
      </xsl:template>

      Note the use of concat() in the call to substring-before(). Here the param is named "Cont" and you can think of it as meaning either "contents" or "continuance". Given an initial value of: aaa "bbb" ccc 1) Output "aaa " 2) Recurse with bbb" ccc 3) Output "bbb" 4) Recurse with ccc 5) Output " ccc" Result: "aaa ""bbb"" ccc" I would appreciate any thoughts on this technique.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups