I’m looking for a quick and easy way to convert his XML (which is like XHTML) with XSLT 1.0:
<?xml version="1.0" encoding="UTF-8"?>
<html>
<head/>
<body>
<div>Hello<a href="http://google.com">this is the first</a>line.<p>This the second.<br/>And this the third one.</p></div>
</body>
</html>
to this one:
<?xml version="1.0" encoding="UTF-8"?>
<html>
<head/>
<body>
<div>
<p>Hello<a href="http://google.com">this is the first</a>line.</p>
<p>This the second.</p>
<p>And this the third one.</p>
</div>
</body>
</html>
I was thinking of a tree-walk algorithm in XSLT 1.0. What is complicated are e.g. the enclosed <a>links. And also existing <p> should not be removed.
May somebody help me with this? Thanks a lot.
This transformation:
when applied on the provided XML document:
produces the wanted, correct result: