[Laszlo-dev] OPML tools

Benjamin Shine ben at laszlosystems.com
Mon Nov 12 12:37:45 PST 2007


Building on that, this stylesheet converts OPML to wikitext:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/ 
Transform">
   <xsl:output method="text" indent="no" />
   <xsl:preserve-space elements="text"/>
   <xsl:template match="/opml">
   ==<xsl:value-of select="head/title"/>== <xsl:text>
   </xsl:text>
       <xsl:for-each select="body/outline">
         <xsl:call-template name="outline">
           <xsl:with-param name="depth" select="1" />
         </xsl:call-template>
       </xsl:for-each>
   </xsl:template>

   <xsl:template name="outline">
     <xsl:param name="depth" select="1"/>
     <xsl:call-template name="indent">
       <xsl:with-param name="char" select="'*'"></xsl:with-param>
       <xsl:with-param name="num" select="number($depth)"></xsl:with- 
param>
     </xsl:call-template>
     <xsl:value-of select="@text"/>
     <xsl:text>
     </xsl:text><xsl:if test="count(outline) > 0">
       <xsl:for-each select="outline">
  <xsl:call-template name="outline">
           <xsl:with-param name="depth" select="$depth + 1"></ 
xsl:with-param>
  </xsl:call-template>
       </xsl:for-each>
     </xsl:if>
   </xsl:template>

   <xsl:template name="indent">
     <xsl:param name="num" />
     <xsl:param name="char" select="'*'" />
<xsl:value-of select="$char"/>
     <xsl:if test="($num > 1)">
       <xsl:call-template name="indent">
         <xsl:with-param name="char" select="$char"></xsl:with-param>
         <xsl:with-param name="num" select="number($num - 1)"></ 
xsl:with-param>
       </xsl:call-template>
     </xsl:if>
   </xsl:template>
</xsl:stylesheet>


On Nov 11, 2007, at 6:45 AM, liorio at laszlosystems.com wrote:

>
> Here is a simple xsl stylesheet I wrote to transform opml (such as  
> produced by OmniOutliner)
> into DocBook.
>
> http://louiorio.com/laszlo/opmldbk.xsl
>
> Lou



More information about the Laszlo-dev mailing list