xsl-list
[Top] [All Lists]

Re: [xsl] function returning string with string-join()

2010-08-06 08:44:11
  concat('NO', ('x',$input)[($input = (1,2)) +1], '.html')


--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play



On Fri, Aug 6, 2010 at 5:37 AM, ac <ac(_at_)hyperbase(_dot_)com> wrote:

Hi,

I would have done this one simply as
...
<xsl:sequence select="string-join (('NO', if (string($input)) then 
string($input) else 'x', ',html'), '')"/>
...
with the feeling that string-join() is typically faster than concat() and 
string() faster than set operation with predicates, and that the overall 
instruction is easier to read and understand

Am I right?

Cheers,
ac




Am 06.08.2010 um 11:15 schrieb Andrew Welch:



When returning atomics (such as xs:string) you should use xs:sequence
and not xsl:value-of, as value-of will create a text node that then
gets "atomized" to an atomic.


Thanks for that reminder... xsl:for-each-group and regular expressions are 
well settled in my XSLT2 mind-set, but xsl:sequence is more or less ignored.



If you didnt have the xsl:message call you could do:

   <xsl:function name="my:filename" as="xs:string">
       <xsl:param name="input" as="xs:integer" />
       <xsl:sequence select="concat(if ($input = (1,2)) then ('NO1',
'NO2')[$input] else 'NOx', '.html')"/>
   </xsl:function>


Yes, if...

I still try to find the best balance between writing some complex, possibly 
hard to debug multi-line XPath expressions or a tree of XSLT elements. 
Haven't found a general rule for that, and maybe there isn't.

Thanks a lot,

- Michael


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or 
e-mail:<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--