Hi, Martin

On 30/01/06, Martin Aliger <[EMAIL PROTECTED]> wrote:
Hello,

I like it very much. Expecially functions. Bad luck I personally need
namespace support, since mine xmls have some namespace in it. And even
default namespace needs specification in xpaths :-(

I don't know that much about namespaces.  Perhaps we could find a way to pass an XMLNamespaceCollection.  I'd have to figure out how namespaces change what the function needs to do.  I'd also have to figure out a way to do that without causing non-namespaced people to have to think about namespaces.  Probably a separate function, since NAnt functions can't be overloaded as far as I can see.  xml::get-value-using-ns(string xmlFile, string xPath, string ns) or something, maybe?

btw: does nant functions support overloading and/or default parameter value?
                bool xml::value-exists (string xmlFile, string xPath,
NamespaceMap nsMap = null)

No, I wish it did.  (That way, the get-value-without-failing function could be overloaded as get-value (string, string, bool), with the bool indicating whether or not to fail on an error) .

===

Here is typical use of namespace map (taken from my real script):

                                <xmlpeek
                                        file="${prjconfig}"
                                        xpath="x:Project/x:ExeName"
                                        property="newexe"
                                        failonerror="true"
                                        failonnonode="false"
                        >
                                                <namespaces>

                                                        <namespace
prefix="x" uri="http://www.gordic.cz/shared/project-config/v_1.0.0.0 "/>
                                                </namespaces>

                        </xmlpeek>


And sample xml file is here (changed to protect innocent):

<?xml version=" 1.0" encoding="utf-8"?>
<Project xmlns="http://www.gordic.cz/shared/project-config/v_1.0.0.0">
  <Name>foo</Name>
  <Description>foobar</Description>
  <ExeName>footest</ExeName>
</Project>

Cool, that'll help. I'll take a look at the xmlpeek source to see if I can work out how it handles namespaces differently and shamelessly plagiarise - ahem, I mean adapt ;) - that into the function.

===

I missed xml-foreach once too, but nowadays I do not need it. Still it could
be worth addition to NAnt(Contrib) tasks!

I got round it with a c# <script> task.  I'd like to revamp that into an <xml-foreach> call (since I think embedded c# scripts should be avoided if possible).  That's why I started this whole thing, in a way.  But I agree - I think it could be a worthy addition as well :)

Reply via email to