Option 1: Write the headers directly in the conversion. I think it would be advisable, since the fields (percent, quantity, etc.) are hard-wired there.
<ul class="price_desc"> <li class="per"> Процентное содержание жира:<xsl:value-of select="percent" /> </li> <li> Вес куска:<xsl:value-of select="weight"/> </li> <li> Цвет:<xsl:value-of select="color"/> </li> <li> цена:<xsl:value-of select="price"/> </li> <li> Количество:<xsl:value-of select="quantity"/> </li> </ul>
Option 2: Display fields and headers dynamically. The main idea is that using the function concat()
we compute the name of the required node with the header:
<xsl:template match="item"> <article class="price_unit"> <div class="price_img"> <img src="{image}" alt="" width="180" height="200" /> </div> <h1> <xsl:apply-templates select="header"/> </h1> <ul class="price_desc"> <xsl:apply-templates select="*[name() != 'image'][name() != 'header']"/> </ul> </article> </xsl:template> <xsl:template match="item/*[name() != 'image'][name() != 'header']"> <li> <xsl:variable name="tagname"> <xsl:value-of select="concat(name(), '_2')"/> </xsl:variable> <xsl:value-of select="//reference/*[name() = $tagname]"/> <xsl:value-of select="."/> </li> </xsl:template>