xml - Tricky nested list XSLT -


i'm new xslt , bit confused formating lists. basicly need xml structure, there's part of it:

<slideshow>     <slide id="a1">         <title>xml techniques</title>         <paragraph> slideshow prepresents different kind of <bold>xml</bold> techniques </paragraph>         <paragraph> common xml techniques </paragraph>         <numberedlist>             <item> basic xml, dtd (version 1.0) </item>             <item> xhtml </item>             <itemizedlist>                 <item> xhtml 1.0 </item>                 <item> xhtml basic </item>                 <numberedlist>                     <item> mobile phones </item>                     <item> basic set xhtml documents</item>                 </numberedlist>             </itemizedlist>             <item> xml namespace </item>             <item> xsl </item>             <itemizedlist>                 <item> xslt - template based programming language</item>                 <item> xsl-fo - formating output css </item>             </itemizedlist>              <item> programming api (like sax , dom) </item>             <item> xml schemas </item>         </numberedlist>     </slide> .. </slideshow> 

to this:

  1. basic xml, dtd (version 1.0)
    • xhtml 1.0
    • xhtml basics
      1. for mobile phones
      2. basic set xhtml documents
  2. xhtml
  3. xml namespace
  4. xsl
    • xslt - template based programming language
    • xsl-fo - formatting output css
  5. programming api (like sax , dom)
  6. xml schemas

i wanted simple possible, using templates , no complicated xpath masks, seems there's no way.. help? thank you!

actually, trivial in xslt, due it's recursive processing model.

xslt 1.0

<xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output method="html" encoding="utf-8"/> <xsl:strip-space elements="*"/>  <xsl:template match="numberedlist">     <ol>         <xsl:apply-templates/>     </ol> </xsl:template>  <xsl:template match="itemizedlist">     <ul>         <xsl:apply-templates/>     </ul> </xsl:template>  <xsl:template match="item">     <li>         <xsl:value-of select="." />     </li> </xsl:template>  <xsl:template match="text()"/>  </xsl:stylesheet> 

result

<ol>    <li> basic xml, dtd (version 1.0) </li>    <li> xhtml </li>    <ul>       <li> xhtml 1.0 </li>       <li> xhtml basic </li>       <ol>          <li> mobile phones </li>          <li> basic set xhtml documents</li>       </ol>    </ul>    <li> xml namespace </li>    <li> xsl </li>    <ul>       <li> xslt - template based programming language</li>       <li> xsl-fo - formating output css </li>    </ul>    <li> programming api (like sax , dom) </li>    <li> xml schemas </li> </ol> 

rendered:

enter image description here


Comments