Hmm, what a good idea to use concat as grouping key, i was sure i was
missing something with this technique ;-) !
Everything is clear, and pulling the whitespace inside the span is quite ok.
I jsut did not understand what the mode="g" means as there is no other
template in this mode ?
Or would it means go back to the "global" mode ?
Thanks again,
Matt
Le 21/12/2010 13:27, David Carlisle a écrit :
On 21/12/2010 12:03, Matthieu Ricaud-Dussarget wrote:
Hi David,
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.
yes I suspected that was the case:-)
In the simpler version that I suggested first, I changed the select
not to pick up white space, but kept the simple adjacency test.
You do want to pick up the white space, but then you need a more
complicated rule for testing adjacency.
Something like this, which doesn't quite handle white space as you
asked (as it always pulls it into the grouped span) but may get you
started.
David
bash-3.2$ saxon9 spgr.xml spgr.xsl
<?xml version="1.0" encoding="UTF-8"?><p id="foo"><span
class="foo1">text1 text2 text3 </span><span class="foo2">text4 text5
text6</span><span class="foo1">text7 text8 </span></p>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="p">
<p>
<xsl:copy-of select="@*"/>
<xsl:for-each-group select="node()"
group-adjacent="concat(@class,self::text()[not(normalize-space())]/preceding-sibling::node()[1]/@class)">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:variable name="x">
<xsl:apply-templates select="current-group()" mode="g"/>
</xsl:variable>
<xsl:value-of select="replace($x,'\s+',' ')"/>
</xsl:copy>
</xsl:for-each-group>
</p>
</xsl:template>
</xsl:stylesheet>
David
--~------------------------------------------------------------------
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>
--~--
--
Matthieu Ricaud
IGS-CP
Service Livre numérique
--~------------------------------------------------------------------
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>
--~--