[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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

Subject: Re: XHTML -to- WIKI ... so close ... yet not close enough
From: omprakash.v@xxxxxxxxxxxxx
Date: Mon, 7 Feb 2005 10:27:36 +0530
xhtml to wiki
Hi,

     Alternately, you may want to try something like below.

Cheers,
Omprakash.V



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

      <xsl:apply-templates select="./*"/>

<xsl:template match="ul">
     <xsl:call-template name="ulist">
     <xsl:with-param name="dash" select="'-'"/>
     </xsl:call-template>
</xsl:template>



<xsl:template name="ulist">
<xsl:param name="dash"/>

     <xsl:for-each select="li">
     <xsl:choose>
     <xsl:when test="name(child::*) = 'ul'">
     <xsl:call-template name="ulist">
     <xsl:with-param name="dash" select="concat($dash, '-')"/>
     </xsl:call-template>
     </xsl:when>
     <xsl:otherwise>
     <xsl:value-of select="$dash"/>
     <BR/>
     <xsl:value-of select="text()"/>
     </xsl:otherwise>
     </xsl:choose>

     </xsl:for-each>
</xsl:template>

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

</xsl:stylesheet>


(Note: This code hasn't been tested)




                                                                                                                   
                    "Joris                                                                                         
                    Gillis"              To:     xsl-list@xxxxxxxxxxxxxxxxxxxxxx                                   
                    <roac@pandora        cc:     (bcc: omprakash.v/Polaris)                                        
                    .be>                 Subject:     Re:  XHTML -to- WIKI ... so close ... yet not close     
                                         enough                                                                    
                    02/07/2005                                                                                     
                    12:30 AM                                                                                       
                    Please                                                                                         
                    respond to                                                                                     
                    xsl-list                                                                                       
                                                                                                                   
                                                                                                                   




Tempore 12:58:13, die 02/06/2005 AD, hinc in
xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Alan Williamson
<alan@xxxxxxxxxxxxx>:

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






This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. 
If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately.
You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification,
distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited.

Visit Us at http://www.polaris.co.in

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.