English:

The Free and Open Productivity Suite
Help us Help the World
<xsl:stylesheet 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:xdoc="http://www.pnp-software.com/XSLTdoc" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" exclude-result-prefixes="xdoc mods xs cs bib">
<!--===licensedunderCC-GNUGPL;seehttp://creativecommons.org/licenses/GPL/2.0===-->
<xdoc:doc type="stylesheet">
<xdoc:short>CiteProcfunctions.</xdoc:short>
<xdoc:author>BruceD’Arcus</xdoc:author>
<xdoc:copyright>2004</xdoc:copyright>
</xdoc:doc>

<!--||||datefunctions||||-->
<xdoc:doc>whengivenabibliographicrecord,returnsitspublicationyear</xdoc:doc>

<xsl:function name="mods:year">
<xsl:param name="bibref" as="element(mods:mods)" />
<xsl:for-each select="$bibref">
<xsl:variable name="xsd-date" select="(mods:originInfo/mods:dateIssued, mods:relatedItem/mods:originInfo/mods:dateIssued, mods:relatedItem/mods:part/mods:date)[1]" />
<xsl:value-of select="substring($xsd-date,1,4)" />
</xsl:for-each>
</xsl:function>
<!--||||numberhandlingfunctions||||-->
<xdoc:doc>CollapsesapagerangeaccordingtotheChicagoalgorithm.Probablyneedstobe
generalized.
</xdoc:doc>

<xsl:function name="bib:number-condense">
<xsl:param name="begin" />
<xsl:param name="end" />
<xsl:choose>
<xsl:when test="$begin castable as xs:integer">
<xsl:variable name="begin" select="xs:integer($begin)" as="xs:integer" />
<xsl:choose>
<xsl:when test="$begin gt 100 and $begin mod 100 and $begin idiv 100 eq $end idiv 100">
<xsl:value-of select="$end mod 100" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$end" />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$end" />
</xsl:otherwise>
</xsl:choose>
</xsl:function>
<xsl:variable name="primary-contributors" select="('author', 'editor', 'creator', 'speaker', 'reviewer')" />
<xsl:variable name="secondary-contributors" select="('translator')" />
<xdoc:doc>Constructsanauthorsstringforgroupingandsorting.Thisfunctionconcatenatesall
authorsintoastringsothatmultiple-authorsgetcorrectlygrouped.Wherenoauthorexistsit
substitutesbasedonCSLdefinitions.
</xdoc:doc>

<xsl:function name="mods:grouping-key" as="xs:string">
<xsl:param name="bibref" as="element(mods:mods)" />
<xsl:variable name="sort-on" select="mods:sort_on($bibref)" as="xs:string" />
<xsl:choose>
<xsl:when test="$sort-on='creator'">
<xsl:value-of separator=";">
<xsl:for-each select="$bibref/mods:name[mods:role/mods:roleTerm=$primary-contributors]">
<xsl:value-of select="string-join((mods:namePart[@type='family'] | mods:namePart[not(@type)],mods:namePart[@type='given']), ',')" />
</xsl:for-each>
</xsl:value-of>
</xsl:when>
<xsl:when test="$sort-on='container-title'">
<xsl:value-of select="$bibref/mods:relatedItem[@type='host']/mods:titleInfo/mods:title" />
</xsl:when>
<xsl:when test="$sort-on='title'">
<xsl:value-of select="$bibref/mods:titleInfo/mods:title" />
</xsl:when>
<xsl:when test="$sort-on='anonymous'">
<xsl:value-of select="'Anonymous'" />
</xsl:when>
</xsl:choose>
</xsl:function>
<xdoc:doc>Determineswhattosorton.</xdoc:doc>

<xsl:function name="mods:sort_on" as="xs:string">
<xsl:param name="bibref" as="element(mods:mods)" />
<xsl:variable name="use-reftype" select="mods:use_csl-reftype($bibref)" />
<xsl:variable name="csl_path" select="if ($citeclass='note-nobib') then $style-citation/cs:first/cs:layout/cs:reftype[@name=$use-reftype] else $style-biblio/cs:layout/cs:reftype[@name=$use-reftype]" />
<xsl:choose>
<xsl:when test="$csl_path/cs:creator[1]">
<xsl:choose>
<xsl:when test="$bibref/mods:name[mods:role/mods:roleTerm=$primary-contributors]">
<xsl:value-of select="'creator'" />
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="$csl_path/cs:creator/@alternate-sortkey='container-title'">
<xsl:value-of select="'container-title'" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'anonymous'" />
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$csl_path/cs:title[1]">
<xsl:value-of select="'title'" />
</xsl:when>
</xsl:choose>
</xsl:function>
<xdoc:doc>DetermineswhichCSLdefinitiontouseforanygivenMODSrecord.</xdoc:doc>

<xsl:function name="mods:use_csl-reftype" as="xs:string">
<xsl:param name="bibref" as="element(mods:mods)" />
<xsl:sequence select="if (mods:csl-reftype($bibref)) then (mods:csl-reftype($bibref)) else (mods:csl-fallback($bibref))" />
</xsl:function>
<xdoc:doc>MapsaMODSreferencetypetoaCSLXPATHexpression.</xdoc:doc>

