Normalization of other subject-long fields of d600
authorDennis Schafroth <dennis@indexdata.com>
Wed, 22 Feb 2012 15:25:43 +0000 (16:25 +0100)
committerDennis Schafroth <dennis@indexdata.com>
Wed, 22 Feb 2012 15:25:43 +0000 (16:25 +0100)
src/org/marc4j/test/resources/tmarc.xsl

index fa91b03..0cdaebf 100644 (file)
             <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" />