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

Re: Join operation with a csv key in XSL?

Subject: Re: Join operation with a csv key in XSL?
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Fri, 3 Jan 2003 02:27:31 -0800 (PST)
join operation cd key
"Jeni Tennison" <jeni@xxxxxxxxxxxxxxxx> wrote in message
news:467234372.20030103013521@xxxxxxxxxxxxxxxxxxx

[snip]

> The harder part is working through the beforekey and afterkey
> attributes to work out what to do. To do this, you need to create a
> recursive template that works through the string, splitting it at
> commas, and apply-templates to the details element that gets selected
> for the particular 'tag'. I'd use a moded recursive template as
> follows:

One can do this and code his/her 999th recursive template, which is
probably very similar to the previous 998, but still requires effort
and time for coding and debugging.

Or, one can use a template from FXSL: 
   Use the generic "str-foldl" template for any kind of "traversing a
string".
   Use the "str-split-to-words" template for tokenisation.

Here's how one tokenises a string using FXSL:

source.xml:
------------
<info beforekey="a,b,c" afterkey="d,e">
  <details tag="a" path="t1.gif" />
  <details tag="b" path="t2.gif" />
  <details tag="c" path="t3.htm" />
  <details tag="d" path="t4.jpg" />
  <details tag="e" path="t5.doc" />
</info>

transformation.xsl:
--------------------
<xsl:stylesheet version="1.0" 
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

 <xsl:import href="E:\xml\msxml\XML
SDK\Samples\Tests\Generic\FP\Fxsl\Msxsl\strSplit-to-Words.xsl"/>
 
 <xsl:output omit-xml-declaration="yes" indent="yes"/>
 
 <xsl:template match="/">
   <xsl:call-template name="str-split-to-words">
     <xsl:with-param name="pStr" select="/info/@beforekey"/>
     <xsl:with-param name="pDelimiters" select="', ;'"/>
   </xsl:call-template>
 </xsl:template>
</xsl:stylesheet>


Result:
-------
<word>a</word>
<word>b</word>
<word>c</word>


As can be seen, "str-split-to-words" accepts in its second parameter *a
set of* delimiters.




=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

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


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.