[xsl] Transforming an XML document where the content isn't in a special tag

Subject: [xsl] Transforming an XML document where the content isn't in a special tag
From: Noam Raphael <noamraph@xxxxxxxxx>
Date: Wed, 17 Aug 2005 04:00:36 +0200
Hello,

I'm very new to XSL, so please forgive me if this question is stupid.

I want to transform an XML document which looks like this:

=====================
<header>
First Section
</header>
This section deals with a lot of <a href="bla.htm">things</a>.
One of them, is...

<header>
Second Section
</header>
Now, this section is different, becase...
=====================

into this HTML:

=====================
<h1>First Section</h1>
<p>This section deals with a lot of <a href="bla.htm">things</a>.
One of them, is...</p>
<h1>Second Section</h1>
<p>Now, this section is different, bacause...</p>
=====================

I have a problem with adding the <p></p> tags. The problem is that
their locations depends on the <header> tags. I can, of course, add a
</p> before a header and a <p> after it, but I'll get an extra one at
the beginning and at the end. Can I do this transformation with XSL?
(If it matters, I used <xsl:for-each select="text() | *">)

Thank you very much,
Noam Raphael

Current Thread