Re: [xsl] small grouping task

Subject: Re: [xsl] small grouping task
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 26 Feb 2009 15:32:12 -0500
At 2009-02-26 12:24 -0800, Fred Christian wrote:
Thanks Ken for the help.
Now I know what specs I need to add. Your second xsl example comes close, you almost read my mind. I will try to add the rest of the requirements succinctly.
I am using Saxon and a xsl 2.0 solution is great.

Good ... anyone who can move to XSLT 2.0 should do so.


> 2), the other making the assumption that each list item is all of the content (except <br/>) that follows each <input/>
Correct. But the first <br/> Not more.

Okay ... but are you sure there will always be at least one? So I just toss the first one and continue on?


Another valid assumption is, After the <br/>

I think the above sentence is incomplete.


Other things to make work are.
-a- There are random text and tags between the '<p class="problem">'
and the first <input>...<br/> pair.

What do you want done with them?


-b- There are text and tags after that last <input>... <br/> pair and the closing </p>
Those need to be preserved.

How are those distinguished from the content of the last <input>?


Your example seems ambiguous as it matches both your "2)" above and your "-b-" above.

In your second xsl, the "-a-" items were removed from the output. And the "-b-" items were wrapped with the last </li> and </ul>. The last </li></ul> needs to end sooner.

Again the ambiguity ... I just missed it the first time.


How does one know when the last <input> element ends? When do the other <input> elements end?

Note my new source a few more tags

Thanks again for supplying ready-to-use data.


...
desired output. Only the <input>.....<br/> pairs are altered

Ummmmmm ... this implies to me that the first <br/> after <input> defines the end of the list item.


What if you had:

   <input> test1 <br/> test2
   <input> test3 <br/>

... what happens to test2?

How about:

 <p class="problem">
   <input> test1 <br/> test2 <br/> <br/>
   <input> test3 <br/> <br/>
   <input> test4
 </p>

... where there are extra or missing <br/> elements?

. . . . . . . . . Ken

--
XQuery/XSLT training in Prague, CZ 2009-03 http://www.xmlprague.cz
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread