Hi all,
This is a reminder of some of the things we should remember when working
with xml data in .net and specifically nant code.
We need to use the namespace manager for all xpath expressions; use our
"nant" prefix for all elements in xpath expressions.
This is used in the following cases:
XmlNode.SelectNodes("nant://elementname", Project.NamespaceManager)
XmlNode.SelectSingleNode("nant://myelement[attribute='value']"Project.Namesp
aceManager)
It is also appropriate to check the namespace of the element when
iteratoring through elements without an xpath expression. Like in this case:
foreach (xmlnode node in nodes) {
//skip non-nant namespace elements and special elements like comments,
pis, text, etc.
if (node.Name.StartsWith("#") ||
!node.NamespaceURI.Equals(doc.DocumentElement.NamespaceURI)) {
continue;
}
}
(we can probably use a better (more efficient) test than
node.Name.StartsWith("#"), like node.NodeType == XmlNodeType.Element)
The reason this is important is because the following docs are different and
the later will cause problems with none-namespace specifies xpath queries.
<project name="foo">
<target name="1"/>
</project>
<nant:project name="fooya" xmlns:nant=http://nant.sf.net/schema/nant.xsd
xmlns="http://nant.sf.net/schema/nant.xsd">
<nant:target name="1"/>
<target name="2"/>
</nant:project>
<project name="fooya" xmlns="http://nant.sf.net/schema/nant.xsd">
<target name="1"/>
</project>
This is not an nant problem, but an issue with the framework xpath and xml
classes. It isn't a problem, but just the way the spec reads.
I've climbed through the code to make these fixes, and am currently testing,
but will checkin stuff soon.
Test Note:
I've also added some tests for many types of different build files. I have
creates a dir in Core.Tests for build files that should be tested. Each file
is embedded in the assembly and tested against nant for validity. Please
feel free to add more files as cases come up. It is also an easy place to
put static build files to test.
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers