2014-05-21 19:31 GMT+02:00 Paul Gearon <gea...@gmail.com>: > > I needed this myself and took a stab at it before it occurred to me to > look for other implementations and found yours. >
Hi Paul, good to hear you are interested in this effort. I like the way that you have split the implementation of functionality into > different namespaces. The current release is a little monolithic. > The patch I attached to DXML-4 [1] are just minimal changes to make roundtripping work. No refactoring. I've started to implement a much more advanced approach to namespaced xml in my repo [2], the design of which came from feedback on clojure-dev thread [3] and is documented in a new design page [4]. This approach will add another data tier (and make it the default), where tags and attribute names will be represented as QNames and xmlns attributes won't be present in :attrs One thing that bothers me is what's going on in clojure.data.xml.impl. I > haven't tried to go through all of it yet, but I didn't think that the code > needed to be that complex. > Good thing that you didn't bother consuming it all, impl currently has a lot of code, that will get deleted again. Basically all the stuff for automagically mixing raw and resolved data. The relevant parts for now are mostly XmlNamespace and the reader tag implementations. The way I handled prefix-uri mappings was to use a stack of maps, which I > thought was adequate. Your implementation of XmlNamespaceImpl has me > thinking that I've been missing something important. Could you explain why > XmlNamespaceImpl is structured the way it is? > Apart from basic bidirectional mapping functionality, XmlNamespaceImpl is built in such a way that: - Adding mappings is semantically equivalent to a child element declaring xmlns attributes - A new prefix for an already established mapping won't displace the current reverse mapping (uri->prefix), but get recorded as an alternative - Remapping a prefix to a new uri or deleting it, will establish an alternative prefix for that uri, in FIFO manner The aim is to strip out redundant xmlns attributes in the emitter, while retaining xml semantics. There is indeed something missing: Two XmlNamespaces must be diffable, to discover which xmlns attributes actually have to be emitted. I'm sure it could be built a lot simpler. It's currently basically a product of making its tests work [5]. It could probably be made to work with stacks of maps, but then each lookup would involve a linear search, no? -- What do you think of the proposed design? [1] http://dev.clojure.org/jira/browse/DXML-4 [2] https://github.com/bendlas/data.xml [3] https://groups.google.com/d/topic/clojure-dev/2ckb0NxJTlQ/discussion [4] http://dev.clojure.org/display/DXML/Namespaced+XML [5] https://github.com/bendlas/data.xml/blob/master/src/test/clojure/clojure/data/xml/test_namespace.clj kind regards -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.