Skip to content
Back to formatted view

Raw Message

Message-ID: <m2psr2pke9.fsf@macaroni.local>
Date: 2005-09-21T14:26:06Z
From: Seth Falcon
Subject: SAX Parser best practise
In-Reply-To: <1F5B2A5E6712B94DA65EA9EBF0A1A38230E75F@EMAIL.mpimp-golm.mpg.de> (Jan Hummel's message of "Wed, 21 Sep 2005 08:43:41 +0200")

Hi Jan,

On 20 Sep 2005, Hummel at mpimp-golm.mpg.de wrote:
> I have a question regarding best practise in setting up a XML parser
> within R. [snip]
> value="445.598999"/> (as one can see in the xml snip set)

I missed the xml snip, but I think I get the gist of your question.

> I know the mechanism of using Event Handlers, as shown in the
> examples.  But what I'm looking for is, how can I use some "path
> information" as mentioned in "addContext" parameter of
> xmlEventParse()? May somebody share a example using "addContext =
> TRUE" and pointing me to the variables I may use if I implement the
> "..." parameter within my handlers.
>
> Do I have to implement a "status machine" using some variables
> within my handlers, or would one prefer to use the "state" parameter
> of xmlEventParse()?

I'm not familiar with the addContext arg and don't know whether or not
that provides another solution to your problem.

I do know that you can do what you want by writing "state machine"
code.  I played a little with using the state arg for this purpose,
but ran into some problems (sorry, no details in my memory banks).

There is an example of the state approach in Bioconductor's AnnBuilder
package.  See R/GO.R.  It isn't the prettiest or best example, but
maybe it will help get you going.

The general approach is to use '<<-' to reach up a level and set the
state variables from inside the tag handlers.

HTH,

+ seth