David N. Wilson <[EMAIL PROTECTED]> a écrit :
Jean-Marie,
Wow this looks very easy to use.
As a project lead of the OOo Bibliographic project I am interested in accessing the bibliographic fields and Bibliographic table entry.
I assume you have to build these in to your xpath descriptions ?
regards
David
David,
Practically, there is not a lot of things to build
OpenOffice::OODoc provides 2 levels of API. The low-level one allows access to any kind of content, but it requires the knowledge of the XML logical paths and naming conventions. The high-level API is a (growing) set of wrappers or shortcuts that provide a mnemonic, user-friendly syntax for the most used elements; it's designed to hide the XML stuff and to help writing compact and self-documented programs.
For the present time, there is no mnemonic shortcut such as selectBibliographicEntry(). If there is a real need, I may consider adding a small set of bibliography-focused methods (it's not a headache). But you could go on immediately with the existing low-level API.
In order to give you a general idea of the job, I wrote a short program that opens a given document, retrieves a given biblio reference then prints some of its properties (author, title, publisher, year, ISBN) and exits. The (untested) code is attached at the end of this message. Note that getAttribute() in this script could be replaced by setAttribute() as well, so every property could be updated and not only read.
Note that it's very easy to encapsulate such a code in a server program, communicating by a socket or a web service, so the user's applications can be written in any language, and can see the OOo "connector" as a database service.
Fell free to contact me again for more information if needed.
Regards
#--------------------------------------------------------- # This script extracts some data from an OOo bibliographic # entry. Its command line must contain 2 arguments: the # file name and the identifier of the biblio entry. # Note: It's not a real world situation; one should not # instantiate a document object just for retrieving only # one element; ooDocument() loads and parses the full # document, and it's the most costly operation.
use OpenOffice::OODoc;
my ($filename, $identifier) = @ARGV;
# get a document connector
my $doc = ooDocument(file => $filename)
or die "Unknown or non-valid OOo file\n"; # query for the needed biblio field
my $bib = $doc->selectElementByAttribute
(
'//text:bibliography-mark',
'text:identifier',
$identifier
)
or die "Unknown reference\n";# extract the properties my $author = $doc->getAttribute($bib, "text:author"); my $title = $doc->getAttribute($bib, "text:title"); my $publiher = $doc->getAttribute($bib, "text:publisher"); my $year = $doc->getAttribute($bib, "text:year"); my $isbn = $doc->getAttribute($bib, "text:isbn");
# create the report
print "Author: $author\n" .
"Title: $title\n" .
"Publisher: $publisher\n" .
"Year: $year\n" .
"ISBN: $isbn\n";# that's all exit;
#---------------------------------------------------------
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
