Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Sorting by count() in a for-each

From: nasser.alhilal@-----.---
To: NULL
Date: 4/1/2007 9:16:00 PM

On Apr 1, 2:42 pm, nasser.alhi...@gmail.com wrote:
> Hi there,
> I've been trying to get the "apply-templates" to sort the output and
> only show 5 items of the result sorted by count. I'm not able to do
> so. All i get are all the results which aren't sorted. Any insight
> would be much much appreciated. Thanks!
> ~Nas


Good Morning!
Pardon me, the XML is a little large ill try to snip out most
irrelevant info

---------- all.xml --------------
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="patches.xsl"?>
<Scan UIScan="" Session="70845075" Profile="Missing Patches">
	<hosts>
		<host visible="1">
			<hostname>SERVER1</hostname>
			  ...
			  ...
			<hotfixes>
				<product>
					<hotfix>
					  ...
					  ...
					  ...
					</hotfix>
					<hotfix>
					  ...
					  ...
					  ...
					</hotfix>
				</product>
			</hotfixes>
			<alerts>
				<missing_hotfixes>
					<product name="Exchange">
						<hotfix>
						  ...
						  ...
						  ...
						</hotfix>
						<hotfix>
						  ...
						  ...
						  ...
						</hotfix>
					</product>
					<product name="Windows">
						<hotfix>
						  ...
						  ...
						  ...
						</hotfix>
						<hotfix>
						  ...
						  ...
						  ...
						</hotfix>
					</product>
				</missing_hotfixes>
			</alerts>
		</host>
	</hosts>
</Scan>

---------------------------------

--------- patches.xsl -----------
?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform">

<xsl:template match="hotfixit">
	<xsl:if test="position() >= 5">
		<xsl:copy-of select="."/>
	</xsl:if>
</xsl:template>

<xsl:template match="/">
	<html>
	<head><title></title></head>
	<body>
		<table border="1">
			<thead>
				<td>Server</td>
				<td>Patches Missing</td>
			</thead>
			<tbody>
				<xsl:for-each select="/Scan/hosts/host">
				<xsl:apply-templates select="hotfixit">
					<xsl:sort select="count(alerts/missing_hotfixes/product/hotfix)"
data-type="number" order="descending"/>
				</xsl:apply-templates>
				<tr>
					<td><xsl:value-of select="hostname"/></td>
					<td><xsl:value-of select="count(alerts/missing_hotfixes/product/
hotfix)"/></td>
				</tr>
				</xsl:for-each>
			</tbody>
		</table>
	</body>
	</html>
</xsl:template>

</xsl:stylesheet>
---------------------------------

The output doesn't sort out, and neither does it (the apply-templates
tag) display only 5 items, it seems to get ignored.



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent