Language

The Free and Open Productivity Suite
Released: Apache OpenOffice 4.1.15
<xsl:stylesheet xmlns="http://purl.org/NET/xbiblio/citeproc" xmlns:bib="http://purl.org/NET/xbiblio/citeproc" xmlns:cs="http://purl.org/NET/xbiblio/csl" xmlns:db="http://docbook.org/ns/docbook" xmlns:mods="http://www.loc.gov/mods/v3" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:xdoc="http://www.pnp-software.com/XSLTdoc" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:course="http://purl.org/NET/xbiblio/course" version="2.0" exclude-result-prefixes="db xdoc xhtml mods xs cs exist bib course">
��
<xsl:include href="config/CONFIG" />
��
<xsl:include href="main/format-style.xsl" />
��
<xsl:include href="main/functions.xsl" />
��
<xsl:include href="main/sort.xsl" />
��
<xsl:include href="main/process-mods.xsl" />
��
<xsl:include href="drivers/in-driver.xsl" />
��
<xsl:include href="drivers/out-drivers.xsl" />
��
<xsl:include href="VERSION" />
��
<!--�===�licensed�under�CC-GNU�GPL;�see�http://creativecommons.org/licenses/GPL/2.0�===�-->
��
<xsl:output name="xml" encoding="UTF-8" indent="yes" />
��
<xsl:strip-space elements="cs:*" />
��
��<xdoc:doc type="stylesheet">
����
<xdoc:short>Main�CiteProc�stylesheet.</xdoc:short>
����
<xdoc:author>Bruce�D’Arcus</xdoc:author>
����
<xdoc:copyright>2004,�Bruce�D’Arcus</xdoc:copyright>
��
</xdoc:doc>

��
��<xdoc:doc>Sort�order�for�bibliography.<xdoc:param type="string" />
��
</xdoc:doc>

��
<xsl:param name="sort_order-bib" as="xs:string">
����
<xsl:choose>
������
<xsl:when test="$citeclass='citekey'">citekey</xsl:when>
������
<xsl:when test="$citeclass='number'">
��������
<xsl:value-of select="$style-biblio/@sort-order" />
������
</xsl:when>
������
<xsl:otherwise>author-year</xsl:otherwise>
����
</xsl:choose>
��
</xsl:param>
��
��<xdoc:doc>A�required�parameter�that�specifies�the�CSL�file�to�use�for�processing�(minus�the�csl
������extension).
<xdoc:param type="string" />
��
</xdoc:doc>

��
<xsl:param name="citation-style" required="yes" as="xs:string" />
��
<xsl:variable name="styles" as="document-node()" select="doc(concat('../styles/',$citation-style,'.csl'))" />
��
��<xdoc:doc>Class�of�formatting�type,�drawn�from�the�CSL�file.<xdoc:param type="string" />
��
</xdoc:doc>

��
<xsl:param name="citeclass" select="$styles/cs:citationstyle/@class" />
��
<xsl:variable name="style-citation" select="$styles/cs:citationstyle/cs:content/cs:citation" />
��
<xsl:variable name="style-biblio" select="$styles/cs:citationstyle/cs:content/cs:bibliography" />
��
<xsl:variable name="style-names" select="$styles/cs:citationstyle/cs:content/cs:names" />
��
<xsl:variable name="style-terms" select="$styles/cs:citationstyle/cs:content/cs:terms" />
��
<xsl:variable name="locators" select="$styles/cs:citationstyle/cs:content/cs:locators" />
��
��<xdoc:doc>first�index�the�citations</xdoc:doc>

��
<xsl:key name="refs" match="db:biblioref" use="@linkend" />
��
��<xdoc:doc>Creates�a�table�against�which�to�measure�relative�citation�position.</xdoc:doc>

��
<xsl:variable name="cite-position">
����
<bib:refs>
������
<bib:all>
��������
<xsl:for-each select="$citerefs">
����������
<bib:ref position="{position()}" id="{generate-id()}" key="{.}" />
��������
</xsl:for-each>
������
</bib:all>
������
<bib:unique>
��������
<xsl:for-each-group select="$citerefs" group-by=".">
����������
<bib:ref position="{position()}" id="{generate-id()}" key="{.}" />
��������
</xsl:for-each-group>
������
</bib:unique>
����
</bib:refs>
��
</xsl:variable>
��
��<xdoc:doc>Constructs�a�list�of�unique�references�to�pass�to�a�query.</xdoc:doc>

