Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I've been thinking of how to make a blog simple recently, and I came across xslt. It looks really cool and seems pretty set in stone, so I thought I'd ask, what are the advantages/drawbacks of making your own tech stack versus xslt? At first glance, it seems perfectly able to handle rss and other simple linking patterns, and pretty much anything can easily be turned into an xml then xslt could be used to generate an html (server-side, or rather writer-side, not like the blog is gonna change) that you serve?


XSLT might be removed from the HTML spec soon, see discussion here: https://news.ycombinator.com/item?id=44952185


that would be client side if it happens, though, I'm talking about server side generation

xsltproc was preinstalled on my machine actually, the fact I could just run it without installing anything is pretty cool


XSL is neat, and it is a functional language, but between XSL and XPath, it is quite verbose. Here's a small section of XSL I use to generate my website (not my blog):

    <xsl:choose>
    
      <!-- ... other code -->
      
      <xsl:when test="name(.) = 'subsection'">
        <xsl:choose>
          <xsl:when test="not(boolean(ancestor-or-self::*/@next)) or ancestor-or-self::*/@next != 'rev'">
            <xsl:if test="boolean(following-sibling::subsection[@listindex != 'no']/attribute::directory)">
              <link rel="next"  href="../{following-sibling::subsection[@listindex != 'no']/attribute::directory}" title="{following-sibling::subsection[@listindex != 'no']/child::title}"/>
            </xsl:if>
            <xsl:if test="boolean(preceding-sibling::subsection[@listindex != 'no'][position()=1]/attribute::directory)">
              <link rel="prev"  href="../{preceding-sibling::subsection[@listindex != 'no'][position()=1]/attribute::directory}" title="{preceding-sibling::subsection[@listindex != 'no'][position()=1]/child::title}"/>
            </xsl:if>
            <link rel="first" href="../{../subsection[@listindex != 'no'][position()=1]/@directory}" title="{../subsection[@listindex != 'no'][position()=1]/title}"/>
            <link rel="last"  href="../{../subsection[@listindex != 'no'][position()=last()]/@directory}" title="{../subsection[@listindex != 'no'][position()=last()]/title}"/>
          </xsl:when>
   
          <xsl:otherwise>
            <xsl:if test="boolean(preceding-sibling::subsection[@listindex != 'no'][position()=1]/attribute::directory)">
              <link rel="next" href="../{preceding-sibling::subsection[@listindex != 'no'][position()=1]/attribute::directory}" title="{preceding-sibling::subsection[@listindex != 'no'][position()=1]/child::title}"/>
            </xsl:if>
            <xsl:if test="boolean(following-sibling::subsection[@listindex != 'no']/attribute::directory)">
              <link rel="prev" href="../{following-sibling::subsection[@listindex != 'no']/attribute::directory}" title="{following-sibling::subsection[@listindex != 'no']/child::title}"/>
            </xsl:if>
            <link rel="first" href="../{../subsection[@listindex != 'no'][position()=last()]/@directory}" title="{../subsection[@listindex != 'no'][position()=last()]/title}"/>
            <link rel="last"  href="../{../subsection[@listindex != 'no'][position()=1]/@directory}" title="{../subsection[@listindex != 'no'][position()=1]/title}"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:when>

      <!-- ... other code ... -->
    </xsl:choose>
And yes, there is other code I've omitted for brevity. This is used to generate the navigation links for the site. I initially write this ... prior to 2009 (that's when I moved it into git). There have been some minor fixes to the XSL over the years, but it's largely unchanged (for a reason that I hope is obvious). Yes, I still use it, because it still works, and it's for a static website.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: