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

Re: A question about the expressive power and limitati

Subject: Re: A question about the expressive power and limitations of XPath 2.0
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Sun, 13 Jan 2002 10:56:10 +0000
 Re: A question about the expressive power and limitati

>> Hmm... the thing that for expressions can't do it aggregate values
>> over a sequence. An easy one would be a str:concat() function that
>> took a sequence as the argument to be concatenated. This could be
>> implemented by recursion with:
>> <xsl:function name="str:concat">
>>   <xsl:param name="strings" type="xs:string*" select="()" />
>>   <xsl:param name="concatenated" type="xs:string" />
>>   <xsl:result
>>     select="if (empty($strings))
>>             then $concatenated
>>             else concat($concatenated,
>>                         $strings[1],
>>                         str:concat($strings[position() > 1])" />
>> </xsl:function>
> I thought that you could achieve concatenation by a simple:
>  <xsl:value-of select="$sequence" separator="''"/>
> or am I wrong? (of course, this is not "pure XPath")

Just had a thought - I think this is still a valid example because
there are certain places where you can't use XSLT - the use attribute
of xsl:key, the select attribute of xsl:sort - so in those situations
you need an XPath expression, can't just use xsl:value-of.

So I think it's still a valid example, especially for xsl:key. There
was a use case mentioned a few days ago, using XForms, where the ref
attribute of xform:bind is a path to an element within xform:instance.
You could solve it with a key if there was some way to generate the
path to an element dynamically. You can get a sequence of strings easy
enough with:

  for $a in (ancestor-or-self::*)
  return (concat('/', name($a), '[',
                 count(preceding-sibling::*[name() = name($a)]) + 1,

but you can't then turn that sequence into a string within the XPath
(aside from ducking out to user-defined functions and using XSLT and
xsl:value-of, but you said that wasn't allowed).



Jeni Tennison

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread


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.
First Name
Last Name
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.