blob: 8f1b34e70f13a8fca481c752b8078f3894c780c7 (
plain)
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
|
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="utf-8"/>
<xsl:template match="tr">
<xsl:choose>
<xsl:when test='td[@colspan="2"]'/>
<xsl:otherwise>
<item>
<name><xsl:value-of select="td[1]"/></name>
<quantity><xsl:value-of select="td[2]"/></quantity>
</item>
<xsl:apply-templates select="following-sibling::tr[1]"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="table">
<xsl:for-each select='tr[td[1][@colspan="2"]]'>
<factory>
<name><xsl:value-of select="td[1]"/></name>
<inventory>
<xsl:apply-templates select="following-sibling::tr[1]"/>
</inventory>
</factory>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
|