��
<xsl:variable name="citekeys">
����
<xsl:if test="$bibdb='exist-xmldb'">(</xsl:if>
����
<xsl:if test="$bibdb='sru'">%22</xsl:if>
����
<xsl:for-each-group select="$citerefs" group-by=".">
������
<xsl:if test="position() gt 1">
��������
<xsl:choose>
����������
<xsl:when test="$bibdb='exist-xmldb'">,%20</xsl:when>
����������
<xsl:otherwise>%20</xsl:otherwise>
��������
</xsl:choose>
������
</xsl:if>
������
<xsl:if test="$bibdb='exist-xmldb'">'</xsl:if>
������
<xsl:value-of select="." />
������
<xsl:if test="$bibdb='exist-xmldb'">'</xsl:if>
����
</xsl:for-each-group>
����
<xsl:if test="$bibdb='sru'">%22</xsl:if>
����
<xsl:if test="$bibdb='exist-xmldb'">)</xsl:if>
��
</xsl:variable>
��
<xsl:variable name="authentication" select="'&amp;x-info-2-auth1.0-authenticationToken='" as="xs:string" />
��
<xsl:variable name="sru-email" select="concat('email=', $email)" as="xs:string" />
��
��<xdoc:doc>Takes�a�list�of�references,�and�imports�them�from�a�database�over�HTTP.�Options�include
����an�XQuery�to�eXist,�SRU/CQL,�and�flat�files.
</xdoc:doc>

��
<xsl:variable name="bibrecord">
����
<xsl:message>
������
<xsl:text>
CiteProc�XSL�Stylesheets�v
</xsl:text>
������
<xsl:value-of select="$CP-VERSION" />
������
<xsl:text>
</xsl:text>
����
</xsl:message>
����
<xsl:message>
������
<xsl:text>citation�style:�</xsl:text>
������
<xsl:value-of select="$styles/cs:citationstyle/cs:info/cs:title" />
����
</xsl:message>
����
<xsl:message>
������
<xsl:text>citation�class:�</xsl:text>
������
<xsl:value-of select="$citeclass" />
������
<xsl:text>
</xsl:text>
����
</xsl:message>
����
<xsl:choose>
������
<xsl:when test="$bibdb='exist-xmldb'">
��������
<xsl:copy-of select="doc(concat(&quot;http://localhost:8080/exist/servlet/db/mods?&quot;, &quot;_query=declare%20namespace%20mods=%22http://www.loc.gov/mods/v3%22;&quot;, &quot;%20for%20$citekey%20in%20&quot;, $citekeys, &quot;%20return%20//mods:mods[@ID=$citekey]&amp;_howmany=-1&quot;))" />
������
</xsl:when>
������
<xsl:when test="$bibdb='sru'">
��������
<xsl:copy-of select="doc(concat($server_url, 'version=1.1&amp;query=bib.citekey%20any%20', $citekeys, '&amp;operation=searchRetrieve&amp;recordSchema=mods&amp;recordPacking=xml&amp;startRecord=1&amp;maximumRecords=9999', $authentication, $sru-email))" />
������
</xsl:when>
������
<xsl:when test="$bibdb='flatfile'">
��������
<mods:modsCollection>
����������
<xsl:for-each select="distinct-values($citerefs)">
������������
<xsl:copy-of select="document($bibinfile)/mods:modsCollection/mods:mods[@ID=current()]" />
����������
</xsl:for-each>
��������
</mods:modsCollection>
������
</xsl:when>
����
</xsl:choose>
��
</xsl:variable>
��
��<xdoc:doc>Creates�a�raw�bibliographic�collection.</xdoc:doc>

��
<xsl:variable name="raw-biblist">
����
<modsCollection xmlns="http://www.loc.gov/mods/v3">
������
<xsl:copy-of select="$bibrecord//mods:mods" />
����
</modsCollection>
��
</xsl:variable>
��
��<xdoc:doc>Groups,�sorts,�and�enhances�content�for�processing;�this�is�where�most�of�the�logic
����lies.
</xdoc:doc>

��
<xsl:variable name="enhanced-biblist">
����
<mods:modsCollection>
������
<xsl:choose>
��������
<xsl:when test="$sort_order-bib='citekey'">
����������
<xsl:apply-templates select="$raw-biblist/mods:modsCollection" mode="sort_citekey" />
��������
</xsl:when>
��������
<xsl:when test="$sort_order-bib='cited'">
����������
<xsl:apply-templates select="$raw-biblist/mods:modsCollection" mode="sort_cited" />
��������
</xsl:when>
��������
<xsl:when test="$sort_order-bib='author-year'">
����������
<xsl:apply-templates select="$raw-biblist/mods:modsCollection" mode="sort_author-year" />
��������
</xsl:when>
������
</xsl:choose>
����
</mods:modsCollection>
��
</xsl:variable>
��
��
��<xdoc:doc>Creates�final�formatted�bibliography�list.�Depending�on�output�format,�transforms�or
����just�copies�contents�of�the�bib:formatted-biblist�variable.
</xdoc:doc>

��
<xsl:template name="bib:format-bibliography">
����
<xsl:param name="output-format" as="xs:string" />
����
<xsl:choose>
������
<xsl:when test="$output-format='latex'">
��������
<xsl:apply-templates select="$bib:formatted-biblist" mode="output-latex" />
������
</xsl:when>
������
<xsl:when test="$output-format='xhtml'">
��������
<xsl:apply-templates select="$bib:formatted-biblist" mode="output-xhtml" />
������
</xsl:when>
������
<xsl:when test="$output-format='fo'">
��������
<xsl:apply-templates select="$bib:formatted-biblist" mode="output-fo" />
������
</xsl:when>
����
</xsl:choose>
����
<xsl:if test="$biboutfile">
������
<xsl:result-document href="{$biboutfile}" format="xml">
��������
<xsl:copy-of select="$raw-biblist" />
������
</xsl:result-document>
����
</xsl:if>
��
</xsl:template>
��
��
��<xdoc:doc>In�conjunction�with�bib:format-bib�templates,�formats�bibliography�list�into�an
����intermediate�representation.�The�intermediate�representation�is�similar�to�xhtml,�but�in�the
����citeproc�namespace.
</xdoc:doc>

