Subject: [xsl] EXSL <func:result> returning a node set From: Nic Ferrier <nferrier@xxxxxxxxxxxxxxxxxxxx> Date: 23 Sep 2003 13:40:31 +0100 |
I've got a problem with EXSLT functions, I hope someone will be able to help me, I think I managed to get EXSLT's <func:result> to return a node set but I don't seem able to use predicates on the returned set. Here's my functions: <func:function name="pcpfunc:date"> <xsl:param name="el"/> <func:result> <xsl:variable name="dateset" select="str:tokenize($el, ', ')"/> <mydate> <xsl:value-of select="$dateset[3]"/> <xsl:value-of select="$dateset[1]"/> <xsl:if test="$dateset[2] < 10">0</xsl:if><xsl:value-of select="$dateset[2]"/> </mydate> </func:result> </func:function> <xsl:template match="*" mode="pcpdatefunc"> <xsl:copy-of select="pcpfunc:date(.)"/> </xsl:template> <func:function name="pcpfunc:ordered"> <xsl:param name="node-set"/> <func:result> <xsl:apply-templates select="$node-set" mode="pcpdatefunc"> <xsl:sort select="pcpfunc:date(.)" order="descending"/> </xsl:apply-templates> </func:result> </func:function> The function pcpfunc:ordered is supposed to return the transformed node set that is passed in, the transformation causes date fields in a specific format to be translated into a YYYYMMDD format If one uses it like this: <xsl:value-of select="pcpfunc:ordered(/el1/el2/date)"/> it works correctly, but if you use it like this: <xsl:value-of select="pcpfunc:ordered(/el1/el2/date)[1]"/> Clearly, that should pull off the most recent date. But (with libxml2) it fails. I've fixed my immediate problem by having another function, like this: <func:function name="pcpfunc:newest"> <xsl:param name="node-set"/> <func:result> <xsl:apply-templates select="$node-set[1]" mode="pcpdatefunc"> <xsl:sort select="pcpfunc:date(.)" order="descending"/> </xsl:apply-templates> </func:result> </func:function> But it seems a pity to not be able to compose these functions when dealing with node-sets. Am I being over-optimistic? Or is it possible? If so: how? Nic Ferrier http://www.tapsellferrier.co.uk XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Using variables to determ, Jeni Tennison | Thread | RE: [xsl] EXSL <func:result> return, Michael Kay |
[xsl] document function support nee, Halgurt Mustafa Ali | Date | Re: [xsl] The best option?, David Carlisle |
Month |