Giuseppe Briotti wrote:
The question is how to create a hierarchical div structure, based on
h1, h2, h*... html tags
As example transform this:
<?xml version="1.0" encoding="UTF-8"?>
<radice>
<h1>titolo 1A</h1>
<h2>titolo 2A</h2>
<p>questo è il testo dopo il titolo 2A</p>
<h1>titolo 1B</h1>
<p>questo è il 1° testo dopo il titolo 1B</p>
<p>questo è il 2° testo dopo il titolo 1B</p>
<p>questo è il 3° testo dopo il titolo 1B</p>
</radice>
to this
<?xml version="1.0" encoding="UTF-8"?>
<radice>
<div class="h1">
<h1>titolo 1A</h1>
<div class="h2">
<h2>titolo 2A</h2>
<p>questo è il testo dopo il titolo 2A</p>
</div>
</div>
<div class="h1">
<h1>titolo 1B</h1>
<p>questo è il 1° testo dopo il titolo 1B</p>
<p>questo è il 2° testo dopo il titolo 1B</p>
<p>questo è il 3° testo dopo il titolo 1B</p>
</div>
</radice>
I'm usign XSLT 2.0 and Saxon HE 9.4
So, what I'm missing? Can you suggest a smarter approach?
Use for-each-group group-starting-with, see
http://stackoverflow.com/questions/11693413/using-xslfor-each-group for
an example (there the input is a bit more complicated and the level is
not in h[n] elements but rather in 'name' attributes of 'p' elements but
you then simply need to adjust the group-starting-with pattern to say e.g.
group-starting-with="*[local-name() eq concat('h', $level)]"
--
Martin Honnen --- MVP Data Platform Development
http://msmvps.com/blogs/martin_honnen/
--~------------------------------------------------------------------
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>
--~--