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

RE: value-of w/separator and nodes

Subject: RE: value-of w/separator and nodes
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 2 Feb 2007 17:42:04 -0000
RE:  value-of w/separator and nodes
If you read the rules for value-of, you'll see that adjacent text nodes in
the sequence are concatenated first, before inserting the separator. So if
you have a sequence of text nodes, no separator is inserted. It's important
here to understand the subtle distinction between text nodes and strings.

The difference is necessary to ensure that you get the expected and
traditional result from something like

<xsl:function name...>
  <xsl:param name="p" as="xs:string"/>
  <xsl:text>(</xsl:text>
  <xsl:value-of select="$p"/>
  <xsl:text>)</xsl:text>
</xsl:function>

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

> -----Original Message-----
> From: Abel Braaksma [mailto:abel.online@xxxxxxxxx] 
> Sent: 02 February 2007 17:18
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  value-of w/separator and nodes
> 
> Hi List,
> 
> What I understood from the value-of with the separator 
> attribute set is that, for each item in the result set from 
> the select attribute, xpath casting rules are applied, the 
> separator string is appended and so on. I.e.:
> 
> <xsl:value-of select=" ('t', 'e', 's', 't') " separator="|" />
> 
> gives: t|e|s|t
> 
> When the values 't', 'e' etc, are returned from a function, 
> it does not work anymore, unless I provide the function with 
> a type 'xs:string' (or any other atomic type).
> 
> <xsl:value-of select="(for $i in 1 to 100 return my:test())" 
> separator="|" />
> 
>     <xsl:function name="my:test" as="xs:anyAtomicType">
>         <xsl:text>1</xsl:text>
>     </xsl:function>
> 
> returns 1|1| etc, but:
> 
> <xsl:value-of select="(for $i in 1 to 100 return my:test())" 
> separator="|" />
> 
>     <xsl:function name="my:test" >
>         <xsl:text>1</xsl:text>
>     </xsl:function>
> 
> returns 11111
> 
> I suspect it has to do with the result being a node() of type text. 
> However, still the normal casting rules should apply to each 
> item, not? 
> Can someone clarify this a bit for me?
> 
> Cheers,
> -- Abel Braaksma

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-2011 All Rights Reserved.