Re: [xsl] transform html h1 with a div

Subject: Re: [xsl] transform html h1 with a div
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Thu, 25 Oct 2012 12:15:17 +0200
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 h il testo dopo il titolo 2A</p>
     <h1>titolo 1B</h1>
     <p>questo h il 10 testo dopo il titolo 1B</p>
     <p>questo h il 20 testo dopo il titolo 1B</p>
     <p>questo h il 30 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 h il testo dopo il titolo 2A</p>
          </div>
      </div>

     <div class="h1">
          <h1>titolo 1B</h1>
          <p>questo h il 10 testo dopo il titolo 1B</p>
          <p>questo h il 20 testo dopo il titolo 1B</p>
          <p>questo h il 30 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?

I think http://stackoverflow.com/questions/4547271/xslt-moving-a-grouping-html-elements-into-section-levels is exactly what you want, in case you couldn't adapt the other more complicated grouping.



--


	Martin Honnen --- MVP Data Platform Development
	http://msmvps.com/blogs/martin_honnen/

Current Thread