Menu

xml2bib: chapter title and book title not converted propertly

2016-05-09
2016-05-23
  • vivek botcha

    vivek botcha - 2016-05-09

    Hi,

    While converting chapter mods xml to bibtex with xml2bib 5.7, we've found that title and booktitle are not converted the way we expected.

    For example

    $ cat mods
    <?xml version="1.0" encoding="UTF-8"?>
    <modsCollection xmlns="http://www.loc.gov/mods/v3">
    <mods>
        <titleInfo>
            <title>chapter title</title>
        </titleInfo>
        <typeOfResource>text</typeOfResource>
        <genre>book chapter</genre>
        <relatedItem type="host">
            <titleInfo>
               <title>book title</title>
            </titleInfo>
        </mods>
    </modsCollection>
    
    $ ./xml2bib --version
    xml2bib, bibutils suite version 5.7 date 2016-02-15
    
    $ ./xml2bib mods
    @Inbook{ref1,
    chapter="chapter title",
    title="book title"
    }
    
    xml2bib: Processed 1 references.
    

    Instead, we expected the bibtex to be

    @Inbook{ref1,
    title="chapter title",
    bookTitle="book title"
    }
    

    It looks like the tags get converted in bibtexout.c. We've tried a quick change that seem to generate it as we expect.

    $ diff -u bibutils_5.7.bak/lib/bibtexout.c bibutils_5.7/lib/bibtexout.c
    --- bibutils_5.7.bak/lib/bibtexout.c    2016-05-09 11:11:01.929326653 +0100
    +++ bibutils_5.7/lib/bibtexout.c    2016-05-09 11:12:21.381326792 +0100
    @@ -583,16 +583,13 @@
        output_people( fp, info, refnum, "TRANSLATOR", "TRANSLATOR:CORP", "TRANSLATOR:ASIS", "translator", -1, p->format_opts );
    
        /* item=main level title */
    -   if ( type==TYPE_INBOOK )
    -       output_title( fp, info, refnum, "chapter", 0, p->format_opts );
    -   else
    -       output_title( fp, info, refnum, "title", 0, p->format_opts );
    +   output_title( fp, info, refnum, "title", 0, p->format_opts );
    
        /* item=host level title */
        if ( type==TYPE_ARTICLE )
            output_title( fp, info, refnum, "journal", 1, p->format_opts );
        else if ( type==TYPE_INBOOK ) {
    -       output_title( fp, info, refnum, "title", 1, p->format_opts );
    +       output_title( fp, info, refnum, "bookTitle", 1, p->format_opts );
            output_title( fp, info, refnum, "series", 2, p->format_opts );
        }
        else if ( type==TYPE_INPROCEEDINGS || type==TYPE_INCOLLECTION ) {
    

    Do you think that this change would be a good idea? Could it be included in bibutils?

    Thanks,
    IT Development Team,
    SpringerNature,
    London.

     
  • Chris Putnam

    Chris Putnam - 2016-05-11

    This is correct. Clearly I was getting confused between chapter/title for @inbook. The patch looks right too. I'm running it through my regression suite now, but I suspect that I'll be uploading this fix soonish.

     
  • vivek botcha

    vivek botcha - 2016-05-13

    Thanks Chris Putnam for looking into this:)

     
  • Chris Putnam

    Chris Putnam - 2016-05-23

    This is now updated in the fixed version 5.8.

     

Log in to post a comment.