A
Anna
Hi all.
I am trying to write a stylesheet that will structure the input HTML
file in the following way:
For each heading of level n it needs to enclose the heading and all
its content until the next heading of the same level within the level
tag.
Example
input file:
<body>
<h1>First heading</h1>
Some text for first heading.
<h2>Second heading</h2>
<p>Some text for second heading</p>
<h3>Small heading</h3>
<div>Small text</div>
<h1>Another big heading</h1>
<span>Some text for big heading</span>
<h2>Sub heading for second big heading</h2>
</body>
output file:
<body>
<level1>
<h1>First heading</h1>
Some text for first heading.
<level2>
<h2>Second heading</h2>
<p>Some text for second heading</p>
<level3>
<h3>Small heading</h3>
<div>Small text</div>
</level3>
</level2>
</level1>
<level1>
<h1>Another big heading</h1>
<span>Some text for big heading</span>
<level2>
<h2>Sub heading for second big heading</h2>
</level2>
</level1>
</body>
I am trying to build an xsl which will call apply-templates for inner
elements with another mode, but fail to do it cleanly - I get a lot of
text nodes output multiple times.
Is there a neat way to do such a thing?
Thank you very much for help and sorry if this is an inapropriate
question.
Anna
I am trying to write a stylesheet that will structure the input HTML
file in the following way:
For each heading of level n it needs to enclose the heading and all
its content until the next heading of the same level within the level
tag.
Example
input file:
<body>
<h1>First heading</h1>
Some text for first heading.
<h2>Second heading</h2>
<p>Some text for second heading</p>
<h3>Small heading</h3>
<div>Small text</div>
<h1>Another big heading</h1>
<span>Some text for big heading</span>
<h2>Sub heading for second big heading</h2>
</body>
output file:
<body>
<level1>
<h1>First heading</h1>
Some text for first heading.
<level2>
<h2>Second heading</h2>
<p>Some text for second heading</p>
<level3>
<h3>Small heading</h3>
<div>Small text</div>
</level3>
</level2>
</level1>
<level1>
<h1>Another big heading</h1>
<span>Some text for big heading</span>
<level2>
<h2>Sub heading for second big heading</h2>
</level2>
</level1>
</body>
I am trying to build an xsl which will call apply-templates for inner
elements with another mode, but fail to do it cleanly - I get a lot of
text nodes output multiple times.
Is there a neat way to do such a thing?
Thank you very much for help and sorry if this is an inapropriate
question.
Anna