+vector<docstring> const BiblioInfo::getXRefs(BibTeXInfo const & data, bool const nested) const
+{
+ vector<docstring> result;
+ if (!data.isBibTeX())
+ return result;
+ // Legacy crossref field. This is not nestable.
+ 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 & 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;
+}
+
+