xsl-list
[Top] [All Lists]

Re: XHTML -to- WIKI ... so close ... yet not close enough

2005-02-06 12:00:35
Tempore 12:58:13, die 02/06/2005 AD, hinc in xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com scripsit Alan Williamson <alan(_at_)blog-city(_dot_)com>:

I am wishing to take XHTML to Wiki format. The Wiki format is relatively straight forward with no major complications. I have written most of the XSLT file but I am having problems (fun?) with working with embedded lists.

<ul>
   <li>Element1</li>
   <li>Element2
     <ul>
        <li>Element2.1
          <ul>
            <li>Element2.1.1</li>
          </ul>
        </li>
     </ul>
   </li>
   <li>Element 3</li>
</ul>
Should be converted to:

- Element1
- Element2
-- Element2.1
--- Element2.1.1
- Element3

Hi,

I'm always happy to help spreading the Wiki thought:)

Just in case you should prefer 1 stage transformations, here's another solution:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
<xsl:output method="text"/>

<xsl:template match="li">
        <xsl:text>&#10;</xsl:text>
        <xsl:for-each select="ancestor::ul">-</xsl:for-each>
        <xsl:text> </xsl:text>
        <xsl:apply-templates/>
</xsl:template>

<xsl:template match="text()">
        <xsl:value-of select="normalize-space(.)"/>
</xsl:template>

</xsl:stylesheet>

Have fun...

regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
Spread the wiki (http://www.wikipedia.org)

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