lcnetdev / marc2bibframe2

Convert MARC records to BIBFRAME2 RDF
http://www.loc.gov/bibframe/
Creative Commons Zero v1.0 Universal
88 stars 35 forks source link

Preprocessing failures due to XPath error #231

Closed kouralex closed 7 months ago

kouralex commented 9 months ago

I have tested the new preprocessing/splitting feature with our (National Library of Finland) MARC/XML records, and whilst it mostly works as expected, there appears to be some issues with the new ConvSpec-Preprocess0-Splitting.xsl file. Running xsltproc with verbose output gives us this (partial) stack trace:

Handling xsl:with-param df856sf3
Building variable df856sf3
Evaluating variable 'df856sf3'
xsltValueOf: select marc:subfield[@code = '3']
xsltValueOf: result ''
Object is an XSLT value tree :
1  Node is NULL !
Handling xsl:with-param df300
Building variable df300
Evaluating variable 'df300'
xsltApplySequenceConstructor: copy node datafield
Object is an XSLT value tree :
1  ELEMENT marc:datafield
    namespace marc href=http://www.loc.gov/MARC21/slim
Handling xsl:with-param cf007
        select 'c'
Building variable cf007 select 'c'
Evaluating variable 'cf007'
Object is a string : c
applying xsl:template 'getTitleStr'
xsltChoose: test $df856sf3 != ''
Lookup variable 'df856sf3'
xsltChoose: test evaluate to 0
xsltChoose: test $df300/marc:subfield[@code='3'] and $df300/marc:subfield[@code='3'] != 'all'
Lookup variable 'df300'
XPath error : Invalid type
call-template returned: name getTitleStr
freeing transformation dictionary
no result for record.xml
freeing dictionary from stylesheet

As a result, the document will be empty.

Some example records that gave the stack trace are listed below (I had to rename them to .txt because of GitHub restrictions on attaching .xml files):

000965383.txt 018751375.txt 018291591.txt 017498204.txt 017462995.txt

Used xsltproc version:

xsltproc --version
Using libxml 20914, libxslt 10134 and libexslt 820
xsltproc was compiled against libxml 20910, libxslt 10134 and libexslt 820
libxslt 10134 was compiled against libxml 20910
libexslt 820 was compiled against libxml 20910
kefo commented 9 months ago

Thanks. I can reproduce this on my end, with both xsltproc and an older version of saxon. I'll look into making a patch release to address this, but the absolute earliest will be Wednesday and even then I can offer no guarantee.

If, however, you want to get around the issue, the problem, I think, is this line:

https://github.com/lcnetdev/marc2bibframe2/blob/f525aaf21c2f5dc4f325f75f90352b1922c3adc7/xsl/ConvSpec-Preprocess0-Splitting.xsl#L372

Replace it with

<xsl:with-param name="df300" select="$record/marc:datafield[@tag = 'ei mitään']" />

And that should get you around the error. It works for me presently.

jodiw01 commented 7 months ago

This issue has been addressed (above)