[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] EXSL <func:result> returning a node set
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|