[xsl] Transform inline-block type elements to block-level elements

Subject: [xsl] Transform inline-block type elements to block-level elements
From: "Christian Roth" <roth@xxxxxxxxxxxxxx>
Date: Fri, 24 Nov 2006 22:02:04 +0100
(alternate subject: "Converting XHTML2 <p>- to XHTML1 <p>-content model")

The task is to break logically structured paragraphs with inline-block-
type elements into layout-oriented paragraphs (blocks).

Suppose I have a document with a <p> element (similar to what XHTML2
allows) as follows:

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <p>one
      <em>two
        <ul>
            <li>three</li>
            <li><strong>four<code>
                <ul>
                    <li>five</li>
                </ul>
                six</code></strong></li>
        </ul>
      </em>
    </p>
</root>


then the desired result (similar to XHTML1) would be:

<?xml version="1.0" encoding="UTF-8"?>
<root>  
    <p>one<em>two</em></p>
    <ul>
        <li>
            <p><em>three</em></p>
        </li>
        <li>
            <p><em><strong>four</strong></em></p>
            <ul>
                <li><p><em><strong><code>five</code></strong></em></p></li>
            </ul>
            <p><em><strong><code>six</code></strong></em></p>
        </li>
    </ul>  
</root>

I've thought already about things like storing the nesting of (real)
inlines in a tunneled sequence of element names to be rolled out just
after writing the last block-level (<p>) element, or assigning block-
nesting level values to the inline-block elements in a first step, then
try to create the structure by grouping on levels in a second one, but I
still do not manage to put the pieces together in a usable way.


-Christian

Current Thread