xsl-list
[Top] [All Lists]

[xsl] Changing a Tree Walking, forward walk example

2009-01-23 20:04:59
Hi everyone,

I am having trouble converting this Tree Walking, forward walk example :
http://www.dpawson.co.uk/xsl/sect2/N4486.html#d6060e1105

Into something more related to my problem and I am using XSLT 2.0.
The example in mention will convert this:

<document>
 <para>First para</para>
 <change-start id="c1"/>
 <para>Second para</para>
 <para>Third para</para>
 <change-start id="c2"/>
 <para>Fourth para</para>
 <change-end id="c2"/>
 <para>Fifth para</para>
 <change-end id="c1"/>
 <para>Sixth para</para>
</document>

To this:

<document>
 <para>First para</para>
 <ins id="c1">
   <para>Second para</para>
   <para>Third para</para>
   <ins id="c2">
     <para>Fourth para</para>
   </ins>
   <para>Fifth para</para>
 </ins>
 <para>Sixth para</para>
</document>

The problem is that my list does not have an end list node if a new list starts immediately after an existing list. So for example this:
<document>
   <p>Non List text</p>
   <list>List Heading Type 1</list>
   <p>First item</p>
   <p>Second item</p>
   <list>List Heading Type 2</list>
   <p>First item</p>
   <p>Second item</p>
   <p>Third item</p>
   <list>End List</list>
   <p>Unrelated Text</p>
   <p>Not in a list</p>
   <list>List Heading Type 1</list>
   <p>First item</p>
   <list>End List</list>
   <p>More Unrelated Text</p>
   <p>Not in a list</p>
</document>

Needs to be changed to this:

<document>
   <p>Non List text</p>
   <list>
       <li>First item</li>
       <li>Second item</li>
   </list>
   <list>
       <li>First item</li>
       <li>Second item</li>
       <li>Third item</li>
   </list>
   <p>Unrelated Text</p>
   <p>Not in a list</p>
   <list>
       <li>First item</li>
       <li>Second item</li>
   </list>
   <p>More Unrelated Text</p>
   <p>Not in a list</p>
</document>

I am finding it hard because I need to match a list node that does not contain "End List" to start a list as well as end it. So far I have not been able to detect if I am still in a list before a new list starts, in which case I need to close it and start a new one.

Thanks in advance for any help on this.



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>