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

Re: Grouping "span" with same @class within mixed cont

Subject: Re: Grouping "span" with same @class within mixed content element
From: Matthieu Ricaud-Dussarget <matthieu.ricaud@xxxxxxxxx>
Date: Tue, 21 Dec 2010 13:03:04 +0100
Re:  Grouping "span" with same @class within mixed cont
Hi David,

Thanks for your explanation.

If I understood well, in my sample :
<span class="bar">text4</span>
<span class="bar">text5</span>

The 2 spans elements would not have been considered adjacent beacause the indentation "create" (or "is") a (whitespace) text node inbetween.

Actually, in my xhtml doc, spans are sometimes inline, sometimes not, and there might be spaces between them when inline.

In xhtml spaces are important, i think you all now the rules : only one space is displayed even when there are more, and a line feed also generate one space on the display screen.

So to be more generic and xhtml indentation/spaces aware, i would like such an input :
<p id="foo"><span class="foo1">text1</span> <span class="foo1">text2</span>
<span class="foo1">text3</span> <span class="foo2">text4</span> <span class="foo2">text5</span>
<span class="foo2">text6</span><span class="foo1">text7</span> <span class="foo1">text8</span>
</p>
to be output like this :
<p id="foo"><span class="foo1">text1 text2 text3</span> <span class="foo2">text4 text5 text6</span><span class="foo1">text7 text8</span>
</p>


I tried the same template as you David, with :
<xsl:for-each-group select="node()" group-adjacent="string(@class) or normalize-space(.)=' '">
which doesn't group anything from my sample above.


string(@class) is a string whereas normalize-space(.)=' ' is a boolean... so my test isn't good?

I'm searching for a solution, any suggestions are welcome !

Matt




Le 20/12/2010 21:40, David Carlisle a icrit :
On 20/12/2010 17:47, Matthieu Ricaud-Dussarget wrote:

what about text()[normalize-space()], i never seen such a predicate, does the normalized-text directly ?

in your sample answer you considered two spans with the same class as adjacent if they were separated by white space.


select="node()" group-adjacent="string(@class)"

would not have considered them adjacent.


so rather than select=node() I used select="text()[normalize-space()]|* which selects just non-white text nodes and elements. In the sequence selected by that expression, the spans with the same class are adjacent as the indentation is not selected


David




--
Matthieu Ricaud
IGS-CP
Service Livre numirique

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.