test_namespace.clj just contains some unit tests for now. The final patch will have usage examples.
With the proposal, you can define your xml namespaces on a clojure-namespace level and refer them via keyword namespaces: (ns thing) (xml-default-prefix *ns* "thing") (xml-prefix *ns* "thing" "http://thing") (def e4 (xml/sexp-as-element [::first {} [::second {}]])) This improves on handling raw xml-prefixes in two ways: - The full xml namespace "http://thing" is known for an xml name like ::first, ::second, not just the prefix you happened to assign in code. - You can combine xml fragments from different parts of code, without worrying about prefix assignment. The emitter takes care of assigning xmlns declarations. cheers 2014-05-10 0:22 GMT+02:00 Timothy Washington <twash...@gmail.com>: > Thanks Herwig. I take it > test_namespace.clj<https://github.com/bendlas/data.xml/blob/master/src/test/clojure/clojure/data/xml/test_namespace.clj>is > the interesting file. Given the example in my previous message, is there > a more idiomatic way of defining namespaces with this proposal? > > > Thanks again > > Tim Washington > Interruptsoftware.com <http://interruptsoftware.com> > > > > On Thu, May 8, 2014 at 10:54 AM, Herwig Hochleitner < > hhochleit...@gmail.com> wrote: > >> Hi, >> >> I'm the guy working on the newer proposal, which is almost done (TM). It >> seems you have found the way to emulate namespacing with the current >> data.xml impl: by taking care of xmlns attributes and prefixes yourself. I >> definitely want to keep compatibility with that representation. Feel free >> to check out my proposal branch here https://github.com/bendlas/data.xml >> >> cheers >> >> >> 2014-05-06 21:53 GMT+02:00 Timothy Washington <twash...@gmail.com>: >> >>> Ok, scratch that. I got it working, lol :) >>> >>> Sorry for the false alarm. For future reference, this: >>> >>> (def e4 (xml/sexp-as-element >>> [:thing:first {:xmlns:thing "http://thing"} >>> [:thing:second {}]])) >>> >>> >>> ...gives you this: >>> >>> user> (process/print-esequel process/e4) >>> >>> <?xml version="1.0" encoding="UTF-8"?> >>> <thing:first xmlns:thing="http://thing"> >>> <thing:second/> >>> </thing:first> >>> >>> >>> >>> Tim Washington >>> Interruptsoftware.com <http://interruptsoftware.com> >>> >>> >>> On Tue, May 6, 2014 at 3:45 PM, Timothy Washington >>> <twash...@gmail.com>wrote: >>> >>>> Got a bit further here. I want to be able to get tag namespaces without >>>> a :root tag (that includes the namespace definition). Assume the below code >>>> has (require '[clojure.data.xml :as xml]). >>>> >>>> >>>> Working with attributes is fine. >>>> >>>> (def e1 (xml/element :use {:xmlns:xlink "http://testing", >>>> :xlink:href "#whiskers", >>>> :transform "scale(-1 1) translate(-140 0)"})) >>>> >>>> >>>> Namespace prefixes is possible with tags; however, I had to add the >>>> unwanted :root tag (that includes ns definition) >>>> >>>> (def e2 (xml/element :root {:xmlns:thing "http://thing"} >>>> (xml/element :thing:use {}))) >>>> >>>> (def e3 (xml/element :root {:xmlns:thing "http://thing"} >>>> (xml/sexp-as-element >>>> [:thing:first {} >>>> [:thing:second {}]]))) >>>> >>>> (defn print-esequel [elem] >>>> (println (xml/indent-str elem))) >>>> >>>> >>>> >>>> The resulting XML is close. But we want the tag namespaces, without the >>>> root node >>>> >>>> user> (print-esequel process/e2) >>>> >>>> <?xml version="1.0" encoding="UTF-8"?> >>>> <root xmlns:thing="http://thing"> >>>> <thing:use/> >>>> </root> >>>> >>>> user> (print-esequel process/e3) >>>> >>>> <?xml version="1.0" encoding="UTF-8"?> >>>> <root xmlns:thing="http://thing"> >>>> <thing:first> >>>> <thing:second/> >>>> </thing:first> >>>> </root> >>>> >>>> >>>> >>>> Tim Washington >>>> Interruptsoftware.com <http://interruptsoftware.com> >>>> >>>> >>>> On Tue, May 6, 2014 at 3:24 PM, Timothy Washington >>>> <twash...@gmail.com>wrote: >>>> >>>>> Hi there, >>>>> >>>>> >>>>> *A)* I'm just writing some SOAP XML, trying to use >>>>> data.xml<https://github.com/clojure/data.xml>. >>>>> This SO >>>>> thread<http://stackoverflow.com/questions/10868050/clojure-data-xml-create-key-named-xlinkhref> >>>>> outlines >>>>> how to write out namespace aware XML. But the example is for a namespace >>>>> on >>>>> an attribute. I'm combing through the code now, but does anyone know how >>>>> to >>>>> set this up? >>>>> >>>>> >>>>> *B)* There's actually this Fuller XML >>>>> Support<http://dev.clojure.org/display/DXML/Fuller+XML+support>proposal >>>>> (referring to this >>>>> thread<https://groups.google.com/forum/#!msg/clojure-dev/3_jkBrdQKgs/dUwtevWqlwkJ>), >>>>> and this Namespaced >>>>> XML<http://dev.clojure.org/display/DXML/Namespaced+XML>proposal. But I >>>>> don't see that namespaces are fully implemented in any of >>>>> the core libs. >>>>> >>>>> I only see this ArmageDOM <https://github.com/pepijndevos/ArmageDOM>lib, >>>>> which supports namespaces. Anything else out there that I've missed? >>>>> >>>>> >>>>> Thanks >>>>> >>>>> Tim Washington >>>>> Interruptsoftware.com <http://interruptsoftware.com> >>>>> >>>>> -- > 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. > -- 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.