Changeset 13342


Ignore:
Timestamp:
2006-11-27T09:41:43+13:00 (17 years ago)
Author:
shaoqun
Message:

checks language perrecord instead of per collection and keeps stopwords of the orginal text

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/etc/dc2marc.xsl

    r13224 r13342  
    88  <xsl:param name="mapping" /> 
    99
    10   <xsl:variable name="lang" >
    11         <xsl:choose>     
    12            <xsl:when test="/MARCXML/MetadataList/Metadata[@name='dc.Language']">
    13                 <xsl:value-of select="/MARCXML/MetadataList/Metadata[@name='dc.Language']"/>                   
    14             </xsl:when>   
    15             <xsl:when test="/MARCXML/MetadataList/Metadata[@name='Language']">
    16                   <xsl:value-of select="/MARCXML/MetadataList/Metadata[@name='Language']"/>
    17             </xsl:when>
    18              <xsl:otherwise>
    19                  <xsl:value-of select="en"/>   
    20              </xsl:otherwise>
    21            </xsl:choose>   
    22    </xsl:variable> 
    23   <xsl:variable name="item" select="$mapping/stopwords[@lang=$lang]/item"/>
    24  
    25 
    26  <xsl:template match="/">
     10  <xsl:template match="/">
    2711     <collection>
    2812           <xsl:apply-templates select="/MARCXML/MetadataList"/>
     
    3115 
    3216  <xsl:template match="MetadataList">
     17       <xsl:variable name="lang" >
     18        <xsl:choose>     
     19           <xsl:when test="Metadata[@name='dc.Language']">
     20                <xsl:value-of select="Metadata[@name='dc.Language']"/>                   
     21            </xsl:when>           
     22            <!-- comment out this if you want to test dls.Language as well
     23             <xsl:when test="Metadata[@name='dls.Language']">
     24                <xsl:value-of select="Metadata[@name='dls.Language']"/>                   
     25             </xsl:when>
     26            -->
     27            <xsl:when test="Metadata[@name='Language']">
     28                  <xsl:value-of select="Metadata[@name='Language']"/>
     29            </xsl:when>           
     30           <!-- the defualt language is english -->
     31            <xsl:otherwise>
     32                 <xsl:value-of select="en"/>   
     33             </xsl:otherwise>
     34           </xsl:choose>   
     35       </xsl:variable> 
     36      <xsl:variable name="item" select="$mapping/stopwords[@lang=$lang]/item"/>
    3337      <record>
    3438      <xsl:apply-templates select="$mapping/leader">
     
    3741          <xsl:apply-templates select="$mapping/controlfield[@required='true']" />
    3842          <xsl:apply-templates select="$mapping/MarcField" >
    39           <xsl:with-param name="source" select="." />   
     43          <xsl:with-param name="source" select="." />
     44              <xsl:with-param name="item" select="$item" />   
    4045      </xsl:apply-templates>                       
    4146      </record>   
     
    107112  <xsl:template match="MarcField">
    108113   <xsl:param  name="source" /> 
     114   <xsl:param  name="item" />
    109115   <xsl:variable name="this" select="."/>
    110116   <xsl:choose>
     
    114120         <xsl:apply-templates select="$this/subfield[1]" mode="testing">
    115121                <xsl:with-param name="pos" select="position()"/>
    116             <xsl:with-param name="source" select="$source"/>
     122            <xsl:with-param name="source" select="$source"/>
     123                <xsl:with-param name="item" select="$item"/>
    117124            </xsl:apply-templates>
    118125        </xsl:for-each>
     
    123130           <xsl:apply-templates select="$this/subfield[1]" mode="testing">
    124131               <xsl:with-param name="pos" select="position()+1"/>
    125            <xsl:with-param name="source" select="$source"/> 
     132           <xsl:with-param name="source" select="$source"/>
     133               <xsl:with-param name="item" select="$item"/> 
    126134            </xsl:apply-templates>
    127135        </xsl:for-each>
     
    131139           <xsl:with-param name="pos" select="'0'"/>
    132140       <xsl:with-param name="source" select="$source"/>
     141           <xsl:with-param name="item" select="$item"/> 
    133142         </xsl:apply-templates>
    134143       </xsl:otherwise>
     
    139148     <xsl:param name="pos"/>
    140149     <xsl:param  name="source" />
     150     <xsl:param  name="item" />
    141151     <xsl:variable name="meta" select="@meta"/>
    142152     <xsl:choose>     
     
    145155             <xsl:apply-templates select="../@*" mode="mapping-attribute">
    146156               <xsl:with-param name="source" select="$source"/>
     157                <xsl:with-param name="item" select="$item"/>
    147158             </xsl:apply-templates>                                     
    148159             <xsl:apply-templates select="../subfield[not(@nonfiling)]" >                       
     
    153164       </xsl:when>
    154165       <xsl:otherwise>
    155              <xsl:apply-templates select="following-sibling::*[1]" mode="testing" >                          <xsl:with-param name="source" select="$source"/>
     166             <xsl:apply-templates select="following-sibling::*[1]" mode="testing" >
     167                    <xsl:with-param name="pos" select="$pos"/>
     168                    <xsl:with-param name="source" select="$source"/>
     169                    <xsl:with-param name="item" select="$item"/>
    156170             </xsl:apply-templates>
    157171         </xsl:otherwise>
     
    161175
    162176  <xsl:template match="@*" mode="mapping-attribute" >
    163      <xsl:param name="source" />   
     177     <xsl:param name="source" />
     178     <xsl:param name="item" /> 
    164179     <xsl:variable name="name" select="name()"/>
    165180     <xsl:variable name="value" select="."/>
     
    192207     <xsl:param name="subfield" />
    193208     <xsl:param name="source" />
     209
    194210  <xsl:variable name="itemname" select="@name"/>
    195211  <xsl:variable name="lowercasecontent" select="xsltutil:toLowerCase($content)"/>       
     
    197213           <xsl:when test="starts-with($lowercasecontent,$itemname) or count(following-sibling::*)=0">
    198214               <xsl:choose>
    199                  <xsl:when test="count(following-sibling::*) !=0 ">             
     215                 <xsl:when test="starts-with($lowercasecontent,$itemname)" >             
    200216                      <xsl:call-template name="addAttribute" >
    201217                         <xsl:with-param name="name" select="$name"/>
     
    251267      <xsl:choose>
    252268        <xsl:when test="@nonfiling='true'">
    253           <subfield code="{@code}"><xsl:value-of select="substring($content,$length+1)"/><xsl:value-of select="@punc"/></subfield>
     269          <subfield code="{@code}"><xsl:value-of select="$content"/><xsl:value-of select="@punc"/></subfield>
    254270        </xsl:when>
    255271        <xsl:when test="$pos >0">
     
    268284 
    269285</xsl:stylesheet>
    270 
Note: See TracChangeset for help on using the changeset viewer.