Subject: RE: alpha comparison From: Kay Michael <Michael.Kay@xxxxxxx> Date: Mon, 10 Apr 2000 10:38:47 +0100 |
> I need to check if the following-sibling has > a child with content <tba> than the current node. > Its a security check to ensure that the input file is > in sorted order (No I won't say why, its too > embarassing). > There's no operator to do alphabetic order comparison, the only thing that does it is xsl:sort. The simplest way to check that a list of strings is in sorted order is to sort it and see if the output equals the input. It's probably possible to improve the following: <xsl:template name="is-sorted"> <!-- test whether the document-order of the supplied $nodes is the same as the sorted order of their string-values --> <xsl:param name="nodes"/> <xsl:variable name="unsorted-nodes"> <xsl:for-each select="$nodes"/> <xsl:value-of select="."/> </xsl:for-each> </xsl:variable> <xsl:variable name="sorted-nodes"> <xsl:for-each select="$nodes"/> <xsl:sort/> <xsl:value-of select="."/> </xsl:for-each> </xsl:variable> <xsl:if test="string($sorted-nodes) != string($unsorted-nodes)"> <xsl:message terminate="yes">Data is not correctly sorted</xsl:message> </xsl:if> </xsl:template> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
alpha comparison, Dave Pawson | Thread | RE: alpha comparison, Pawson, David |
RE: Reference book on XSL?, Kay Michael | Date | Why does this work in IE and not in, Maria Manuel |
Month |