xsl-list
[Top] [All Lists]

[xsl] a table-of-contents for XHTML problem

2008-06-15 11:47:05
        I wonder, what would be the simplest way to transform a sequence
        of sibling nodes, e. g.:

   <body>
     <h1>Chapter</h1>
     <h2>Section</h2>
     <h3>Subsection</h3>
     <h3>Another subsection</h3>
     <h2>Another section</h2>
   </body>

        into a nested list, like:

   <body>
     <ul>
       <li>Chapter
         <ul>
           <li>Section
             <ul>
               <li>Subsection</li>
               <li>Another subsection</li>
             </ul>
           </li>
           <li>Another section</li>
         </ul>
       </li>
     </ul>
   </body>

        in XSLT 1.0?

        The following conditions are assumed to be true:

        * all the `hN' nodes are the children of a single `body' node;

        * for any consequent elements `hN' and `hM', M <= 1 + N; the
          first child of the `body' node is `h1'; i. e., it's assumed
          that, e. g., the following input could never happen:

   <body>
     <h1>Foo</h1>
     <h3>Bar</h3>
   </body>

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