order: Generate catalogue of items and prices.

This commit is contained in:
Ricardo Wurmus 2022-06-23 11:04:40 +02:00
parent 4b5ab52612
commit 3e9d56071e
No known key found for this signature in database
GPG Key ID: 197A5888235FACAC
3 changed files with 21 additions and 0 deletions

1
.gitignore vendored
View File

@ -9,6 +9,7 @@ news/????/index.xsl
news/*/.*.??.xml
global/data/texts/.texts.??.xml
global/data/topbanner/.topbanner.??.xml
order/catalogue.xml
.default.xsl
.localmenu.*.xml
.*.xmllist

View File

@ -155,3 +155,6 @@ localmenus: $(SUBDIRS)
all: xmllists
xmllists: $(SUBDIRS)
tools/update_xmllists.sh
order/catalogue.xml: order/catalogue.xsl $(wildcard order/*/item*.xml)
(echo -e "<?xml version=\"1.0\"?>\n<catalogue>"; xsltproc $^; echo "</catalogue>") > $@

17
order/catalogue.xsl Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
<xsl:template match="/itemset">
<xsl:for-each select="item">
<xsl:variable name="prefix"><xsl:value-of select="@id"/></xsl:variable>
<xsl:variable name="price"><xsl:value-of select="@price"/></xsl:variable>
<xsl:for-each select="available">
<xsl:element name="item">
<xsl:attribute name="id"><xsl:value-of select="$prefix"/><xsl:text>_</xsl:text><xsl:value-of select="@size"/></xsl:attribute>
<xsl:attribute name="price"><xsl:value-of select="$price"/></xsl:attribute>
</xsl:element>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>