Exporting bibtex constant strings to MS Office 2007 (xml)

I am trying to convert my bibtex (.bib) file to MS Office 2007 (.xml). JabRef seems to do this flawlessly, except that my .bib file makes use of string constants (for journal names). When I export the .bib file to MS Office 2007 (.xml) the string constants are not resolved/expanded and show up as the key enclosed by hashes (#key#). When exporting to xml, is it possible for JabRef to expand the string constants into the value, rather than the key?

Here is a MWE:

.bib file:

@String{grl = "Geophys. Res. Lett."}

@article{claudepierre:20a,
    author = {Claudepierre, S. G.},
    journal = grl
}

Use JabRef to export the above .bib file to MS Office 2007. The exported .xml file will have the following for the JournalName field:

<b:JournalName>#grl#</b:JournalName>

whereas the desired behavior would be:

<b:JournalName>Geophys. Res. Lett.</b:JournalName>

I’ve searched the online documentation on strings, export to MS Word, and journal abbreviations but I have not been able to find a solution. My apologies if I have overlooked something.

Hi,

thanks for the report. Currently, BibTeX Strings are only resolved when writing in the bib file format and only for the list of fields mentioned in the preferences.

But from a look at the code it should be just two lines that would need to be modified:

It should be:

   public MSBibDatabase(BibDatabase database, List<BibEntry> entries) {
        if (entries == null) {
            var resolvedEntries = database.resolveForStrings(database.getEntries(), false);
            addEntriesForExport(resolvedEntries);
        } else {
            var resolvedEntries = database.resolveForStrings(entries, false);
            addEntriesForExport(resolvedEntries);
        }
    }

I have not yet tested it. Can do this later and prepare a PR.

Excellent, thanks Christoph!

Good news,

the issue is now solved in the latest development version. Strings are now resolved when exporting to MSBib.

(currently building, ready in roughly 30 minutes)

Remember to make a backup of your library file if you try out the new version!

This is awesome, thanks so much! The new build works perfectly for the MWE provided in my original post. However, I do have some string constants formatted in a more Latex-friendly way, such as:

@string{grl   = {Geophys.\ Res.\ Lett.}}

These get mangled into this in the xml:

<b:JournalName>Geophys.\ {R}{e}{s}.\ {L}{e}{t}t.</b:JournalName>

Maybe something funny is happening because of the backslash (escape) in the string constant?

1 Like

Thanks for the feedback, glad that it works so far.

I took another look, the exporter tries to get the Latex-Free variant (e.g. the Unicode representation) of each field. But with resolving of String constants, I have no idea how this works together. Maybe @koppor can help here, he knows more about those BibtTeX-Strings

1 Like