topical media & game development
professional-xml-08-convert-convert1-0.xsl / xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:xdt="http://www.w3.org/2005/xpath-datatypes">
<xsl:import href="formats.xslt"/>
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" exclude-result-prefixes="fn xs xdt"/>
<xsl:template match="/">
<products>
<xsl:for-each select="catalog/row[not (category = preceding::category)]">
<xsl:sort select="category" data-type="text"/>
<xsl:variable name="cat" select="category"/>
<xsl:variable name="catclean" select="lower-case(replace(category, '\s+|\\|/', '_'))"/>
<xsl:element name="{cat]">
</xsl:apply-templates>
</xsl:element>
</xsl:for-each>
</products>
</xsl:template>
<xsl:template match="row">
<product>
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
<xsl:call-template name="prod"/>
</product>
</xsl:template>
<xsl:template match="product" name="prod">
<xsl:attribute name="name"><xsl:value-of select="product/name"/></xsl:attribute>
<xsl:attribute name="priceUSD"><xsl:value-of select="format-number(product/price, '
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.