I have an xml file:
<PRODUCTS>
<PRODUCT>
<NAME_EN>jacket</NAME_EN>
<SKU>1</SKU>
<SIZE>
<CODE>01 </CODE>
<DESCRIPTION>34</DESCRIPTION>
</SIZE>
<COLOR>
<DESCRIPTION_EN>black</DESCRIPTION_EN>
</COLOR>
</PRODUCT>
<PRODUCT>
<NAME_EN>jacket</NAME_EN>
<SKU>2</SKU>
<SIZE>
<CODE>02</CODE>
<DESCRIPTION>35</DESCRIPTION>
</SIZE>
<COLOR>
<DESCRIPTION_EN>black</DESCRIPTION_EN>
</COLOR>
</PRODUCT>
<PRODUCT>
<NAME_EN>shoes</NAME_EN>
<SKU>3</SKU>
<SIZE>
<CODE>01</CODE>
<DESCRIPTION>34</DESCRIPTION>
</SIZE>
<COLOR>
<DESCRIPTION_EN>black</DESCRIPTION_EN>
</COLOR>
</PRODUCT>
</PRODUCTS>
I want to use xsl transformation to achieve such result:
<catalog>
<product>
<variants>
<variant>
<sku>1</sku>
<options>
<option>
<code>size</code>
<value>34</value>
</option>
</options>
</variant>
<variant>
<sku>2</sku>
<options>
<option>
<code>size</code>
<value>35</value>
</option>
</options>
</variant>
</variants>
</product>
<product>
<variants>
<variant>
<sku>3</sku>
<options>
<option>
<code>size</code>
<value>34</value>
</option>
</options>
</variant>
</variants>
</product>
</catalog>
What I need is to for-each over all nodes where NAME_EN
and COLOR/DESCRIPTION_EN
where name the same.
I know about such for-each:
<xsl:for-each select="PRODUCTS/PRODUCT[NAME_EN='jacket']">
But it will not fork for me. Is there any way to achieve this?