Copied marc21 and tmarc from pazpar2
authorDennis Schafroth <dennis@indexdata.com>
Wed, 29 Feb 2012 12:22:48 +0000 (13:22 +0100)
committerDennis Schafroth <dennis@indexdata.com>
Wed, 29 Feb 2012 12:22:48 +0000 (13:22 +0100)
src/org/marc4j/test/resources/marc21.xsl
src/org/marc4j/test/resources/tmarc.xsl

index 1aec6b9..e7bee0c 100644 (file)
        </pz:metadata>
       </xsl:for-each>
 
+      <xsl:for-each select="marc:datafield[@tag='130']">
+        <pz:metadata type="title-uniform">
+          <xsl:value-of select="marc:subfield[@code='a']" />
+        </pz:metadata>
+        <pz:metadata type="title-uniform-media">
+          <xsl:value-of select="marc:subfield[@code='m']" />
+        </pz:metadata>
+        <pz:metadata type="title-uniform-parts">
+          <xsl:value-of select="marc:subfield[@code='n']" />
+        </pz:metadata>
+        <pz:metadata type="title-uniform-partname">
+          <xsl:value-of select="marc:subfield[@code='p']" />
+        </pz:metadata>
+        <pz:metadata type="title-uniform-key">
+          <xsl:value-of select="marc:subfield[@code='r']" />
+        </pz:metadata>
+      </xsl:for-each>
+
       <xsl:for-each select="marc:datafield[@tag='260']">
         <pz:metadata type="date">
           <xsl:value-of select="translate(marc:subfield[@code='c'], 'cp[].', '')" />
         </pz:metadata>
       </xsl:if>
 
-      <xsl:for-each select="marc:datafield[@tag='130']">
-        <pz:metadata type="title-uniform">
-          <xsl:value-of select="marc:subfield[@code='a']" />
-        </pz:metadata>
-        <pz:metadata type="title-uniform-media">
-          <xsl:value-of select="marc:subfield[@code='m']" />
-        </pz:metadata>
-        <pz:metadata type="title-uniform-parts">
-          <xsl:value-of select="marc:subfield[@code='n']" />
-        </pz:metadata>
-        <pz:metadata type="title-uniform-partname">
-          <xsl:value-of select="marc:subfield[@code='p']" />
-        </pz:metadata>
-        <pz:metadata type="title-uniform-key">
-          <xsl:value-of select="marc:subfield[@code='r']" />
-        </pz:metadata>
-      </xsl:for-each>
-
       <xsl:for-each select="marc:datafield[@tag='245']">
         <pz:metadata type="title">
           <xsl:value-of select="marc:subfield[@code='a']"/>
        </pz:metadata>
       </xsl:for-each>
 
-       <xsl:for-each
-               select="marc:datafield[@tag = '500' or @tag = '505' or
+      <xsl:for-each select="marc:datafield[@tag = '500' or @tag = '505' or
                @tag = '518' or @tag = '520' or @tag = '522']">
-               <pz:metadata type="description">
-          <xsl:for-each select="node()">
-            <xsl:value-of select="text()" />
-          </xsl:for-each>
+       <pz:metadata type="description">
+            <xsl:value-of select="*/text()"/>
         </pz:metadata>
-       </xsl:for-each>
+      </xsl:for-each>
 
        <xsl:for-each
                select="marc:datafield[@tag='600' or @tag='610' or @tag='611' or @tag='630' or @tag='648' or @tag='650' or @tag='651' or @tag='653' or @tag='654' or @tag='655' or @tag='656' or @tag='657' or @tag='658' or @tag='662' or @tag='69X']">
                                </xsl:variable>
                                <xsl:choose>
                                        <xsl:when test="substring($value,string-length($value)) = ','">
-                                               <xsl:value-of select="substring($value,0,string-length($value))" />
+                                               <xsl:value-of select="substring($value,1,string-length($value)-1)" />
                                        </xsl:when>
                                        <xsl:otherwise>
                                                <xsl:value-of select="$value" />
                </pz:metadata>
        </xsl:for-each>
 
