
I am (at last!) looking to implement an XML namespace processing filter for HaXml, having completed the various structural changes needed to carry namespace information in the content model. The basic idea is to process a document such that: (a) all xmlns:xx='xxuri' attributes are removed (b) all attribute and element names of the form xx:foo are replaced by a URI xxuri and local name foo, corresponding to a currently in-scope namespace declaration. This raises some questions, which may simply be that I'm overlooking some obvious way of using the CFilter combinator library: (1) is there a combinator for updating attributes, in a fashion similar to the way 'chip' updates elements? (I wrote my own "atip" for general entity substitution in attributes, but it seems that there should be a way to do this in the library.) (2) it appears that I need the XML processing filter to carry a symbol table of in-scope namespaces, which will be updated through the traversal as new xmlnx:xx declarations come into scope. I cannot see any way to do this with the existing combinators; I think this would need a form of recursive combinator, along the lines of 'foldXml' that uses a newly computed CFilter function for each successive recursion. I imagine something like: mangleXml f mkf c = (f' `o` (chip (mangleXml f` mkf))) c where f' = mkf f c (where I would use mkf to scan the attributes and create an augmented version of f that takes into account new xmlns declarations, and f would be a function that replaces names with qnames on an element and its attributes.) Am I missing a trick with the existing combinators? ... (An alternative approach I considered was to use a monadic form of CFilter function which could carry and update the namespace table as the traversal progresses, but that appears to require that (a) many of the existing combinators would have be re-written, and (b) it doesn't cleanly deal with issues of scoping xmlns declarations.) ... #g ------------ Graham Klyne For email: http://www.ninebynine.org/#Contact