DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Blogmarks To Html Conversion

  • submit to reddit
        This file is intended to transform a Blogmarks atom feed ( into html code fragment to be included in a complete page.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:atom="" xmlns:xsl="" xmlns:dc="">
  <xsl:output method="html" />
  <xsl:template match="/">
    <xsl:apply-templates select="/atom:feed/atom:head" mode="before" />
    <xsl:apply-templates select="/atom:feed/atom:entry" />
    <xsl:apply-templates select="/atom:feed/atom:head" mode="after" />
  <xsl:template match="atom:feed/atom:head" mode="before" >
    <!-- <h3><xsl:value-of select="atom:title" /></h3> -->
  <xsl:template match="atom:feed/atom:head" mode="after">
    <p><a href="{atom:link[@rel='alternate']/@href}"><img src="" alt="" /></a></p>
  <xsl:template match="atom:feed/atom:entry">
        <xsl:when test="position() mod 2 = 1">
          <xsl:attribute name="class">bm_blogmarks bm_odd</xsl:attribute>
          <xsl:attribute name="class">bm_blogmarks bm_even</xsl:attribute>
      <a href="{atom:link[@rel='related']/@href}"><img src="{atom:link[@rel='image']/@href}" alt="" /></a>
      <h4><a href="{atom:link[@rel='related']/@href}"><xsl:value-of select="atom:title" /></a></h4>
      <p><xsl:value-of select="atom:summary" disable-output-escaping="yes" /></p>
      <p class="blogmarks-tags">
        <xsl:value-of select="substring(atom:published, 0, 11)" />
        <xsl:if test="atom:category">
          <xsl:for-each select="atom:category">
            <xsl:text> - </xsl:text><a href="{@term}{@sheme}"><xsl:value-of select="@label" /></a>
The generated html is inspired by the one used on Hot Links ( It can be styled with the following css:
.bm_blogmarks {
	margin: 10px auto;
	padding: 1%;
	background-color: #f5f5f5;
	border: 1px solid #d9d9d9;
	width: 97%;
.bm_even {
    background-color: #fcfcfc;
.bm_blogmarks h4 {
	margin-top: 0;
.bm_blogmarks p.bm_tags {
	margin-bottom: 0;
	display: block;
	clear: left;
.bm_blogmarks img {
	margin: 0 0px 5px 10px;
	float: right;
	border: 0;
	clear: none;
	width: 144px;
	height: 107px;
.bm_even img {
	margin: 0 10px 5px 0px;
	float: left;