Add Normalization of subject-long for other fields that d600
authorDennis Schafroth <dennis@indexdata.com>
Wed, 22 Feb 2012 15:19:49 +0000 (16:19 +0100)
committerDennis Schafroth <dennis@indexdata.com>
Wed, 22 Feb 2012 15:19:49 +0000 (16:19 +0100)
etc/tmarc.xsl

index 8d658b9..0cdaebf 100644 (file)
         </pz:metadata>
       </xsl:for-each>
 
-      <xsl:for-each select="tmarc:d600">
-        <pz:metadata type="subject">
-          <xsl:value-of select="tmarc:sa" />
-        </pz:metadata>
-        <pz:metadata type="subject-long">
-          <xsl:for-each select="node()/text()">
-            <xsl:if test="position() > 1">
-              <xsl:text>, </xsl:text>
-            </xsl:if>
-           <xsl:variable name='value'>
-             <xsl:value-of select='normalize-space(.)'/>
-           </xsl:variable>
-           <xsl:choose>
-             <xsl:when test="substring($value,string-length($value)) = ','">
-               <xsl:value-of select="substring($value,0,string-length($value))"/>
-             </xsl:when>
-             <xsl:otherwise>
-               <xsl:value-of select="$value"/>
-             </xsl:otherwise>
-           </xsl:choose> 
-         </xsl:for-each>
-        </pz:metadata>
-      </xsl:for-each>
+       <xsl:for-each select="tmarc:d600">
+               <pz:metadata type="subject">
+                       <xsl:value-of select="tmarc:sa" />
+               </pz:metadata>
+               <pz:metadata type="subject-long">
+                       <xsl:for-each select="node()/text()">
+                               <xsl:if test="position() > 1">
+                                       <xsl:text>, </xsl:text>
+                               </xsl:if>
+                               <xsl:variable name='value'>
+                                       <xsl:value-of select='normalize-space(.)' />
+                               </xsl:variable>
+                               <xsl:choose>
+                                       <xsl:when test="substring($value,string-length($value)) = ','">
+                                               <xsl:value-of select="substring($value,0,string-length($value))" />
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <xsl:value-of select="$value" />
+                                       </xsl:otherwise>
+                               </xsl:choose>
+                       </xsl:for-each>
+               </pz:metadata>
+       </xsl:for-each>
 
       <xsl:for-each select="tmarc:d610">
         <pz:metadata type="subject">
             <xsl:if test="position() > 1">
               <xsl:text>, </xsl:text>
             </xsl:if>
-            <xsl:value-of select="." />
+                <xsl:variable name='value'>
+                    <xsl:value-of select='normalize-space(.)' />
+                </xsl:variable>
+                <xsl:choose>
+                    <xsl:when test="substring($value,string-length($value)) = ','">
+                        <xsl:value-of select="substring($value,0,string-length($value))" />
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <xsl:value-of select="$value" />
+                    </xsl:otherwise>
+                </xsl:choose>
           </xsl:for-each>
         </pz:metadata>
       </xsl:for-each>
             <xsl:if test="position() > 1">
               <xsl:text>, </xsl:text>
             </xsl:if>
-            <xsl:value-of select="." />
+                <xsl:variable name='value'>
+                    <xsl:value-of select='normalize-space(.)' />
+                </xsl:variable>
+                <xsl:choose>
+                    <xsl:when test="substring($value,string-length($value)) = ','">
+                        <xsl:value-of select="substring($value,0,string-length($value))" />
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <xsl:value-of select="$value" />
+                    </xsl:otherwise>
+                </xsl:choose>
           </xsl:for-each>
         </pz:metadata>
       </xsl:for-each>
             <xsl:if test="position() > 1">
               <xsl:text>, </xsl:text>
             </xsl:if>
-            <xsl:value-of select="." />
+                <xsl:variable name='value'>
+                    <xsl:value-of select='normalize-space(.)' />
+                </xsl:variable>
+                <xsl:choose>
+                    <xsl:when test="substring($value,string-length($value)) = ','">
+                        <xsl:value-of select="substring($value,0,string-length($value))" />
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <xsl:value-of select="$value" />
+                    </xsl:otherwise>
+                </xsl:choose>
           </xsl:for-each>
         </pz:metadata>
       </xsl:for-each>
             <xsl:if test="position() > 1">
               <xsl:text>, </xsl:text>
             </xsl:if>
-            <xsl:value-of select="." />
+                <xsl:variable name='value'>
+                    <xsl:value-of select='normalize-space(.)' />
+                </xsl:variable>
+                <xsl:choose>
+                    <xsl:when test="substring($value,string-length($value)) = ','">
+                        <xsl:value-of select="substring($value,0,string-length($value))" />
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <xsl:value-of select="$value" />
+                    </xsl:otherwise>
+                </xsl:choose>
           </xsl:for-each>
         </pz:metadata>
       </xsl:for-each>
             <xsl:if test="position() > 1">
               <xsl:text>, </xsl:text>
             </xsl:if>
-            <xsl:value-of select="." />
+                <xsl:variable name='value'>
+                    <xsl:value-of select='normalize-space(.)' />
+                </xsl:variable>
+                <xsl:choose>
+                    <xsl:when test="substring($value,string-length($value)) = ','">
+                        <xsl:value-of select="substring($value,0,string-length($value))" />
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <xsl:value-of select="$value" />
+                    </xsl:otherwise>
+                </xsl:choose>
           </xsl:for-each>
         </pz:metadata>
       </xsl:for-each>
             <xsl:if test="position() > 1">
               <xsl:text>, </xsl:text>
             </xsl:if>
