Scripts. XSL conversions can require a lot of commands and options, most of which do not change between runs. pilot-qof includes sample scripts that demonstrate how to ease the process.
Example 4.1. Using stylesheets in scripts of your own
A typical command from one of these scripts is:
XML_CATALOG_FILES="/usr/share/xml/datafreedom/xsl/catalog.xml" \ xsltproc --nonet http://www.data-freedom.org/xsl/pilot-qof-calcurse-todo.xsl $1
$1 indicates the first argument passed to the script (in this
case an XML file). XML_CATALOG_FILES
is an environment
variable, set just for this script. Where stylesheets in this manual can
use other options, these are documented in a shortened form that omits the
environment variable and the URL of the stylesheet.
Sample bash scripts are neither installed into system-wide locations nor available within the default system path. You are advised to copy the scripts into user-specific locations to make it easier to adjust the script behaviour.
pilot-qof-2-address-vcard1
A sample bash script that demonstrates how an XSL stylesheet can
be used with less typing. It uses
pilot-qof-address-vcard1.xsl
as an example. Other
scripts are also included:
pilot-qof-2-apts-calcurse
Automate use of the pilot-qof-calcurse-apts.xsl stylesheet.
pilot-qof-2-todo-calcurse
Automate use of the pilot-qof-calcurse-todo.xsl stylesheet.
dfexport-all
dfexport-all is intended to export
pilot-qof
data to various supported applications.
Unlike the datafreedom stylesheets which can work with just the QSF XML,
this example script uses the pilot-qof
utility to update
and query the XML. The script will fail if pilot-qof
is not installed.
dfexport-all should be run in the same
directory as the pilot-qof
data. If the
offline.xml
is not in the correct directory,
dfexport-all
will seek to connect to the Palm to create
the file from a pilot-qof HotSync.
For this reason, dfexport-all is still an example
script (installed in /usr/share/
not /usr/bin
).
Supported applications:
Example 4.2. Using dfexport-all and zenity-invoice with gnucash to create invoices
Creating invoices in gnucash is still a labour intensive task but by using
pilot-qof
, datafreedom-qsfxsl
and
datafreedom-perl
together with dates
, it is
possible to have all the necessary information on the same screen.
dfexport-all
can export calendar data to dates
which in turn supports a drop down calendar from the clock in the panel dock. This
highlights the days that have events and includes the description of the event, which
helps in creating the invoice window data in gnucash
.
Then zenity-invoice
is another sample script that displays
the invoice using data calculated from pilot-qof
, allowing easier
data entry into the gnucash invoice entries. In the figure, zenity-invoice
has been assigned a sample spreadsheet-like icon by adding a customised applet to the
panel.
zenity-invoice
uses perl and is part of the
datafreedom-perl
package. Generating an invoice with XSL is problematic
unless your invoice needs are very simple. Eventually, it is hoped that gnucash will be able
to import invoice data as XML or other text format, at which point pilot-qof
will provide a script to automate the process within the datafreedom-perl
package. See
http://bugzilla.gnome.org/show_bug.cgi?id=355939.
Figure 4.1. Using dfexport-all, zenity-invoice and dates with gnucash
The drop-down calendar (top right) contains data from dates
which is
exported from pilot-qof
using dfexport-all
. This
drop-down remains on top until cancelled by clicking on the date/time widget in the panel.
The description of the calendar event, along with the date of the event, provides the information
needed to create a new invoice window in gnucash
(foreground).
zenity-invoice
creates the text window at top left with
the selected date in the title, this provides the data for the entries within the invoice in
gnucash
. zenity-invoice
will calculate the cost of
each invoice entry but the actual rates and results have been obscured from the screenshot.
The two windows in the background are views of PDF files detailing the payments made from
submitted invoices which provide data for entry into the gnucash
Process Payments dialogue.
Others
Any plain text, XML or HTML format can be generated, including possibly LDAP. If you have a request for an XSL stylesheet or if you have a stylesheet you would like to make available to others, mention it on the QOF-devel mailing list. http://lists.sourceforge.net/lists/listinfo/qof-devel
Although it is fine to pipe pilot-qof output to other processes like xsltproc, (note the terminal dash - to denote that xsltproc should expect the XML content on stdin) :
Example 4.3. Redirection from a QSF XML file.
$ pilot-qof -x whole_year.xml --invoice-city -t 2006-03-01 | \ xsltproc --nonet http://www.data-freedom.org/xsl/pilot-qof-invoice-xhtml.xsl -
Just remember that it might not be so wise to do this:
Example 4.4. Redirection from a HotSync - use with caution.
$ pilot-qof -a --invoice-city -t 2006-03-01 | \ xsltproc --nonet http://www.data-freedom.org/xsl/pilot-qof-invoice-xhtml.xsl -
Why? Because using -a
means that your Palm data is
not being backed up in this process (because the XML sent to xsltproc by the
pipe is not saved and cannot be recreated from the HTML). Now, of course, you
can sync your Palm twice but reading from the backup file is a lot faster.
"If the Palm data has changed, use -a
to backup to file.
If the Palm data has not changed, use -x
to
read the backup file."
Reporting Bugs. Please do NOT report bugs in pilot-QOF to pilot-link or GnuCash. Report bugs via the Pilot-QOF Mantis bug tracker. http://sourceforge.net/apps/mantisbt/pilot-qof/main_page.php