How to write xsl in the body of products.xsl that will get product name and condition with quantity > 10
products.xml:
<?xml version="1.0" encoding="iso-8859-1"?>
<products>
<product>
<name>soaps</name>
<quantity>10</quantity>
<condition>ready</condition>
</product>
<product>
<name>soaps</name>
<quantity>15</quantity>
<condition>ready</condition>
</product>
<product>
<name>soaps</name>
<quantity>20</quantity>
<condition>ready</condition>
</product>
</products>
products.xsl
<?xml version="1.0"?><!-- DWXMLSource="products.xml" -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<HTML>
<HEAD>
<TITLE> products</TITLE>
</HEAD>
<BODY>
products quantity greater than 10 : <BR/>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
This should do the trick:
This should work: (if provided with a well-formed XML – see comment on question)
Combined with e.g. this template:
Just customize per your needs…
This transformation (no
<xsl:for-each>
and no conditional instructions):when applied on the provided XML document:
produces the wanted result: