All pastes #504980 Raw Edit

vote-links - ibis

public xml v1 · immutable
·published 2007-05-23 11:42 UTC
rendered paste body
<?xml version='1.0' encoding='utf-8'?><xsl:stylesheet version='1.0'  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"   xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"   xmlns:h="http://www.w3.org/1999/xhtml"  xmlns:foaf="http://xmlns.com/foaf/0.1/"  xmlns:dc="http://purl.org/dc/elements/1.1/"  xmlns:doap="http://usefulinc.com/ns/doap#"  xmlns:admin="http://webns.net/mvcb/"  xmlns:ibis="http://dannyayers.com:88/xmlns/ibis/ibis.rdfs"><!-- uri choosing code copied from ian davis's eRDF stylesheet--> <xsl:param name="baseUri" />        <xsl:output method="xml" version="1.0" encoding="utf-8" omit-xml-declaration="no" standalone="no" indent="yes"/>  <xsl:variable name="authBaseUri">    <xsl:choose>      <xsl:when test="/h:html/h:head/h:base[@href]">        <xsl:value-of select="/h:html/h:head/h:base[@href][1]/@href" />      </xsl:when>      <xsl:otherwise>        <xsl:value-of select="$baseUri" />      </xsl:otherwise>    </xsl:choose>  </xsl:variable>  <xsl:variable name="baseUriNoFragment">    <xsl:call-template name="substring-before-last">      <xsl:with-param name="string" select="$authBaseUri" />      <xsl:with-param name="character" select="'#'" />    </xsl:call-template>  </xsl:variable>        <xsl:template name="substring-before-last">                <xsl:param name="string"/>                <xsl:param name="character"/>                <xsl:choose>                        <xsl:when test="contains($string,$character)">        <xsl:value-of select="substring-before($string,$character)"/>        <xsl:if test="contains( substring-after($string, $character), $character)">          <xsl:value-of select="$character"/>          <xsl:call-template name="substring-before-last">            <xsl:with-param name="string" select="substring-after($string, $character)" />            <xsl:with-param name="character" select="$character" />          </xsl:call-template>        </xsl:if>                        </xsl:when>      <xsl:otherwise>        <xsl:value-of select="$string" />      </xsl:otherwise>                </xsl:choose>        </xsl:template><xsl:template match="/"><rdf:RDF><xsl:apply-templates/><!-- select="a[@rev='vote-for']|*[@rev='vote-against']|*[@rev='vote-abstain']"/> --></rdf:RDF></xsl:template><xsl:template match="h:a[@rev='vote-for']|h:a[@rev='vote-against']|h:a[@rev='vote-abstain']"> <xsl:variable name="id" select="ancestor-or-self[@id][1]/@id" /><ibis:Argument> <xsl:attribute name="rdf:about">              <xsl:value-of select="concat($baseUriNoFragment, '#', $id)" />            </xsl:attribute><xsl:choose><xsl:when test="@rev='vote-for'">  <ibis:pro rdf:resource="{@href}"/></xsl:when><xsl:when test="@rev='vote-against'">  <ibis:con rdf:resource="{@href}"/></xsl:when><xsl:otherwise>  <ibis:refersTo rdf:resource="{@href}"/></xsl:otherwise></xsl:choose></ibis:Argument><ibis:Argument rdf:about="{@href}" rdfs:label="{.}"></ibis:Argument></xsl:template></xsl:stylesheet>