I'd like to include an xquery script with my stylesheet archive to do
the following:
1) take my source document, extract all of the citations from it
2) use that list of citations to create a bibliography collection,
where the bibliographic records are in their own directory, with
filenames that are the same as the IDs, plus an extension.
So, citation is:
<citation><biblioref linkend="doe99"/></citation>
The record it points to is thus "bib-data/doe99.xml".
3) Insert that bibliography into the document, and then run my
stylesheets on it, with a citation-style parameter entered by the user
on the commandline.
Below is where I'm at. I'm stuck on
1) how to define the article path to be a variable entered by the user
2) how to define where to grab the mods data (bib-data/{$citation}.xml
doesn't work, nor does bib-data/*)
3) how to run the stylesheets (with parameter) on the returned article
Bruce
xquery version "1.0";
declare default element namespace "http://docbook.org/docbook-ng";
declare namespace mods="http://www.loc.gov/mods/v3";
declare namespace xbiblio="http://xbiblio.sourceforge.net";
declare function xbiblio:resolve-references($article as element())
as element()* {
(: extract citation linkend values from the docbook-ng file :)
for $citation in distinct-values($article//biblioref/@linkend)
(: find the corresponding mods record :)
let $mods := doc("bib-data/*")//mods:mods[(_at_)ID = $citation]
return
if(empty($mods)) then
(: not found: stop processing :)
error(concat("No record found for reference ", $citation))
else
$mods
};
let $article := doc("test.xml")/article
return
<article>
{$article/*}
<bibliography>
<mods:modsCollection>
{xbiblio:resolve-references($article)}
</mods:modsCollection>
</bibliography>
</article>