After reading Pierre Mais's postings
http://www.pmsf.de/resources/lisp/expat.html
I have written a basic C wrapper for libmxl2, which parses an XML
document, and prints a list containing the parsed data. At the moment,
I save the printed sexp to a file, and READ it from Lisp. I am thinking
it may be better to avoid the intermediate printing and READing, and
instead save the parsed data to a C struct; I can then try to use Lisp
to get the sexp from the C struct, using an FFI. What is a good way to
store a sexp in C? Is it common practice to pass through an
intermediate file like I am doing now?
TIA,
Raghavendra.
PS: In case it's relevant, the C wrapper takes an XML document like this
--8<---------------cut here---------------start------------->8---
<?xml version="1.0" encoding="utf-8"?>
<?draft omit="author"?>
<doc xmlns="urn:example:ns:doc"
xmlns:kw="urn:example:ns:keyword"
xmlns:xi="http://www.w3.org/2001/XInclude"
id="sexp" lang="en-GB">
<?latex class="article" fontsize="12pt"?>
<docinfo>
<author>
<firstname>Schöne</firstname>
<surname>Grüße</surname>
</author>
<title>An Example Article</title>
<titleabbrev role="running-title">Example art</titleabbrev>
<keywordset>
<keyword kw:type="ai">an articleinfo keyword</keyword>
<keyword kw:type="ai">another articleinfo keyword</keyword>
</keywordset>
</docinfo>
<xi:include href="urn:publicid:-:EXAMPLE:DOCUMENT+Section:EN"/>
</doc>
--8<---------------cut here---------------end--------------->8---
and prints a sexp, which when READ by CLISP looks like this
--8<---------------cut here---------------start------------->8---
((DRAFT (PROCESSING-INSTRUCTION "omit=\"author\""))
(DOC (XML-NAMESPACE "urn:example:ns:doc") (ID "sexp") (LANG "en-GB")
(LATEX (PROCESSING-INSTRUCTION "class=\"article\" fontsize=\"12pt\""))
(DOCINFO (XML-NAMESPACE "urn:example:ns:doc")
(AUTHOR (XML-NAMESPACE "urn:example:ns:doc")
(FIRSTNAME (XML-NAMESPACE "urn:example:ns:doc") "Schöne")
(SURNAME (XML-NAMESPACE "urn:example:ns:doc") "Grüße"))
(TITLE (XML-NAMESPACE "urn:example:ns:doc") "An Example Article")
(TITLEABBREV (XML-NAMESPACE "urn:example:ns:doc") (ROLE "running-title")
"Example art")
(KEYWORDSET (XML-NAMESPACE "urn:example:ns:doc")
(KEYWORD (XML-NAMESPACE "urn:example:ns:doc")
(TYPE (XML-NAMESPACE "urn:example:ns:keyword") "ai")
"an articleinfo keyword")
(KEYWORD (XML-NAMESPACE "urn:example:ns:doc")
(TYPE (XML-NAMESPACE "urn:example:ns:keyword") "ai")
"another articleinfo keyword")))
(SECTION
(SECTIONINFO
(KEYWORDSET
(KEYWORD (TYPE (XML-NAMESPACE "urn:example:ns:keyword") "si")
"a sectioninfo keyword")))
(TITLE "A Section")
(PARA
"This is a paragraph in a section. It does not quote any one,
so we don't need any `\"' characters.")
(PARA "The canonical URI for this document is "
(ULINK (URL "http://www.example.org/sexp"))
". Please check there for the
latest updates. Meanwhile, here is Äñ example of
character entity references."))))
--8<---------------cut here---------------end--------------->8---
--
N. Raghavendra <ra...@mri.ernet.in> | http://www.retrotexts.net/
Harish-Chandra Research Institute | http://www.mri.ernet.in/
See message headers for contact and OpenPGP information.