In what appears to be a biannual ‘thing’ for me over the last few years, I’ve thrown out my old blog software and replaced it with something that suits my needs and skills better. I’m now running Symphony, by 21 Degrees, which is:
Here’s some naff XSL I wrote (with some assistance from members and their examples at Overture) to scan through my XML structure and append the location of the installed Symphony application to the front of all absolute URLs. This means I can move my blog where-ever I like, and all of my links within pages will continue working. It’s also a good example of advanced XSL usage.
<xsl:template match="p | ul | ol | li | h1 | h2 | h3 | h4 | h5 | h6 | blockquote | em | strong | code | pre | acronym | span">
<xsl:element name="{name(.)}">
<xsl:apply-templates select="@*"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="a | img">
<xsl:element name="{name(.)}">
<xsl:apply-templates select="@*"/>
<xsl:if test="substring(@src,1,1)='/'">
<xsl:attribute name="src"><xsl:value-of select="$root"/><xsl:value-of select="@src"/></xsl:attribute>
</xsl:if>
<xsl:if test="substring(@href,1,1)='/'">
<xsl:attribute name="href"><xsl:value-of select="$root"/><xsl:value-of select="@href"/></xsl:attribute>
</xsl:if>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="@*">
<xsl:attribute name="{name(.)}"><xsl:value-of select="."/></xsl:attribute>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of select="."/>
</xsl:template>