-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodfunc.xsl
58 lines (51 loc) · 1.67 KB
/
modfunc.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?xml version="1.0" encoding="UTF-8"?>
<!--
ATLauncher XML to functional mod list CSV
Author: Léa Gris
Date: 2017-05-29
Version: 0.1.0
License: http://www.wtfpl.net/
Example usage:
xsltproc modlist.xsl ATLauncherModpack.xml > modlist.md
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:functx="http://www.functx.com"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.0">
<xsl:strip-space elements="*"/>
<xsl:output method="text" />
<xsl:template name="tokenize">
<xsl:param name="csv" />
<xsl:variable name="first-item" select="normalize-space( substring-before( concat( $csv, ','), ','))" />
<xsl:variable name="hasnext" select="contains( normalize-space($csv),',' )" />
<xsl:choose>
<xsl:when test="$first-item">
<xsl:value-of select="$first-item" />
<xsl:if test="$hasnext">
<xsl:text><![CDATA[<br/>]]></xsl:text>
</xsl:if>
<xsl:call-template name="tokenize">
<xsl:with-param name="csv" select="substring-after($csv,',')" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="*">
<xsl:apply-templates select="mods"/>
</xsl:template>
<xsl:template match="/version/mods">
<xsl:text>"Mod Name", "Mod function"
</xsl:text>
<xsl:apply-templates select="mod">
<xsl:sort select="@name"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="mod">
<xsl:text>"</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>", "</xsl:text>
<xsl:value-of select="@colour"/>
<xsl:text>"
</xsl:text>
</xsl:template>
</xsl:stylesheet>