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

Re: Cannot use a parameter value in the group-startin

Subject: Re: Cannot use a parameter value in the group-starting-with attribute?
From: Peter Desjardins <peter.desjardins.us@xxxxxxxxx>
Date: Fri, 14 May 2010 16:17:51 -0400
Re:  Cannot use a parameter value in the  group-startin
Thank you! That did work. Your clarification is extremely helpful.

Peter

On Fri, May 14, 2010 at 4:07 PM, David Carlisle <davidc@xxxxxxxxx> wrote:
> On 14/05/2010 20:49, Peter Desjardins wrote:
>>
>> Hi. I'm writing a 2.0 stylesheet and my processor is Saxon HE 9.2.1.1.
>> Also, I'm just starting out with XSLT.
>>
>> I am trying to create a template with parameters that will use the
>> for-each-group element. I find that I cannot use a parameter value in
>> the group-starting-with attribute.
>
> There are two problems there, one is that patterns use a restricted syntax
> compared to xpath, but more importantly parameters and variables in xpath
> hold _values_ (as they would in c or fortran) not fragments of syntax 9as
> they would in a shell scripting language)
>
> so when you go   <xsl:with-param name="starting-element" select = "h1" />
>
> the parameter does not hold the fragment of a pattern "h1" it holds the
> result of ebaluating teh expression h1 at that point, which is a possibly
> empty  sequence of h1 nodes.
>
> the this works
>
>  <xsl:for-each select = "$starting-element">
>
> but it is not (at that point) selecting h1 elements it is simply iterating
> over the list of elements that has already been selected and stored in the
> $starting-element variable.
>
> but this could not work even if it were not a syntax error
>
> <xsl:for-each-group select = "*" group-starting-with = "$starting-element">
>
> the grouping attributes need to take patterns or expressions used to filter
> the nodes selected, not take a sequence of nodes.
>
> so do not pass in a sequence of nodes, pass in a string:
>
> <xsl:with-param name="starting-element" select = "'h1'" />
>
> (note the extra quotes(
>
> then you can use that string in a pattern
>
>
> <xsl:for-each-group select = "*"
> group-starting-with = "*[name()=$starting-element]">
>
>
> David

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.