* SXML tree operations
@ 2005-07-24 19:34 Mario Storti
0 siblings, 0 replies; only message in thread
From: Mario Storti @ 2005-07-24 19:34 UTC (permalink / raw)
Hi all,
I started playing with SXML (the (axml transform) and (sxml xpath)
modules in guile-lib).
As an example, I proposed myself to write a simple
application to generate a bibliography list in LaTeX, with a certain
format, from a database written in SXML. For instance I have
(define data-base
'(root
(paper
(code "paper1")
(authors
(a "Author1 N1.")
(a "Author2 N2.")
(a "Author3 N3."))
(title "Name of paper")
(journal "The Journal")
(year 2004))
(paper
(code "paper2")
(authors
(a "Author21 N21.")
(a "Author22 N22.")
(a "Author23 N23."))
(title "Name of paper2")
(journal "The Journal2")
(year 2003))
...))
And I want an output like
\begin{enumerate}
\item Author1 N1., Author2 N2, Author3 N3.
``Name of Paper'', \emph{The Journal} (2004)
\item Author21 N21., Author22 N22, Author23 N23.
``Name of Paper2'', \emph{The Journal2} (2003)
....
\end{enumerate}
After some work I'm able to do this using `pre-post-order' and
`SRV:send-reply'. I wrote simple handlers for doing that.
However I want to perform some operations that I'm not sure of what is
the correct way to do that. For instance, I want to order the papers
by year (or some other criterion). I wander if the correct way is to
extract the papers as a list, sort them and build another tree as
follows,
(define papers
(cons 'papers
(sort
((sxpath '(paper)) data-base)
(lambda (p1 p2)
(> (paper-year p1) (paper-year p2))))))
(paper-year are simple functions that extract the
year from a paper, of course).
Then I can write the handlers for printing as before.
Another question is if I want to write the fields in other order, for
instance paper title first and authors second.
\begin{enumerate}
\item
``Name of Paper'', by Author1 N1., Author2 N2, Author3 N3.
\emph{The Journal} (2004)
\item
``Name of Paper2'', by Author21 N21., Author22 N22, Author23 N23.
\emph{The Journal2} (2003)
....
\end{enumerate}
I wander if I should transform the original tree in another tree as
before, changing the order of the fields and then print with
`pre-post-order' and `SRV:send-reply'.
Another, more general, question is if there are alternative libraries
for manipulating text databases, making queries and generating
reports.
Thank fo all input,
Mario
-------------------------
Mario Alberto Storti
Centro Internacional de Metodos Computacionales
en Ingenieria - CIMEC (INTEC/CONICET-UNL)
INTEC, Guemes 3450 - 3000 Santa Fe, Argentina
Tel/Fax: +54-342-4511594, cel: +54-342-156144983
e-mail: mstorti@intec.unl.edu.ar
http://www.cimec.org.ar/mstorti, http://www.cimec.org.ar
-------------------------
__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
Regístrate ya - http://correo.espanol.yahoo.com/
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-07-24 19:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-24 19:34 SXML tree operations Mario Storti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).