[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SXML tree operations

From: Mario Storti
Subject: SXML tree operations
Date: Sun, 24 Jul 2005 14:34:43 -0500 (CDT)

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
      (code "paper1")
       (a "Author1 N1.")
       (a "Author2 N2.")
       (a "Author3 N3."))
      (title "Name of paper")
      (journal "The Journal")
      (year 2004))

      (code "paper2")
       (a "Author21 N21.")
       (a "Author22 N22.")
       (a "Author23 N23."))
      (title "Name of paper2")
      (journal "The Journal2")
      (year 2003))


And I want an output like

  \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)


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

(define papers 
  (cons 'papers
         ((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. 

    ``Name of Paper'', by Author1 N1., Author2 N2, Author3 N3. 
     \emph{The Journal} (2004)

    ``Name of Paper2'', by Author21 N21., Author22 N22, Author23 N23. 
    \emph{The Journal2} (2003)


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

Thank fo all input,


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: address@hidden,

Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¬°gratis! 
Regístrate ya - 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]