<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="html">
        <result>
            <xsl:apply-templates mode="selclass"
                select="//*/*/preceding-sibling::*[1]/*[position()=last()]/span/node()"/>
        </result>
    </xsl:template>
    <xsl:template match="node()" mode="selclass">
        <xsl:variable name="var_class">
            <xsl:value-of select="normalize-space(.)"/>
        </xsl:variable>
        <xsl:apply-templates mode="selname"
            select="parent::*/parent::*/parent::*/following-sibling::*[1]/parent::*/*/*/preceding-sibling::*[1][last()]/*/*/*/*/text()">
            <xsl:with-param name="var_class" select="$var_class"/>
        </xsl:apply-templates>
    </xsl:template>
    <xsl:template match="node()" mode="selname">
        <xsl:param name="var_class"/>
        <xsl:variable name="var_name">
            <xsl:value-of select="normalize-space(.)"/>
        </xsl:variable>
        <xsl:apply-templates mode="display"
            select="parent::*/parent::*/parent::*/parent::*/parent::*/following-sibling::*[1]/*/*/*/*/text()">
            <xsl:with-param name="var_class" select="$var_class"/>
            <xsl:with-param name="var_name" select="$var_name"/>
        </xsl:apply-templates>
    </xsl:template>
    <xsl:template match="node()" mode="display">
        <xsl:param name="var_class"/>
        <xsl:param name="var_name"/>
        <xsl:variable name="var_value">
            <xsl:value-of select="normalize-space(.)"/>
        </xsl:variable>
        <triple>
            <xsl:attribute name="class">
                <xsl:value-of select="$var_class"/>
            </xsl:attribute>
            <xsl:attribute name="name">
                <xsl:value-of select="$var_name"/>
            </xsl:attribute>
            <xsl:attribute name="value">
                <xsl:value-of select="$var_value"/>
            </xsl:attribute>
        </triple>
    </xsl:template>
</xsl:stylesheet>

