ниже document_1.xml
<products>
<product>
<name>Pen</name>
<Quantity>30</Quantity>
</product>
<product>
<name>Pencil</name>
<Quantity>20</Quantity>
</product>
<product>
<name>Bag</name>
<Quantity>25</Quantity>
</product>
</products>
и document_2.xml
- это
<products>
<product>
<name>Pen</name>
<Quantity>10</Quantity>
</product>
<product>
<name>Pencil</name>
<Quantity>5</Quantity>
</product>
<product>
<name>Bag</name>
<Quantity>2</Quantity>
</product>
</products>
и document.xml
- это
<products>
</products>
Ниже мой xsl, я имел обыкновение соединять document_1.xml
и document_2.xml
с document.xml
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/products">
<xsl:copy>
<xsl:apply-templates select="document('document_1.xml')/*/product"/>
<xsl:apply-templates select="document('document_2.xml')/*/product"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()">
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Мне нужен вывод, как показано ниже
Сортировать по количеству ASC
<products>
<product>
<name>Bag</name>
<Quantity>2</Quantity>
</product>
<product>
<name>Pencil</name>
<Quantity>5</Quantity>
</product>
<product>
<name>Pen</name>
<Quantity>10</Quantity>
</product>
<product>
<name>Pencil</name>
<Quantity>20</Quantity>
</product>
<product>
<name>Bag</name>
<Quantity>25</Quantity>
</product>
<product>
<name>Pen</name>
<Quantity>30</Quantity>
</product>