possible to convert a CSV to xml using XSLT?
Depends on your CSV and XSLT processor, and even then it can be seen as
some sort of a hack that should be avoided. CSV isn't really the format
that is supposed to be transformed by XSLT, there are better tools for
that.
You can do this hack by "faking" CSV as HTML by simply telling the XSLT
processor that input is HTML. The processor may have this option and
may (should) additionally support the HTML tag optionality, and thus
may interpret the whole CSV file as one HTML paragraph.
For example, using 'xsltproc':
---8<---8<---
$ cat test.csv
1,2,3,4
$ cat csv-mod.xsl
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
$ xsltproc | grep "\--html"
--html: the input document is(are) an HTML file(s)
$ xsltproc --html csv-mod.xsl test.csv
<html><body><p>1,2,3,4
</p></body></html>
---8<---8<---
Once you have the CSV interpreted as HTML, it is just a matter of
converting or stripping the HTML elements and processing the CSV as a
string by some recursive template.
In the end, I guess, it is just a matter of software to provide input
file for the XSLT as a tree, regardless of the original file format
whether it is XML or SGML (HTML), CSV or just text/plain. The software
could read CSV directly and provide input as a one text node or full
tree in some custom predefined tabular structure (like XML Exchange
Table Model DTD), but AFAIK there isn't any such software available
(for a reason).