Transformasjon fra XML til CSV
Vi har følgende oppgave:
Fra XML til TEXT
Fila olymp4.xsl ser slik ut:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" encoding="UTF-8" /> <xsl:template match="/"> <xsl:text>Olympiske sprintfinalister </xsl:text> <xsl:for-each select="IOC/OlympicGame"> <xsl:text> </xsl:text> <xsl:value-of select="@place"/><xsl:text> </xsl:text> <xsl:value-of select="@year"/> <xsl:text>: </xsl:text> <xsl:for-each select="event"> <xsl:value-of select="@dist"/> <xsl:for-each select="athlet"> <xsl:text>,</xsl:text> <xsl:value-of select="name"/> </xsl:for-each> <xsl:text> </xsl:text> </xsl:for-each> </xsl:for-each> </xsl:template> </xsl:stylesheet>
Resultat https://borres.hiof.no/wep/xslt/ol/xml2csv/output4.txt