At 08:52 AM 2/19/03 -0800, Joe English wrote:
Graham Klyne wrote:
Which leads me to a question: starting from the haskell.org web page, I have identified three XML parsers in Haskell (HaXml, hXML, Haskell XML Toolbox), none of which seem to support XML namespaces and only one of which claims to be tested on both HUGS and GHC.
Can anyone offer any recommendations, or maybe pointers to other work?
What are you looking for in an XML toolkit?
Hi, thanks for responding. My desiderata: 1. Works with HUGS and GHC (I'm currently developing with HUGS, but anticipate using GHC for "production" code). 2. Namespaces, though I'm prepared to roll-my-own on top of an existing XML parser. 3. Well-formedness checking would be nice; i.e return a useful error indication if tags are mismatched, that sort of thing. 4. Validation is not required for my application.
As far as HXML goes, I have a rough sketch of an implementation of XML namespace support, not yet finished or released. (This is a somewhat thorny problem; implementing XMLNS is not hard, but implementing it in a sane way requires some ingenuity.)
I was looking at HXML yesterday, and it has the great advantage that I feel I can understand it well enough to tinker. And the code looks clean to my Haskell-inexperienced eye. The main drawback is the lack of well-formedness checking, but think I could live with that, at least for prototyping purposes. I think your presentation of an XML parse as a tree of XMLNodes closely matches what I want to do. Would it make sense to add a new node constructor indicating a syntax error? I also thought briefly about adding namespace support, and contemplated replacing your type Name = String -- from memory, maybe not exactly right? with something like data Name = QName String String where the two strings would be namespace URI and local name respectively. I haven't yet figured what the cascading effects of such a change might be. Better, maybe, I define a new XMLnode type that uses QName instead of Name, and write a function to translate a (Tree XMLNode) to a (Tree XMLQNode)? That keeps things cleanly separated. BTW, do you have a test suite for your parser? (I've found the HUnit library to be very useful, and easily transferred my previous experience with JUnit.) #g _______________________________________________
Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
------------------- Graham Klyne <GK@NineByNine.org>