]> git.lyx.org Git - lyx.git/blobdiff - src/BiblioInfo.cpp
... and RELEASE-NOTES
[lyx.git] / src / BiblioInfo.cpp
index 421d71756b145926349f90fa5d16ab7c73f83991..243f78c59f6595fb7d24ac0cede957e04e2db87c 100644 (file)
@@ -326,7 +326,7 @@ docstring const BibTeXInfo::getYear() const
                // Format is [-]YYYY-MM-DD*/[-]YYYY-MM-DD*
                // We only want the years.
                static regex const yreg("[-]?([\\d]{4}).*");
-               static regex const ereg(".*/([\\d]{4}).*");
+               static regex const ereg(".*/[-]?([\\d]{4}).*");
                smatch sm;
                string const date = to_utf8(year);
                regex_match(date, sm, yreg);
@@ -796,20 +796,36 @@ vector<docstring> const BiblioInfo::getXRefs(BibTeXInfo const & data, bool const
        if (!data.isBibTeX())
                return result;
        // Legacy crossref field. This is not nestable.
-       if (!nested && !data["crossref"].empty())
-               result.push_back(data["crossref"]);
-       // Biblatex's xdata field. Infinitely nestable.
-       docstring const xdatakey = data["xdata"];
-       if (!xdatakey.empty()) {
-               result.push_back(xdatakey);
-               BiblioInfo::const_iterator it = find(xdatakey);
+       if (!nested && !data["crossref"].empty()) {
+               docstring const xrefkey = data["crossref"];
+               result.push_back(xrefkey);
+               // However, check for nested xdatas
+               BiblioInfo::const_iterator it = find(xrefkey);
                if (it != end()) {
-                       BibTeXInfo const & xdata = it->second;
-                       vector<docstring> const nxdata = getXRefs(xdata, true);
+                       BibTeXInfo const & xref = it->second;
+                       vector<docstring> const nxdata = getXRefs(xref, true);
                        if (!nxdata.empty())
                                result.insert(result.end(), nxdata.begin(), nxdata.end());
                }
        }
+       // Biblatex's xdata field. Infinitely nestable.
+       // XData field can consist of a comma-separated list of keys
+       vector<docstring> const xdatakeys = getVectorFromString(data["xdata"]);
+       if (!xdatakeys.empty()) {
+               vector<docstring>::const_iterator xit = xdatakeys.begin();
+               vector<docstring>::const_iterator xen = xdatakeys.end();
+               for (; xit != xen; ++xit) {
+                       docstring const xdatakey = *xit;
+                       result.push_back(xdatakey);
+                       BiblioInfo::const_iterator it = find(xdatakey);
+                       if (it != end()) {
+                               BibTeXInfo const & xdata = it->second;
+                               vector<docstring> const nxdata = getXRefs(xdata, true);
+                               if (!nxdata.empty())
+                                       result.insert(result.end(), nxdata.begin(), nxdata.end());
+                       }
+               }
+       }
        return result;
 }