"Jeni Tennison" <jeni(_at_)jenitennison(_dot_)com> wrote in message
news:467234372(_dot_)20030103013521(_at_)jenitennison(_dot_)com(_dot_)(_dot_)(_dot_)
[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