xml - XSL transformation from EAD to MARC skips over 2nd subject term -


i have strange problem. have xml documents encoded in ead i'm transforming marc records library catalog. there section of ead document looks this:

    <controlaccess>         <list type="simple">             <item><subject encodinganalog="650" source="lcsh">prisons -- history -- 19th century</subject></item>             <item><subject encodinganalog="650" source="lcsh">prisons -- statistics -- history -- 19th century</subject></item>             <item><subject encodinganalog="650" source="lcsh">prisons -- statistics -- term 1 -- history -- 19th century</subject></item>             <item><subject encodinganalog="650" source="lcsh">prisons -- statistics -- term 1 -- term 2 -- history -- 19th century</subject></item>         </list>     </controlaccess> 

what code correctly pull out each item/subject , create marc field each one, , each term that's separated "--" gets put separate subfield (either a, x, y, or whatever).

the code if there 1-3 terms in single subject element, if there 4 or more terms, second term gets left out entirely , rest of terms (from third 1 on) extracted properly. can't figure out why second term gets skipped on if there 4+ terms. that's i'd figuring out.

i'm using xsl 1.0 , subject portion of code looks this. parameter gets called main template.

<xsl:template name="subject_template">         <xsl:param name="string" />         <marc:datafield>             <xsl:choose>                 <xsl:when test="contains($string, '--')!=0">                     <xsl:variable name="tmp1" select="substring-before($string, '--')" />                     <xsl:variable name="tmp2" select="substring-after($string, '--')" />                     <marc:subfield code="a">                         <xsl:value-of select="$tmp1" />                     </marc:subfield>                     <xsl:call-template name="subject_tokenize">                         <xsl:with-param name="string" select="$tmp2" />                         <xsl:with-param name="type" select="'x'" />                     </xsl:call-template>                 </xsl:when>                 <xsl:otherwise>                     <marc:subfield code="a">                         <xsl:value-of select="$string" />                     </marc:subfield>                 </xsl:otherwise>             </xsl:choose>         </marc:datafield>     </xsl:template> 

here tokenize template, hundreds of lines long. tried include necessary/relevant problem.. 4 variables in beginning (genx, etc) pull huge list of terms determine subfield code should be.

<xsl:template name="subject_tokenize">     <xsl:param name="string" />     <xsl:param name="type" />     <xsl:variable name="genx">         <xsl:call-template name="genx" />     </xsl:variable>     <xsl:variable name="geny">         <xsl:call-template name="geny" />     </xsl:variable>     <xsl:variable name="formlist">         <xsl:call-template name="formlist" />     </xsl:variable>     <xsl:variable name="geoglist">         <xsl:call-template name="geoglist" />     </xsl:variable>     <xsl:if test="contains($string, '--')!=0">         <xsl:variable name="str1" select="substring-before($string, '--')"/>         <xsl:variable name="str2" select="substring-after($string, '--')"/>         <xsl:if test="contains($str2, '--')!=0">             <xsl:variable name="newstr2" select="substring-after($str2, '--')"/>             <xsl:variable name="tmpvar" select="substring-before($str2, '--')"/>             <xsl:choose>                 <xsl:when test="testsomething">                     stuff                 </xsl:when>                 <xsl:otherwise>                     <xsl:if test="contains($geoglist, translate($str1, '.', ''))!=0">                         <marc:subfield code="z">                             <xsl:value-of select="$str1"/>                         </marc:subfield>                         <xsl:if                             test="contains($formlist, translate(substring-before($str2, '--'), '.', ''))!=0">                             <marc:subfield code="v">                                 <xsl:value-of select="substring-before($str2, '--')"/>                             </marc:subfield>                         </xsl:if>                         <xsl:if                             test="contains($geny, translate(substring-before($str2, '--'), '.', ''))!=0">                             <marc:subfield code="y">                                 <xsl:value-of select="substring-before($str2, '--')"/>                             </marc:subfield>                         </xsl:if>                         <xsl:if                             test="contains($genx, translate(substring-before($str2, '--'), '.', ''))!=0">                             <marc:subfield code="x">                                 <xsl:value-of select="substring-before($str2, '--')"/>                             </marc:subfield>                         </xsl:if>                         <xsl:if                             test="contains($formlist, translate(substring-before($str2, '--'), '.', ''))=0 , contains($genx, translate(substring-before($str2, '--'), '.', ''))=0 , contains($geny, translate(substring-before($str2, '--'), '.', ''))=0">                             <marc:subfield code="z">                                 <xsl:value-of select="substring-before($str2, '--')"/>                             </marc:subfield>                         </xsl:if>                     </xsl:if>                     <xsl:if test="contains($formlist, translate($str1, '.', ''))!=0">                         <marc:subfield code="v">                             <xsl:value-of select="$str1"/>                         </marc:subfield>                     </xsl:if>                     <xsl:if test="contains($geny, translate($str1, '.', ''))!=0">                         <marc:subfield code="y">                             <xsl:value-of select="$str1"/>                         </marc:subfield>                     </xsl:if>                     <xsl:if                         test="contains($formlist, translate($str1, '.', ''))=0 , contains($geny, translate($str1, '.', ''))!=0">                         <marc:subfield code="x">                             <xsl:value-of select="$str1"/>                         </marc:subfield>                     </xsl:if>                     <xsl:if test="contains($geoglist, translate($str1, '.', ''))=0">                         <xsl:if                             test="contains($formlist, translate(substring-before($str2, '--'), '.', ''))!=0">                             <marc:subfield code="v">                                 <xsl:value-of select="substring-before($str2, '--')"/>                             </marc:subfield>                         </xsl:if>                         <xsl:if                             test="contains($geny, translate(substring-before($str2, '--'), '.', ''))!=0">                             <marc:subfield code="y">                                 <xsl:value-of select="substring-before($str2, '--')"/>                             </marc:subfield>                         </xsl:if>                         <xsl:if                             test="contains($geoglist, translate(substring-before($str2, '--'), '.', ''))!=0">                             <marc:subfield code="z">                                 <xsl:value-of select="substring-before($str2, '--')"/>                             </marc:subfield>                         </xsl:if>                         <xsl:if                             test="contains($geoglist, translate(substring-before($str2, '--'), '.', ''))=0 , contains($geny, translate(substring-before($str2, '--'), '.', ''))=0 , contains($formlist, translate(substring-before($str2, '--'), '.', ''))=0">                             <marc:subfield code="x">                                 <xsl:value-of select="substring-before($str2, '--')"/>                             </marc:subfield>                         </xsl:if>                     </xsl:if>                     <xsl:call-template name="subject_tokenize">                         <xsl:with-param name="string" select="$newstr2"/>                         <xsl:with-param name="type" select="'x'"/>                     </xsl:call-template>                 </xsl:otherwise>             </xsl:choose>         </xsl:if> 

my output looks this:

=650  \0$aprisons $x history $x 19th century =650  \0$aprisons $x history $x 19th century =650  \0$aprisons $x term 1 $x history $x 19th century =650  \0$aprisons $x term 1 $x term 2 $x history $x 19th century 

the first 650 field correct. following 3 missing second term, "statistics." example , has been replicated different terms, different ordering of terms, and/or different quantity of terms. assume problem lies in xsl code showed because that's part of code should affecting example provided. if nobody finds errors in xsl snippet, perhaps take @ full xsl.

update: here link (https://drive.google.com/folderview?id=0b647oe0wvd5-rffpmjhqsjk3cve&usp=sharing) of files. includes entire xsl , xml, additional xsl gets imported, resulting output mrc file, , txt version of mrc file easier viewing.


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -