Changeset 869

Show
Ignore:
Timestamp:
08/02/07 08:49:14 (1 year ago)
Author:
thomase
Message:

Factor out getbesttitle template into separate file to support multiple (future) stylesheets. Also added function to export formatted citations to separate xml files.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • BibIt/trunk/ProcModsCollection.xsl

    r868 r869  
    1717           Note: this is an xsl 2.0 stylesheet, and therefore requires an xsl 2.0 capable transform engine --> 
    1818 
     19    <xsl:import href="getbesttitle.xsl"/> 
    1920 
    2021    <!-- ================================================================  
     
    2324           * outpath is the absolute path for writing out all files  
    2425          ================================================================ --> 
    25      
    2626    <xsl:param name="mapnum">999</xsl:param> 
    2727    <xsl:param name="outpath">/monkeypox/</xsl:param> 
    2828     
    29  
    3029    <!-- ================================================================  
    3130           the following xsl:output elements govern each of the various output  
     
    3938        doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" 
    4039        doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"/> 
    41     <xsl:output name="mods-format" method="xml" indent="yes" escape-uri-attributes="yes" encoding="UTF-8"/> 
     40    <xsl:output name="mods-format" method="xml" indent="yes" escape-uri-attributes="yes" encoding="UTF-8"  
     41         xpath-default-namespace="http://www.loc.gov/mods/v3"/> 
     42    <xsl:output name="citation-format" method="xml" indent="no" escape-uri-attributes="yes" encoding="UTF-8"/> 
    4243         
    4344    <xsl:key name="modskeys" match="mods:titleInfo[@type='abbreviated'][1]/mods:title | mods:titleInfo[@type='uniform' and not(../mods:titleInfo/@type='abbreviated')][1]/mods:title" use="ancestor::mods:mods/@ID"/> 
     
    9697            </xsl:choose> 
    9798            <xsl:element name="br"/> 
    98             <xsl:choose> 
    99                 <xsl:when test="mods:abstract"> 
    100                     <xsl:element name="span"> 
    101                         <xsl:attribute name="class">formattedcitation</xsl:attribute> 
    102                         <xsl:apply-templates select="mods:abstract/html:p"/> 
    103                     </xsl:element> 
    104                 </xsl:when> 
    105                 <xsl:otherwise> 
    106                     <xsl:apply-templates select="." mode="abstract"/>. 
    107                 </xsl:otherwise> 
    108             </xsl:choose> 
     99            <xsl:call-template name="docitation"> 
     100                <xsl:with-param name="modscit" select="mods:abstract/html:p"/> 
     101            </xsl:call-template> 
    109102        </xsl:element> 
    110103 
     
    113106            <xsl:apply-templates select="." mode="copy"/> 
    114107        </xsl:result-document> 
     108         
     109        <xsl:result-document href="{$outpath}citations/{$newid}.xml" 
     110            format="citation-format"> 
     111            <!-- create separate file to hold formatted citation --> 
     112            <xsl:element name="div" namespace="http://www.w3.org/1999/xhtml"> 
     113                <xsl:attribute name="id"> 
     114                    <xsl:value-of select="$newid" /> 
     115                </xsl:attribute> 
     116                <xsl:call-template name="docitation"><xsl:with-param name="modscit" select="mods:abstract/html:p" /></xsl:call-template> 
     117            </xsl:element> 
     118        </xsl:result-document> 
     119 
    115120         
    116121        <xsl:result-document href="{$outpath}{$newid}.html" format="record-format" > 
     
    126131                        <h2>Formatted citation:</h2> 
    127132                        <ul> 
    128                             <li><xsl:choose> 
    129                                 <xsl:when test="mods:abstract"><xsl:apply-templates select="mods:abstract/html:p" /></xsl:when> 
    130                                 <xsl:otherwise><xsl:apply-templates select="." mode="abstract"/>.</xsl:otherwise> 
    131                             </xsl:choose></li> 
     133                            <li><xsl:call-template name="docitation"> 
     134                                    <xsl:with-param name="modscit" select="mods:abstract/html:p" /> 
     135                                </xsl:call-template></li> 
    132136                        </ul> 
    133137                    </div> 
     
    169173    </xsl:template> 
    170174 
    171  
     175    <xsl:template name="docitation"> 
     176        <xsl:param name="modscit"/> 
     177        <xsl:choose> 
     178            <xsl:when test="local-name($modscit) = 'p'"> 
     179                <xsl:element name="span"> 
     180                    <xsl:attribute name="class">formattedcitation</xsl:attribute> 
     181                    <xsl:copy-of select="$modscit/node()"/> 
     182                </xsl:element> 
     183            </xsl:when> 
     184            <xsl:otherwise> 
     185                <xsl:apply-templates select="ancestor-or-self::mods:mods" mode="abstract"/>. 
     186            </xsl:otherwise> 
     187        </xsl:choose> 
     188    </xsl:template> 
    172189    <!-- ================================================================ 
    173190          copy-mode templates are used primarily to copy, suppress or modify  
     
    748765        <xsl:value-of select="mods:start"/><xsl:if test="mods:end">-<xsl:value-of select="mods:end"/></xsl:if> 
    749766    </xsl:template> 
    750     <xsl:template match="html:p"><xsl:copy-of select="node()"/></xsl:template> 
    751767 
    752768    <xsl:template name="makenewidold"> 
     
    874890    </xsl:template> 
    875891 
    876     <xsl:template name="getbesttitle"> 
    877         <xsl:choose> 
    878             <xsl:when test="mods:titleInfo[@type='abbreviated']"> 
    879                 <xsl:value-of select="mods:titleInfo[@type='abbreviated'][1]/mods:title" /> 
    880             </xsl:when> 
    881             <xsl:otherwise> 
    882                 <xsl:value-of select="mods:titleInfo[@type='uniform']/mods:title" /> 
    883             </xsl:otherwise> 
    884         </xsl:choose> 
    885     </xsl:template> 
    886      
     892    
    887893    <xsl:template name="toHex"> 
    888894        <xsl:param name="decimalNumber" />