[thelist] XSLT Challenge

Mark Kennedy mark at eurogamer.net
Thu Apr 3 03:49:46 CST 2003


Hi everybody.  This problem is killing me.

I have the following:

<p>
	Mixed content Paragraph 1
	<br/>
	<br/>
	Paragraph 2 <b>Some more content</b>
	<br/>
	<br/>
	<br/>
	Paragraph 3
	<br/>
	... and so on...
</p>

And I want to split this up, using XSLT, into

<p>
	Mixed content Paragraph 1
</p>
<p>
	Paragraph 2 <b>Some more content</b>
</p>

.. and so on, using 2 or more <br/>s as a paragraph break.  Basically, I wanna
deserialise this bad HTML into something more structural.  It would be the
equivalent of inseting </p><p> everytime you find a <br/><br/> (or more) except
XSLT doesn't really do this sort of thing.  The paragraphs are actually mixed
content, so I need to preserve the HTML inside.

I have had a go, and my understanding of functional programming extends to using
a recursive template to take a node tree, process the first few nodes, write
them to the result tree, then call myself with the remainder of the tree.  It
sounds like it should be simple, but it's just complex enough that I get
thoroughly lost trying to manage it all.  Is there another way?  Or has anybody
already written code to do this that they wouldn't mind sharing?

Help me please :)

Thanks in advance.

Mark


P.S. This HAS to be done in XSLT with no proprietry extensions.





More information about the thelist mailing list