[xsl] Finding list items in XHTML

Subject: [xsl] Finding list items in XHTML
From: Chris Loschen <loschen@xxxxxxxxxxxxx>
Date: Tue, 12 Nov 2002 12:45:50 -0500
Hi, all!

I've learned a lot from reading the traffic here. At the moment, I've got a problem
that I feel I could almost solve on my own, if I had enough time -- I hope it will
be an easy one.


My input (and output) is essentially XHTML (actually OEB, but they're almost identical). It has
a series of <p> elements, and in two specific cases, I need to convert the <p> elements
to <li> elements. Those cases are:


(1) when the <p> element starts with a <span> with the contents "&#10148; " (yes, that's a character reference), and
(2) when the <p> element starts with a <span> with the contents "&amp;(!!char1!!); " (that string exactly)


In both of these cases, I need to replace the <p> element with an <li> element
and delete the child <span> element entirely.

Perhaps the more difficult part of this is that I also would like to take a series of
such elements and surround the entire series with a <ul> </ul> element structure.
So, basically, I'm trying to find paragraphs that should be list items and setting up
the appropriate list and list item structure.


I know I should start with the identity transform structure, since I don't want to change
anything else in my input (at least not yet). I've gotten that from the FAQ site, and I've
got that set up in my stylesheet. Now I need (I think) something to iterate through the
paragraphs that satisfy one or the other of the above requirements (perhaps for-each?)
along with some sort of XPath expression. That's where I'm feeling foggy.


If I can get this going, I'd get extra credit (no, this is not a homework assignment -- just
an expression) if I could also handle lists inside of lists. Those seem to have the
<span> contents of "&#x10063; " and I'd like to end up with the correct XHTML structure
of


<li>....
   <ul>
    <li>...</li>
   ...
   </ul>
</li>

etc.

I'd greatly appreciate any suggestions or advice. Thank you very much!


--Chris


----------------------------------------------------------------------------------------
Texterity ~ XML and PDF ePublishing Services
----------------------------------------------------------------------------------------
Chris Loschen, XML Developer
Texterity, Inc.
144 Turnpike Road
Southborough, MA 01772 USA
tel: +1.508.804.3033
fax: +1.508.804.3110
email: loschen@xxxxxxxxxxxxx
http://www.texterity.com/


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread