I’m new to stack overflow and also pretty new to programming. I got assigned my first XSLT task and I’ve come quite far but am stuck now. The task is to write a transformation that will list the contents of three folders in an html file as well as in a csv file.
The html part is complete, I’m working on the csv part now. I managed to have the correct output in the csv, however every record is in one column instead of a new column for every value. Here is the csv part of my code:
<xsl:if test=”report[contains(@output,’csv’)]”>
<xsl:result-document href=”{$output_file_csv}” encoding=”UTF-8″ method=”text”>
xsl:textDAM, Titel, AutorIn, ISBN, EB Erstellt, Status, Duplikate</xsl:text>
<xsl:text>
</xsl:text>
<xsl:for-each select="$prod">
<xsl:variable name="DAM" select="replace(.,'^.+/(ddddd).+$','$1')"/>
<xsl:text>
</xsl:text>
<xsl:variable name="Titel" select="document(.)//*:title"/>
<xsl:text>
</xsl:text>
<xsl:variable name="AutorIn" select="document(.)//*:creator"/>
<xsl:text>
</xsl:text>
<xsl:variable name="ISBN" select="document(.)//*:source"/>
<xsl:text>
</xsl:text>
<xsl:variable name="EBErstellt" select="document(.)//*:date"/>
<xsl:text>
</xsl:text>
<xsl:variable name="Status" select="subsequence($status,number(replace(.,'^.+_(d)%20PRODUKTION.+$','$1')),1)"/>
<xsl:variable name="Duplikate" select="if (count(index-of(document($prod)//*:source,document(.)//*:source)) > 1) then ', Duplikat' else ''"/>
<xsl:text>
</xsl:text>
<xsl:value-of select="concat($DAM, ', ', $Titel, ', ', $AutorIn, ', ', $ISBN, ', ', $EBErstellt, ', ', $Status, $Duplikate)"></xsl:value-of>
<xsl:text>
</xsl:text>
</xsl:for-each>-->
</xsl:result-document>
</xsl:if>
</xsl:template>
Can anyone help with creating a csv header, and mapping each value to the respective column? Also open to any suggestions on how to improve my code – as I said, still a newbie!
Eva is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.