[antlr-interest] Experiences going to XML DOM from AST...

Sam Barnett-Cormack s.barnett-cormack at lancaster.ac.uk
Mon Jun 22 05:22:24 PDT 2009


Sylvain, Gregory [USA] wrote:
> Hi,
> 
> I have a system which currently translates several legacy message 
> formats into XML DOM (does some manipulation and verification) and then 
> translates the XML DOM back to the legacy message format.  It currently 
> does all of the legacy translation by hand.   Accordingly, there are 
> some 'gaps', as well as hard to find bugs, in the translation.
> 
> I am looking to replace the hand translation with ANTLR.   However, I 
> would like to keep the XML DOM middle representation as there is already 
> quite a few architectural features built around that model.
> 
> Does anyone have experience translating from ANTLR AST to XML DOM?  I 
> have a bit of trouble trying to grasp how the tree grammar would/could 
> output XML DOM.

An immediate idea occuring to me would be to use yet another layer in 
between - but it's a pretty easy layer. Assuming you're using Java, 
create a data binding of your XML, using (for example) JAXB. Then have 
the tree grammar build these Java objects, and then use JAXB's internal 
capability to turn them into DOM.

Sometimes an extra step saves time.

-- 
Sam Barnett-Cormack


More information about the antlr-interest mailing list