xsl-list
[Top] [All Lists]

RE: [xsl] Nested lists

2013-11-01 14:43:10
Hi Michael,

Thanks for the excellent advice.

Rick

-----Original Message-----
From: Michael Müller-Hillebrand [mailto:mmh(_at_)docufy(_dot_)de] 
Sent: Friday, November 01, 2013 12:37 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Nested lists

Hi Rick,

Compared to the pain using XSLT1 for a task which XSLT2 can easily handle,
the pain you have to go through if you are forced to change a nice working
XSLT2 solution down to XSLT1 is a real PITA.

But anyhow, I know that sometimes we are forced to do ugly stuff. I would
not be trying to use xsl:key for that problem, as keys are more of an index
across a full document and in your situation everything depends on the order
of elements. In XSLT2 you would use xsl:for-each-group, which in XSLT1
sometimes can be kind-of replicated by "tree walking"
<http://www.dpawson.co.uk/xsl/sect2/N4486.html#d5510e1105>.

As in your example the same class attribute value maybe used for a level 1
or level 2 list item, it might also be a good idea to do some preprocessing,
because otherwise some XPaths may become really long. I guess I would try to
separate the logic of finding the correct list item level from the step of
adding the required <ul>.

Good luck,

- Michael


Am 31.10.2013 um 21:22 schrieb Rick Quatro <rick(_at_)rickquatro(_dot_)com>:

Hi,

I have this for my input XML:

<body>
 <p class="listintro">ListItem_Bullets:</p>
 <p class="listitembullets">&#8226; Item 1</p>  <p 
class="listitembullets">&#8226; Item 2</p>  <p 
class="listitembullets">&#8226; Item 3</p>  <p 
class="normal">Paragraph within a list.</p>  <p 
class="listitembullets">&#8226; Item 4</p>  <p 
class="listitembullets">&#8226; Item 5</p>  <p 
class="listitemindented">&#8226; Item 1 indented</p>  <p 
class="listitemindented">&#8226; Item 2 indented</p>  <p 
class="listitembullets">&#8226; Item 6</p>  <h2>Indented list starts 
here:</h2>  <p class="listitemindented">&#8226; Item 1 indented</p>  
<p class="listitemindented">&#8226; Item 2 indented</p>  <p 
class="listitemindented">&#8226; Item 3 indented</p>  <p 
class="normal">Paragraph within a list.</p>  <p 
class="listitemindented">&#8226; Item 4 indented</p>  <p 
class="listitemindented">&#8226; Item 5 indented</p>  <p 
class="listitemindented">&#8226; Item 6 indented</p> </body>

I want to get this:

<body>
 <p class="listintro">ListItem_Bullets:</p>
 <ul>
    <li>Item 1</li>
    <li>Item 2</li>
    <li>Item 3</li>
 </ul>
 <p class="normal">Paragraph within a list.</p>  <ul>
    <li>Item 4</li>
    <li>Item 5</li>
    <ul>
      <li>Item 1 indented</li>
      <li>Item 2 indented</li>
    </ul>
    <li>Item 6</li>
 </ul>
 <h2>Indented list starts here:</h2>
 <ul>
    <li>. Item 1 indented</li>
    <li>. Item 2 indented</li>
    <li>. Item 3 indented</li>
 </ul>
 <p class="normal">Paragraph within a list.</p>  <ul>
    <li>. Item 4 indented</li>
    <li>. Item 5 indented</li>
    <li>. Item 6 indented</li>
 </ul>
</body>


--
Michael Müller-Hillebrand
mmh(_at_)docufy(_dot_)de




--~------------------------------------------------------------------
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>
--~--


--~------------------------------------------------------------------
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>