From: John L. <joh...@gm...> - 2006-02-13 19:45:50
|
Ok, I've made a few improvements to my copy. Joao, would you mind trying this version and letting me know how you get on, please? Thanks in advance. ;) Some things to note with it, though: This is an updated NAnt.Core.dll, so delete the XmlExtensions one if that's what you're using. Also if you're using that version, the XmlPoke2 task is now part of XmlPoke. From that it gets the benefit of namespaces and all kinds of funkiness like that, and also will (hopefully) be merged into the trunk copy of NAnt. Summary of the changes, then. - There's now an XmlTaskContainer for the for-each task, which in turn inherits from TaskContainer. Other than that, it's just the same as XmlTask. (Again, because of this, this task should be able to understan= d namespaces). - All-round better error handling. xml::get-value() and xml::get-value-without-failing() don't return an error if the XPath poin= ts to a node, rather than a value. I think get-value should, but I'm still thinking about how it could make that decision. If you want to ensure i= t fails under this situation, and the value you want isn't an attribute, y= ou can put '/text()' in the xpath, like so: - <echo message=3D"${xml::get-value(/root/test/text())}"/> - Better error messages. There are still some issues. The way the functions seem to be reading the XML data is causing some strange formatting issues, which could be annoying if you want to read data in then write it out again, then edit or read the resulting file manually. And the functions don't support namespaces. I'm considering making changes to the expression evaluator so that it can support a namespace manager, and I was looking into the code for the evaluator today. Regards John On 13/02/06, John Ludlow <joh...@gm...> wrote: > > Hi Joao, > > Thanks for your feedback, and I'm glad you found it useful. I'll look > into the issues with the error messages (I think that in the code it shou= ld > have general catch handlers that throw a BuildException, since anything e= lse > results in a not-very-clear messag). > > Were the messages you got saying INTERNAL ERROR? > > John > > On 13/02/06, Joa...@ba... <Joa...@ba...= > > wrote: > > > > Hi, > > > > Just to give you notice of my experience with you xml tasks and > > functions. > > > > Overall, all went smoothly and most important, it solved my needs > > perfectly. There were only minor quirks with error conditions, or shoul= d I > > say error messages as they were not very clear. For example: > > > > - If the Xml-ForEach task doesn't find the source Xml it blows > > without giving a very informative message. > > - If the XPath query given to get-value-without-failing (and I > > assume the get-value) function resturns a node and not a value, the = function > > again fails without a clear message. > > > > Thanks again for your effort! It was (is) most useful. > > > > Jo=E3o > > > > ------------------------------ > > *From:* John Ludlow [mailto:joh...@gm...] > > *Sent:* s=E1bado, 28 de Janeiro de 2006 16:43 > > *To:* Jo=E3o Hugo Miranda (DNC) > > *Subject:* Re: [nant-dev] New XML tasks and functions > > > > > > > > On 28/01/06, Joa...@ba... <Joao.hugo.miranda@bancobpi.= pt > > > wrote: > > > > > > Well, what can I say but thank you? I never cease to be amazed by how > > > some people can be so incredibly helpful. I'll give it a try as soon = as I > > > can and keep you posted. > > > > > > > Well, that's the nature of a community project like this. My life has > > been made so much easier by, shall we say "the kindness of strangers", = and > > it's nice to give something back. It also means that future updates mi= ght > > be easier for me if this becomes widely adopted and integrated into the= NAnt > > release at some point. > > > > Thanks again! > > > Jo=E3o (Curious... Jo=E3o means John in portuguese :) ) > > > > > > > Aha! I wondered if it meant something like that. I know Juan is > > Spanish for John. Nice to meet a fellow John out there! ;) > > > > ------------------------------ > > > *From:* John Ludlow [mailto:joh...@gm...] > > > *Sent:* s=E1bado, 28 de Janeiro de 2006 16:19 > > > *To:* Jo=E3o Hugo Miranda (DNC) > > > *Subject:* Fwd: [nant-dev] New XML tasks and functions > > > > > > Hi, > > > > > > Just remembered I'd sent it to someone else, so I'll just forward you > > > the same email (probably easier than you waiting for me to get into w= ork on > > > Monday). > > > > > > Attached to this email should be a zip with the source code and > > > binaries in. Copy the assembly into the NAnt\bin folder. Alternativ= ely, I > > > have also attached a build file which you can <include> into your bui= ld > > > (though I've noticed that the <xml-foreach> task in that one is a lit= tle > > > behind the assembly version, in that it doesn't support the index > > > attribute). I've submitted a patch to Ian MacLean that provides thes= e > > > functions and an updated <xmlpoke> task, so you might see these featu= res in > > > a future version of NAnt. > > > > > > One thing I think the other guy found confusing (so I might change it= ) > > > is that by default the <get> elements don't return an error if they c= ouldn't > > > find the node. I figured you could do a property::exists() call. It= 's a > > > trivial change, though, and in the meantime you can always set the > > > failonerror attribute for <get> to true. > > > > > > Anyway, let me know how it goes. Glad I could help ;) > > > > > > John > > > > > > > > |