[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

EXSL <func:result> returning a node set

Subject: EXSL <func:result> returning a node set
From: Nic Ferrier <nferrier@xxxxxxxxxxxxxxxxxxxx>
Date: 23 Sep 2003 13:40:31 +0100
func result
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] &lt; 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.