Scott Hernandez wrote:
>We need to do something. This code fails because there is no file
>associated with the document.
>
> XmlDocument doc = new XmlDocument();
> XmlElement project = doc.CreateElement("project");
> XmlElement echo = doc.CreateElement("echo");
> echo.SetAttribute("message","Go Away!");
> project.AppendChild(echo);
> doc.AppendChild(project);
>
> Project p = new Project(doc);
> p.Run()
>
>
>
well this will never work properly as far as I can see. If you're
loading a dom dynamically then you can't generate line numbers and in
fact they are of little use if there is no file to map them to. that
said we shouldn't generate errors in this case - just produce no line
information.
>In my test env I've hacked the LocationMap so this doesn't generate
>errors, er... at least so it runs. But having a LocationMap is a little
>intrusive, IMHO.
>
>Currently it means that we need to re-read the file to generate the
>location.
>
well that makes sense. If theres no file to start with then the line
number could be anything depending on how you decide to format it. ie
the whole document could be on one line.
>
>My docs don't list XPathNavigator as implementing the IXmlLineInfo
>interface. The object browser doesn't seem to show it either. Nor does
>the IXmlLineInfo overview list any classes other than "XmlTextReader,
>XmlValidatingReader" as implementers[1].
>
>
Docs or no docs the following code works a treat :
string strInput = @"d:\dev\foo.xml";
XPathDocument doc = new XPathDocument(strInput);
XPathNavigator nav = doc.CreateNavigator();
int lineNumber = 0;
int inpputlineNumber = 0;
IXmlLineInfo lineInfo = nav as IXmlLineInfo;
lineNumber = lineInfo.LineNumber;
Ian
_______________________________________________________________
Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm
_______________________________________________
Nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers