1<?xml version="1.0"?>
2<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3
4<xsl:output encoding="utf-8"/>
5
6<xsl:template match="tr">
7  <xsl:choose>
8    <xsl:when test='td[@colspan="2"]'/>
9    <xsl:otherwise>
10      <item>
11        <name><xsl:value-of select="td[1]"/></name>
12        <quantity><xsl:value-of select="td[2]"/></quantity>
13      </item>
14      <xsl:apply-templates select="following-sibling::tr[1]"/>
15    </xsl:otherwise>
16  </xsl:choose>
17</xsl:template>
18
19
20
21<xsl:template match="table">
22  <xsl:for-each select='tr[td[1][@colspan="2"]]'>
23    <factory>
24      <name><xsl:value-of select="td[1]"/></name>
25      <inventory>
26        <xsl:apply-templates select="following-sibling::tr[1]"/>
27      </inventory>
28    </factory>
29  </xsl:for-each>
30</xsl:template>
31
32</xsl:stylesheet>
33
34
35
36