Re: [xsl] Joining sibling elements

Subject: Re: [xsl] Joining sibling elements
From: Marcin Miłkowski <milek_pl@xxxxx>
Date: Wed, 10 Aug 2005 23:00:50 +0200
Joris Gillis napisaE(a):
Tempore 19:49:30, die 08/10/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Marcin MiEkowski <milek_pl@xxxxx>:

<b>this</b><b> </b><b>is</b><b> </b><b>bold<text</b>

which should be transformed this:

<b>this is bold text</b>


Here's a stylesheet that will handle this simple scenario:

Thanks, I'll try to extend it to my WordML scenario (your version seems to destroy the format and the most annoying parts are still there).


See a sample of the WordML:

<w:r><w:rPr><w:sz w:val="27"/></w:rPr><w:t>It</w:t></w:r><w:r><w:rPr><w:sz w:val="27"/></w:rPr><w:t> </w:t></w:r><w:r><w:rPr><w:sz w:val="27"/></w:rPr><w:t>is</w:t></w:r><w:r><w:rPr><w:sz w:val="27"/></w:rPr><w:t> </w:t></w:r><w:r><w:rPr><w:sz w:val="27"/></w:rPr><w:t>an</w:t></w:r><w:r><w:rPr><w:sz w:val="27"/></w:rPr><w:t> </w:t></w:r><w:r><w:rPr><w:sz w:val="27"/></w:rPr><w:t>honour</w:t></w:r><w:r><w:rPr><w:sz w:val="27"/></w:rPr><w:t> </w:t></w:r><w:r><w:rPr><w:sz w:val="27"/></w:rPr><w:t>to</w:t></w:r><w:r><w:rPr><w:sz w:val="27"/></w:rPr><w:t> </w:t></w:r><w:r><w:rPr><w:sz w:val="27"/></w:rPr><w:t>be</w:t></w:r><w:r><w:rPr><w:sz w:val="27"/></w:rPr><w:t> </w:t></w:r><w:r><w:rPr><w:sz w:val="27"/></w:rPr><w:t>here</w:t></w:r><w:r><w:rPr><w:sz w:val="27"/></w:rPr><w:t> </w:t></w:r><w:r><w:rPr><w:sz w:val="27"/></w:rPr><w:t>in</w:t></w:r><w:r><w:rPr><w:sz w:val="27"/></w:rPr><w:t> </w:t></w:r><w:r><w:rPr><w:sz w:val="27"/></w:rPr><w:t>the</w:t></w:r><w:r><w:rPr><w:sz w:val="27"/></w:rPr><w:t> </w:t></w:r><w:r><w:rPr><w:sz w:val="27"/></w:rPr><w:t>European</w:t></w:r><w:r><w:rPr><w:sz w:val="27"/></w:rPr><w:t> </w:t></w:r><w:r><w:rPr><w:sz w:val="27"/></w:rPr><w:t>Parliament</w:t></w:r><w:r><w:rPr><w:sz w:val="27"/></w:rPr><w:t> </w:t></w:r><w:r><w:rPr><w:sz w:val="27"/></w:rPr><w:t>today.</w:t></w:r>

It is a single sentence, and the translator is supposed to translate it not in MS Word, but in kind of a specialized XML editor with tags visible. The problem is that the task is to join elements <w:t> so the challenge is not really to join immediate siblings but to join (you might say "compress") same groups of tags to make <w:t> enclose more text. If I understand WordML specs the task would be to join <w:t> under the condition that <w:r> enclosing adjacent <w:t> elements contains same formatting tags.

But from your answer I see that this is possible using XSLT (that was my original question) although because of the recursion involved the processing would probably take some time.

Thanks again,
	Marcin

Current Thread