From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,deac256a05c84a59 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Nick Roberts Newsgroups: comp.lang.ada Subject: Re: DOM and SAX parsing in Ada Date: Tue, 25 Jan 2005 15:29:40 +0000 Message-ID: References: <41900010.D28DD400@boeing.com><9CWjd.17305$5K2.1356@attbi_s03> <1106223415.857525.176640@c13g2000cwb.googlegroups.com> <41F4DB6F.4090909@mailinator.com> Content-Type: text/plain; charset=us-ascii X-Trace: individual.net vFVUdRLCcU99Bj6czQfK7Q6sl9Mu9DPa4p4Ml4U/956ULY5/0= X-Orig-Path: not-for-mail User-Agent: Gemini/1.45d (Qt/3.3.2) (Windows-XP) Xref: g2news1.google.com comp.lang.ada:7975 Date: 2005-01-25T15:29:40+00:00 List-Id: "Alex R. Mosteo" wrote: > Nick Roberts wrote: > > > Would anyone be interested in an Ada package that parsed XML (including > > DTDs and entities, with namespace support), but which was written with > > an interface that is (hopefully) better suited to Ada than DOM or SAX? > > I for one am interested. What kind of Ada-ish interface have you in mind? It is really quite similar to DOM, but simplified and made more Ada-ish. Most of the exported types are token types, whose values are references to the object itself. Tokens are easily copied and passed around, and are naturally implemented (privately) as access values. So, for example, a document in memory is represented by the Document_Ref type, and elements within a document by the Element_Ref type, and so on. There is a Read procedure to read an XML document into memory (which can read and use a DTD, performing full validation), and a Write procedure to write out a document in memory (as a standalone XML document). I have provided a full set of operations for querying a document in memory, and a redcued set of operations which allow the construction (or extension) of a document's structure (but not modification-in-place, reorganisation, or deletion). I reckon this simplifies the interface (and the iplementation) tremendously without much loss of usefulness, since the typical idiom of an XML processing program written in Ada will be to traverse through one structure, generating another structure as it goes. I've not included anything like XPath; I don't think it would be appropriate at the level of Ada programming. It would be easy enough to write a procedure that iterated another procedure (as an access parameter) for each node matching certain criteria. I am including a convenience procedure to copy a node from one document to another. More later. -- Nick Roberts