-    <xsl:for-each select="marc:datafield[@tag='856']">
-          <pz:metadata type="electronic-url">
-              <xsl:value-of select="marc:subfield[@code='u']"/>
-          </pz:metadata>
-          <pz:metadata type="electronic-text">
-               <xsl:choose>
-                       <xsl:when test="marc:subfield[@code='y']">
-                <xsl:value-of select="marc:subfield[@code='y']/text()" />
-                       </xsl:when>
-                       <xsl:when test="marc:subfield[@code='3']">
-                <xsl:value-of select="marc:subfield[@code='3']/text()" />
-                       </xsl:when>
-                       <xsl:otherwise>Get resource</xsl:otherwise>
-               </xsl:choose>
+      <xsl:for-each select="marc:datafield[@tag='856']">
+       <pz:metadata type="electronic-url">
+         <xsl:value-of select="marc:subfield[@code='u']"/>
+       </pz:metadata>
+       <pz:metadata type="electronic-text">
+         <xsl:value-of select="marc:subfield[@code='y' or @code='3' or @code='a']"/>
        </pz:metadata>
        <pz:metadata type="electronic-note">
          <xsl:value-of select="marc:subfield[@code='z']"/>
index 0cdaebf..faaa3ab 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:d610">
-        <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:d611">
-        <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:d630">
-        <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:d648">
-        <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:d650">
-        <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:d651">
-        <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:d653">
-        <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:d654">
-        <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 select="tmarc:d600 | tmarc:d610 | tmarc:d611 | tmarc:d630 |
+                            tmarc:d648 | tmarc:d650 | tmarc:d651 | tmarc:d653 |
+                            tmarc:d654 | tmarc:d655 | tmarc:d656 | tmarc:d657 |
+                            tmarc:d658 | tmarc:d662 | tmarc:d69X">
+         <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() &gt; 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, 1, string-length($value)-1)"/>
+              </xsl:when>
+              <xsl:otherwise>
+                <xsl:value-of select="$value"/>
+              </xsl:otherwise>
+            </xsl:choose> 
           </xsl:for-each>
-        </pz:metadata>
+         </pz:metadata>
       </xsl:for-each>
 
-      <xsl:for-each select="tmarc:d655">
-        <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:value-of select="." />
-          </xsl:for-each>
-        </pz:metadata>
-      </xsl:for-each>
-
-      <xsl:for-each select="tmarc:d656">
-        <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:d657">
-        <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:value-of select="." />
-          </xsl:for-each>
-        </pz:metadata>
-      </xsl:for-each>
-
-      <xsl:for-each select="tmarc:d658">
-        <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:d662">
-        <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:d69X">
-        <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>
-
-      <!-- or tmarc:d651 or tmarc:d653 or tmarc:d654 or tmarc:d655 or tmarc:d656 
-        or tmarc:d657 or tmarc:d658 or tmarc:d662 or tmarc:d69X"> -->
-
-      <!-- <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="tmarc:sa tmarc:sb tmarc:sc tmarc:sd "> <xsl:if test="position() 
-        > 1"> <xsl:text>, </xsl:text> </xsl:if> <xsl:value-of select="."/> </xsl:for-each> 
-        </pz:metadata> </xsl:for-each> -->
-
       <xsl:for-each select="tmarc:d856">
         <pz:metadata type="electronic-url">
           <xsl:value-of select="tmarc:su" />
              <xsl:when test="tmarc:s3">
                   <xsl:value-of select="tmarc:s3/text()" />
              </xsl:when>
+             <xsl:when test="tmarc:sa">
+                  <xsl:value-of select="tmarc:sa/text()" />
+             </xsl:when>
              <xsl:otherwise>Get resource</xsl:otherwise>
             </xsl:choose>
         </pz:metadata>