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

RE: How to cast current-group() ?

Subject: RE: How to cast current-group() ?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 27 Apr 2009 21:30:47 +0100
RE:  How to cast current-group() ?
> the type of current-group() and current-grouping-key() is 
> item()* and xs:anyAtomicType?. I wonder how to cast them to 
> what really is in them.
> 
>    <xsl:for-each-group select="/results/match" group-by="team">
>      <xsl:copy-of
>   select="myfn:MakeTableRow(current-grouping- 
> key(),current-group())"/>
>    </xsl:for-each-group>
> 
> In my example, the function myfh:MakeTabelRow(.,.) takes the 
> parameters as="element(*,my:matchType)*" and as="schema- 
> element(my:team)" respectively both complexTypes. My 
> workaround is to leave the function parameters untyped, not 
> really ingenious...
> 

current-grouping-key() is an atomic value, not an element. You could
construct an element and give it a type by validating it, but I suspect
that's not what you want to do. I would suggest:

<xsl:copy-of select="myfn:MakeTableRow(current-group()[1]/team,
current-group())"/>

though I can't see enough of your code to know whether that will fix the
problem.

Note that unless you're using an XSLT 2.0 processor that does strict static
typing, which is unlikely, as I don't think one exists and I don't think
anyone would be foolish enough to write one, it doesn't matter that the
static type of current-group() is item()* - it's the dynamic type that
matters, and so long as /results/match selects elements that have been
validated against the schema type my:matchType, the function call should
work. I think it's failing on the first argument, not the second, though you
don't show any error messages.

Michael Kay
http://www.saxonica.com/

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.