Warning, /frameworks/syntax-highlighting/autotests/input/highlight.xsl is written in an unsupported language. File is not indexed.

0001 <?xml version="1.0" encoding="iso-8859-15"?>
0002 
0003 <!--
0004         This file is freely distributable, created by Wilbert Berendsen (wbsoft@xs4all.nl)
0005 
0006         This is just a simple XSLT file that converts some HTML pages to a XBEL bookmarklist.
0007         It is included here to test the new XSLT highlighting by Peter Lammich.
0008         
0009         TODO: add better test file.
0010 -->
0011 
0012 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
0013 xmlns:h="http://www.w3.org/1999/xhtml">
0014 <xsl:output method="xml" encoding="iso-8859-15" indent="yes"
0015  doctype-public="+//IDN python.org//DTD XML Bookmark Exchange Language 1.0//EN//XML"
0016  doctype-system="http://www.python.org/topics/xml/dtds/xbel-1.0.dtd"
0017 />
0018 
0019 <!-- main -->
0020 <xsl:template match="/">
0021 <xbel><folder><title>Linux at Home Links</title>
0022 <xsl:for-each select="//*[@id='maincontents']//h:li">
0023   <xsl:variable name="f" select="document(h:a/@href)/h:html"/>
0024   <folder>
0025   <title><xsl:value-of select="h:a/h:strong"/></title>
0026   <desc><xsl:value-of select="normalize-space(h:a/text())"/></desc>
0027   <xsl:for-each select="$f//h:div[@id='maincontents']">
0028   <xsl:call-template name="getbookmarks"/>
0029   </xsl:for-each>
0030   
0031   </folder>
0032 </xsl:for-each>
0033 </folder></xbel>
0034 </xsl:template>
0035 <!-- end of main -->
0036 
0037 <!-- get bookmarks from a page -->
0038 <xsl:template name="getbookmarks">
0039 
0040 <xsl:choose>
0041   <!-- harvest links from p or li elements -->
0042   <xsl:when test="self::h:li or self::h:p">
0043     <xsl:variable name="t" select="normalize-space()"/>
0044     <xsl:for-each select=".//h:a[1]">
0045       <xsl:call-template name="bookmark">
0046         <xsl:with-param name="desc" select="$t"/>
0047       </xsl:call-template>
0048     </xsl:for-each>
0049     <xsl:for-each select=".//h:a[position()!=1]">
0050       <xsl:call-template name="bookmark"/>
0051     </xsl:for-each>
0052   </xsl:when>
0053 
0054 
0055   <xsl:otherwise>
0056     <xsl:for-each select="*">
0057       <xsl:call-template name="getbookmarks"/>
0058     </xsl:for-each>
0059   </xsl:otherwise>
0060 
0061 </xsl:choose>
0062 
0063 </xsl:template>
0064 
0065 
0066 <xsl:template name="bookmark">
0067   <xsl:param name="href" select="@href"/>
0068   <xsl:param name="desc" select="''"/>
0069   <xsl:param name="title" select="normalize-space()"/>
0070 
0071   <xsl:variable name="realdesc">
0072     <xsl:choose>
0073       <xsl:when test="starts-with($desc,$title)">
0074         <xsl:choose>
0075           <xsl:when test="starts-with(translate(substring-after($desc,$title),',.;','...'),'.')">
0076             <xsl:value-of select="substring($desc,string-length($title) + 2)"/>
0077           </xsl:when>
0078           <xsl:otherwise>
0079             <xsl:value-of select="substring-after($desc,$title)"/>
0080           </xsl:otherwise>
0081         </xsl:choose>
0082       </xsl:when>
0083       <xsl:otherwise>
0084         <xsl:value-of select="$desc"/>
0085       </xsl:otherwise>
0086     </xsl:choose>
0087   </xsl:variable>
0088   
0089   <bookmark>
0090     <xsl:attribute name="href">
0091       <xsl:choose>
0092         <xsl:when test="starts-with($href,'http://') or starts-with($href,'ftp://') or starts-with($href,'mailto:')">
0093           <xsl:value-of select="$href"/>
0094         </xsl:when>
0095         <xsl:otherwise>
0096           <xsl:value-of select="concat('http://www.xs4all.nl/~wbsoft/linux/links/',$href)"/>
0097         </xsl:otherwise>
0098       </xsl:choose>
0099     </xsl:attribute>
0100     <title><xsl:value-of select="normalize-space($title)"/></title>
0101     <xsl:if test="normalize-space($realdesc) != ''">
0102       <desc><xsl:value-of select="normalize-space($realdesc)"/></desc>
0103     </xsl:if>
0104   </bookmark>
0105 </xsl:template>
0106 
0107 
0108 
0109 </xsl:stylesheet>