[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XSL for CSV to XML
You may find the code I used in these stylesheets to be helpful:
https://cranesoftwrights.github.io/resources/#csv . . . . . Ken At 2019-02-14 05:53 +0000, Rahul Singh rahulsinghindia15@xxxxxxxxx wrote: Hi,aa|aaaaaaaaaaa|aaaaaaaaaaa</root> Transform" scr1>xmlns:xs="<http://www.w3.org/2001/XMLSchema>http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs"> <xsl:output method="xml" indent="yes" encoding="UTF-8"/> <xsl:template match="/"> <root> <xsl:call-template name="texttorows"> <xsl:with-param name="StringToTransform" select="root"/> </xsl:call-template> </root> </xsl:template> <xsl:template name="texttorows"> <xsl:param name="StringToTransform" select="''"/> <xsl:choose> <xsl:when test="contains($StringToTransform,'
')"> <row> <xsl:call-template name="csvtoxml"> <xsl:with-param name="StringToTransform" select="substring-before($StringToTransform,'
')"/> </xsl:call-template> </row> <xsl:call-template name="texttorows"> <xsl:with-param name="StringToTransform"> <xsl:value-of select="substring-after($StringToTransform,'
')"/> </xsl:with-param> </xsl:call-template> </xsl:when> <xsl:otherwise> <row> <xsl:call-template name="csvtoxml"> <xsl:with-param name="StringToTransform" select="$StringToTransform"/> </xsl:call-template> </row> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="csvtoxml"> <xsl:param name="StringToTransform" select="''"/> <xsl:choose> <xsl:when test="contains($StringToTransform,'|')"> <elem> <xsl:value-of select="substring-before($StringToTransform,'|')"/> </descr1> <xsl:call-template name="csvtoxml"> <xsl:with-param name="StringToTransform"> <xsl:value-of select="substring-after($StringToTransform,'|')"/> </xsl:with-param> </xsl:call-template> </xsl:when> <xsl:otherwise> <elem> <xsl:value-of select="$StringToTransform"/> </descr1> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> aaaaaaaaa</descr1>B B B <elem>aaaaaaaaaaa</descr1> B B B <elem>aaaaaaaaaaa</descr1> B B B <elem>aaaaaaaaaaa</descr1> B B </row> </root> B B B <descr2>aaaaaaaaaaa</descr2> B B B <descr3>aaaaaaaaaaa</descr3> B B B <descr4>aaaaaaaaaaa</descr4> B B </row> </root> -- Contact info, blog, articles, etc. http://www.CraneSoftwrights.com/s/ | Check our site for free XML, XSLT, XSL-FO and UBL developer resources | Streaming hands-on XSLT/XPath 2 training class @ US$45 (5 hours free) |
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|