Re: [xsl] Converting Mixed Content Into Unmixed Content

Subject: Re: [xsl] Converting Mixed Content Into Unmixed Content
From: Alan Gutierrez <alan@xxxxxxxxxxxxxx>
Date: Tue, 27 Nov 2007 11:55:13 -0600

I am sorry, I should have noted that I'm looking for an XSLT 2.0 solution. I'm using Saxon.

Also, I now remember where I've seen this problem before. In the XSLT 2.0 W3C Recommendation under the description of for-each-group.

I'll probably figure this out now. Thank you.

On Nov 27, 2007, at 8:46 AM, Wendell Piez wrote:

Yes, this is a familiar problem, and no, there isn't an obvious answer. "Element splitting" would probably be the closest thing to a normative way of describing it. It's difficult because it's a variety of upconversion, introducing structure that is only implicit in the source data.

The best approach is an XSLT 2.0 approach: you have to treat it as a grouping problem -- use group-adjacent with a boolean grouping key (either a node is, or is not, an element you wish to split on).

In XSLT 1.0, most experts would probably approach this with a node- by-node walk across the set of elements to be split. Modes are involved. In my code I have called this a "step and tuck" approach since with each subsequent following sibling, you either tuck it into the element you are building (the new 'p' in your case), or you don't (in your case, turning aside to create a 'ul'). In the latter case, you then have to restart the stepping on the other side.

So, can you use XSLT 2.0? (Please say yes: your maintainer will thank you.)

At 09:14 AM 11/27/2007, you wrote:
From this document....

<p>This is some text.  <ul><li>List item.</li></ul> <strong>This is
strong text.</strong> Also, normal text.</p>

I want to create

<p>This is some text.</p>
<ul><li>List item.</li></ul>
<p><strong>This is strong text.</strong> Also, normal text.</p>

Before I set out to solve this, I want to make sure that there is not
some obvious answer. I am pretty sure that I've seen this problem
numerous times when in the past I've followed this list. I'm unable
to think of the right terms to search for, so some suggestions on
search terms are all I really need.

Alan Gutierrez | alan@xxxxxxxxxxxxxx | | 504 717 1428
Think New Orleans |

Current Thread