Subject: Re: [xsl] Closest matching value From: "Stuart Robinson" <serob@xxxxxxxxxxx> Date: Mon, 10 May 2004 22:29:26 +0100 |
Thank you Jeni, I like your solution. I hadn't used starts-with() before, handy function. Cheers. ----- Original Message ----- From: "Jeni Tennison" <jeni@xxxxxxxxxxxxxxxx> To: "Stuart Robinson" <serob@xxxxxxxxxxx> Cc: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Sent: Monday, May 10, 2004 10:07 PM Subject: Re: [xsl] Closest matching value Hi Stuart, > My xsl doc contains a variable holding the Request URI. I want to > select the controller in the domain which contains the closest > matching url value (url values are unique) for the Request URI. Your definition of "closest matching" seems to be "the longest url that matches the start of RequestURI". Assuming the request URI is held in a variable called $RequestURI, you can get this by selecting the <domain> elements where $RequestURI starts with the value of their <url> child, sorting them in descending order by the string length of the url, selecting the first one, and getting its <controller>: <xsl:for-each select="/root/domain[starts-with($RequestURI, url)]"> <xsl:sort select="string-length(url)" data-type="number" order="descending" /> <xsl:if test="position() = 1"> <xsl:value-of select="controller" /> </xsl:if> </xsl:for-each> Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Closest matching value, Jeni Tennison | Thread | [xsl] Page breaks in a table..., Julian L. Hunter |
Re: [xsl] Grouping into a table cel, Jeni Tennison | Date | Re: [xsl] problem: recursive templa, poppe chris |
Month |