��
<xsl:variable name="bib:formatted-biblist">
����
<xsl:apply-templates select="$enhanced-biblist/mods:modsCollection/mods:mods" mode="temp-placeholder" />
��
</xsl:variable>
��
��
��<xdoc:doc>Formats�bibliography�list�into�an�intermediate�representation.</xdoc:doc>

��
<xsl:template match="mods:mods" mode="temp-placeholder">
����
<xsl:variable name="shorten-author" select="@bib:shorten-author" />
����
<xsl:variable name="use_reftype" select="@bib:use-reftype" />
����
<xsl:variable name="id" select="@ID" />
����
<xsl:variable name="number">
������
<xsl:choose>
��������
<xsl:when test="$sort_order-bib='author-year'">
����������
<xsl:value-of select="position()" />
��������
</xsl:when>
��������
<xsl:otherwise>
����������
<xsl:value-of select="$cite-position/bib:refs/bib:unique/bib:ref[@key=$id]/@position" />
��������
</xsl:otherwise>
������
</xsl:choose>
����
</xsl:variable>
����
<xsl:apply-templates select="$style-biblio">
������
<xsl:with-param name="bib:source" select="." as="element()" tunnel="yes" />
������
<xsl:with-param name="use_reftype" select="@bib:use-reftype" as="xs:string" tunnel="yes" />
������
<xsl:with-param name="bib:number" select="$number" as="xs:string" tunnel="yes" />
����
</xsl:apply-templates>
��
</xsl:template>
��
��
��<xdoc:doc>formats�citations</xdoc:doc>

��
<xsl:template name="bib:format-citation">
����
<xsl:param name="output-format" as="xs:string" />
����
<!--�create�a�temporary�tree�to�hold�the�processing�citations�-->
����
<xsl:variable name="intermediate-citation">
������
<bib:span class="citation">
��������
<xsl:value-of select="$style-citation/cs:prefix" />
��������
<xsl:choose>
����������
<xsl:when test="$sort_order-bib='author-year' or $citeclass='note-nobib'">
������������
<xsl:choose>
��������������
<!--�FIX:�add�additional�conditional�for�@ibid,�configure�formatting�in�CSL�-->
��������������
<xsl:when test="bib:ibid(.) and count(db:biblioref)=1">
����������������
<bib:a class="citation" href="#{db:biblioref/@linkend}">
������������������
<xsl:text>ibid.</xsl:text>
����������������
</bib:a>
��������������
</xsl:when>
��������������
<xsl:when test="$citeclass='author-year' or $citeclass='note-nobib'">
����������������
<xsl:apply-templates select="." mode="sort_citation_author-year" />
����������������
</xsl:when>
��������������
<xsl:otherwise>
����������������
<xsl:apply-templates select="db:biblioref" mode="otherwise" />
��������������
</xsl:otherwise>
������������
</xsl:choose>
����������
</xsl:when>
����������
<xsl:otherwise>
������������
<xsl:apply-templates select="db:biblioref" mode="otherwise" />
����������
</xsl:otherwise>
��������
</xsl:choose>
��������
<xsl:value-of select="$style-citation/cs:suffix" />
������
</bib:span>
����
</xsl:variable>
����
<!--
����create�formatted�output�by�running�appropriate�output�mode�on�the�temporary
����tree�in�the�intermediate-citation�variable�
����
-->
����
<xsl:choose>
������
<xsl:when test="$output-format='latex'">
��������
<xsl:apply-templates select="$intermediate-citation" mode="output-latex" />
������
</xsl:when>
������
<xsl:when test="$output-format='xhtml'">
��������
<xsl:apply-templates select="$intermediate-citation" mode="output-xhtml" />
������
</xsl:when>
����
</xsl:choose>
��
</xsl:template>
��
<xsl:template match="db:biblioref" mode="otherwise">
����
<xsl:apply-templates select="$style-citation">
������
<xsl:with-param name="cite-ref" select="." as="node()" tunnel="yes" />
����
</xsl:apply-templates>
����
<xsl:if test="position() != last()">
������
<xsl:value-of select="$style-citation/@delimiter" />
����
</xsl:if>
��
</xsl:template>
</xsl:stylesheet>






































v

Apache Software Foundation

Copyright & License | Privacy | Contact Us | Donate | Thanks

Apache, OpenOffice, OpenOffice.org and the seagull logo are registered trademarks of The Apache Software Foundation. The Apache feather logo is a trademark of The Apache Software Foundation. Other names appearing on the site may be trademarks of their respective owners.