<xsl:function name="mods:csl-reftype" as="xs:string">
<xsl:param name="bibref" as="element(mods:mods)" />
<xsl:variable name="reftype" select="mods:reftype($bibref)" />
<xsl:variable name="csl-style" select="if ($citeclass='note-nobib') then ($style-citation/cs:first/cs:layout/cs:reftype) else ($style-biblio/cs:layout/cs:reftype)" />
<xsl:value-of select="$csl-style/@name[.=$reftype]" />
</xsl:function>
<xdoc:doc>DeterminestheCSLfallbackforaMODSrecord.</xdoc:doc>

<xsl:function name="mods:csl-fallback" as="xs:string">
<xsl:param name="bibref" as="element(mods:mods)" />
<xsl:variable name="bibrefclass" select="mods:refclass($bibref)" />
<xsl:choose>
<xsl:when test="$bibrefclass='monograph'">
<xsl:value-of select="'book'" />
</xsl:when>
<xsl:when test="$bibrefclass='part-inMonograph'">
<xsl:value-of select="'chapter'" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'article'" />
</xsl:otherwise>
</xsl:choose>
</xsl:function>
<xdoc:doc>Thisfunctioniscentraltotheformattinglogicofthesystem.Thefallbacksystem
classifiesrecordsintooneofthreestructuralclasses:part-inMongraph,part-inSerial,and
mongraph.Itwouldbeeasytoaddserialasafourth,butIhavenotyetfoundtheneed(does
oneeverciteaserialasawhole?).
</xdoc:doc>

<xsl:function name="mods:refclass" as="xs:string">
<xsl:param name="bibref" as="element(mods:mods)?" />
<xsl:choose>
<xsl:when test="$bibref/mods:relatedItem[@type='host']">
<xsl:variable name="issuance" select="$bibref/mods:relatedItem/mods:originInfo/mods:issuance" />
<xsl:choose>
<xsl:when test="$issuance='monographic'">part-inMonograph</xsl:when>
<xsl:otherwise>part-inSerial</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>monograph</xsl:otherwise>
</xsl:choose>
</xsl:function>
<xdoc:doc>Furtherclassifiesrecordsintotypesbasedontheclass.Thesetypesthenmapontothe
citationstylelangaugedefinitions.Article,chapterandbookarethedefaultstructuresand
genericfallbacks.Mostrecordswillbeformattedwiththese"types."Beyondthesecoretypes,
additionaltypeswouldbedefinedbyboththeirgenrevaluesandtheirlikenesstothecore
types.Thevaluecanbemulti-levelwhereapplicable:e.g.“article-magazine.”
</xdoc:doc>

<xsl:function name="mods:reftype" as="xs:string">
<xsl:param name="bibref" as="element(mods:mods)?" />
<xsl:value-of>
<xsl:choose>
<xsl:when test="$bibref/mods:relatedItem/@type = 'host'">
<xsl:variable name="issuance" select="$bibref/mods:relatedItem/mods:originInfo/mods:issuance" />
<xsl:choose>
<xsl:when test="mods:refclass($bibref) = 'part-inSerial'">
<xsl:if test="$bibref/mods:relatedItem/mods:genre=('periodical', 'magazine', 'academic journal', 'newspaper')">
<xsl:text>article</xsl:text>
<xsl:text>-</xsl:text>
</xsl:if>
<xsl:value-of select="($bibref/mods:relatedItem/mods:genre, $bibref/mods:genre)[1]" />
</xsl:when>
<xsl:when test="mods:refclass($bibref) = 'part-inMonograph'">
<xsl:choose>
<xsl:when test="$bibref/mods:genre">
<xsl:value-of select="$bibref/mods:genre" />
</xsl:when>
<xsl:otherwise>
<xsl:text>chapter</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$bibref/mods:genre" />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>book</xsl:otherwise>
</xsl:choose>
</xsl:value-of>
</xsl:function>
<xdoc:doc>Numberscitationsandfoot/endnotestogether.</xdoc:doc>

<xsl:function name="bib:number-footcite" as="xs:string">
<xsl:param name="footcite" as="element()" />
<xsl:choose>
<xsl:when test="$chapters/db:chapter">
<xsl:for-each select="$footcite">
<xsl:number level="any" select="." count="db:footnote|db:citation[not(ancestor::db:footnote)]" from="db:chapter" />
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="$footcite">
<xsl:number level="any" select="." count="db:footnote|db:citation[not(ancestor::db:footnote)]" />
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
<xdoc:doc>Determinesthefirsttimeareferenceiscitedinthetext.Necesaryforthosestyles
thatmakeaformattingdistinctionbetweenfirstandsubsequentreferences.
</xdoc:doc>

<xsl:function name="bib:first-reference" as="xs:boolean">
<xsl:param name="cite-ref" as="node()" />
<xsl:sequence select="$cite-ref is key('refs', $cite-ref/@linkend, root($cite-ref))[1]" />
</xsl:function>
<xdoc:doc>Determineswhenacitationfulfillsthe"ibid"condition.</xdoc:doc>

<xsl:function name="bib:ibid" as="xs:boolean">
<xsl:param name="citation" as="node()" />
<xsl:sequence select="$citation/db:biblioref/@linkend = $citation/preceding::db:biblioref[1]/@linkend" />
</xsl:function>
</xsl:stylesheet>






































v

Apache Feather

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

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