xsl-list
[Top] [All Lists]

RE: [xsl] Join elements by name, with spaces in between

2007-02-12 06:56:04
Try group-adjacent using a grouping key of

group-adjacent="if (. instance of element()) then name(.) else
name(following-sibling::*[1])"

This groups text nodes with the following element, which may not be what you
want. If you only want to retain text nodes if they fall between to element
nodes that are in the same group, you could try to expand the conditional
above.

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

-----Original Message-----
From: Yves Forkl [mailto:Y(_dot_)Forkl(_at_)srz(_dot_)de] 
Sent: 12 February 2007 13:47
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Join elements by name, with spaces in between

Hi,

in XSLT 2.0 I want to join adjacent sibling elements of the 
same name, and spaces in between should be included on this 
occasion. The elements may appear in any order. For instance, 
if a, b and c instances may need joining, whereas x instances 
do never repeat and thus are never joined (this is meant to 
be one single line):

<e><x>x</x> <a>a1</a> <a>a2</a> <b>b</b> <c>c1</c> <c>c2</c> 
<a>a3</a></e>

should become

<e><x>x</x> <a>a1 a2</a> <b>b</b> <c>c1 c2</c> <a>a3</a></e>

My idea is to use for-each-group, but I can't figure out how 
to process the siblings and the possible space in between 
only once and in the right order.

Can you help me?

   Yves


--~------------------------------------------------------------------
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>
--~--