<?xml version='1.0' encoding='iso-8859-1'?>

<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:output method='html' version='1.0' encoding='UTF-8' indent='no'/>

<!-- An XSLT style sheet to convert a Safari bookmarks list to HTML, almost 
     suitable for importing into Firefox. The output of this stylesheet
     will need to have the doctype line modified to:
     
     <!DOCTYPE NETSCAPE-Bookmark-file-1>
     -->
<!-- You can find your Safari bookmarks file in your home directory under
     Library / Safari / Bookmarks.plist -->
     
<!-- Original version written by Marc Liyanage (http://www.entropy.ch).
     Later modified by Kyle Smith to tweak the encoding and to remove
     the CSS styling. -->



<!-- Match toplevel element, emit basic HTML document structure -->

<xsl:template match="plist">

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Bookmarks</title>
    <h1>Bookmarks</h1>
    <dl>
	<xsl:apply-templates/>
	</dl>

</xsl:template>


<!-- This generic template matches dict entries which act as containers for other items -->
<xsl:template match="dict">
	<xsl:variable name="title" select="string[preceding-sibling::key[text() = 'Title']]"/>

		<dt>
		<xsl:if test="$title"><h3><xsl:value-of select="$title"/></h3></xsl:if>
		<dl><xsl:apply-templates select="array"/></dl>
		</dt>
</xsl:template>


<!-- This more specific template matches dict entries which contain a particular link. Because
     it is more specific it will have precedence over the one above. -->
<xsl:template match="dict[key[text() = 'URIDictionary']]">

		<dt><a href="{string[preceding-sibling::key[text() = 'URLString']]}"><xsl:value-of select="dict[preceding-sibling::key[text() = 'URIDictionary']]/string[preceding-sibling::key[text() = 'title']]"/></a></dt>

</xsl:template>



</xsl:stylesheet>

