[xsl] From WordprocessingML inline styles to nested inline elements
Subject: [xsl] From WordprocessingML inline styles to nested inline elements|
From: Yves Forkl <Y.Forkl@xxxxxx>
Date: Wed, 21 Mar 2007 15:19:14 +0100
I am dealing with a problem that is somehow related to the one that Jeff
Sese described in the thread "Transforming a Loose Structure" today, but
it is different, so I'm starting a new thread.
Reading up WordprocessingML (from Word 2003), I obtain text runs with
inline styles attached as leaf nodes like this:
<w:t>This is text in bold and italic.</w:t>
In my output, however, the inline styles should nest, and moreover, nest
in a particular order:
<run><b><i>This is text in bold and italic.</i></b></run>
As I am generating the stylesheet rather than hand-writing it, I do not
want to hardwire the structure of the tree to create, but would like to
derive it from a document that only serves the purpose of describing the
desired nesting order:
My idea is to generate from this some code that would take the w:r node
and translate the run's properties, i.e. the children of w:rPr, into
suitably nested elements that are wrapping the contents of w:t.
I am not quite sure which way is the best to tackle the translation
part. Maybe hold the structure description in some variable, then work
down on the tree it is making up, creating each container element only
if there is an instance of the corresponding w:b, w:i etc.? Or
recursively call a named template that adds a container for each w:rPr
child at the right moment?
Do you have any other suggestions?