-            <xsl:value-of select="." />
+                <xsl:variable name='value'>
+                    <xsl:value-of select='normalize-space(.)' />
+                </xsl:variable>
+                <xsl:choose>
+                    <xsl:when test="substring($value,string-length($value)) = ','">
+                        <xsl:value-of select="substring($value,0,string-length($value))" />
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <xsl:value-of select="$value" />
+                    </xsl:otherwise>
+                </xsl:choose>
           </xsl:for-each>
         </pz:metadata>
       </xsl:for-each>
             <xsl:if test="position() > 1">
               <xsl:text>, </xsl:text>
             </xsl:if>
-            <xsl:value-of select="." />
+                <xsl:variable name='value'>
+                    <xsl:value-of select='normalize-space(.)' />
+                </xsl:variable>
+                <xsl:choose>
+                    <xsl:when test="substring($value,string-length($value)) = ','">
+                        <xsl:value-of select="substring($value,0,string-length($value))" />
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <xsl:value-of select="$value" />
+                    </xsl:otherwise>
+                </xsl:choose>
           </xsl:for-each>
         </pz:metadata>
       </xsl:for-each>
             <xsl:if test="position() > 1">
               <xsl:text>, </xsl:text>
             </xsl:if>
-            <xsl:value-of select="." />
+                <xsl:variable name='value'>
+                    <xsl:value-of select='normalize-space(.)' />
+                </xsl:variable>
+                <xsl:choose>
+                    <xsl:when test="substring($value,string-length($value)) = ','">
+                        <xsl:value-of select="substring($value,0,string-length($value))" />
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <xsl:value-of select="$value" />
+                    </xsl:otherwise>
+                </xsl:choose>
           </xsl:for-each>
         </pz:metadata>
       </xsl:for-each>
             <xsl:if test="position() > 1">
               <xsl:text>, </xsl:text>
             </xsl:if>
-            <xsl:value-of select="." />
+                <xsl:variable name='value'>
+                    <xsl:value-of select='normalize-space(.)' />
+                </xsl:variable>
+                <xsl:choose>
+                    <xsl:when test="substring($value,string-length($value)) = ','">
+                        <xsl:value-of select="substring($value,0,string-length($value))" />
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <xsl:value-of select="$value" />
+                    </xsl:otherwise>
+                </xsl:choose>
           </xsl:for-each>
         </pz:metadata>
       </xsl:for-each>
             <xsl:if test="position() > 1">
               <xsl:text>, </xsl:text>
             </xsl:if>
-            <xsl:value-of select="." />
+                <xsl:variable name='value'>
+                    <xsl:value-of select='normalize-space(.)' />
+                </xsl:variable>
+                <xsl:choose>
+                    <xsl:when test="substring($value,string-length($value)) = ','">
+                        <xsl:value-of select="substring($value,0,string-length($value))" />
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <xsl:value-of select="$value" />
+                    </xsl:otherwise>
+                </xsl:choose>
           </xsl:for-each>
         </pz:metadata>
       </xsl:for-each>
             <xsl:if test="position() > 1">
               <xsl:text>, </xsl:text>
             </xsl:if>
-            <xsl:value-of select="." />
+                <xsl:variable name='value'>
+                    <xsl:value-of select='normalize-space(.)' />
+                </xsl:variable>
+                <xsl:choose>
+                    <xsl:when test="substring($value,string-length($value)) = ','">
+                        <xsl:value-of select="substring($value,0,string-length($value))" />
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <xsl:value-of select="$value" />
+                    </xsl:otherwise>
+                </xsl:choose>
           </xsl:for-each>
         </pz:metadata>
       </xsl:for-each>
             <xsl:if test="position() > 1">
               <xsl:text>, </xsl:text>
             </xsl:if>
-            <xsl:value-of select="." />
+                <xsl:variable name='value'>
+                    <xsl:value-of select='normalize-space(.)' />
+                </xsl:variable>
+                <xsl:choose>
+                    <xsl:when test="substring($value,string-length($value)) = ','">
+                        <xsl:value-of select="substring($value,0,string-length($value))" />
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <xsl:value-of select="$value" />
+                    </xsl:otherwise>
+                </xsl:choose>
           </xsl:for-each>
         </pz:metadata>
       </xsl:for-each>
           <xsl:value-of select="tmarc:su" />
         </pz:metadata>
         <pz:metadata type="electronic-text">
-          <xsl:choose>
-           <xsl:when test="tmarc:sy">
-             <xsl:value-of select="tmarc:sy/text()" />
-           </xsl:when>
-           <xsl:when test="tmarc:s3">
-             <xsl:value-of select="tmarc:s3/text()" />
-           </xsl:when>
-            <xsl:otherwise>Get resource</xsl:otherwise>
-          </xsl:choose>
+         <xsl:choose>
+             <xsl:when test="tmarc:sy">
+                  <xsl:value-of select="tmarc:sy/text()" />
+             </xsl:when>
+             <xsl:when test="tmarc:s3">
+                  <xsl:value-of select="tmarc:s3/text()" />
+             </xsl:when>
+             <xsl:otherwise>Get resource</xsl:otherwise>
+            </xsl:choose>
         </pz:metadata>
         <pz:metadata type="electronic-note">
           <xsl:value-of select="tmarc:sz" />