Re: [nant-dev] XML Line Numbers

2002-06-04 Thread Ian MacLean



Gerry Shaw wrote:

It does seem like a pretty good solution but what we have does work and
has been tested and isn't causing any problems that I know of.  Its also
a lot fewer files.

Still it's a pretty good sample and I'll likely use it in other
projects.

Thanks

  

A sample just (a few days ago) got released on gotdotnet that 
tracks line numbers for a DOM object. It extends the DOM 
objects, and tracks the information internally. I think this 
would be a good way of doing it, instead of the current way. 
Any comments?

Example showing how to extend the System.Xml DOM classes. 
The derived classes implement the IXmlLineInfo interface 
which allows users to return line information on the XML 
documents. - http://www.gotdotnet.com/userfiles/XMLDom/extendDOM.zip




In fact the XPathNvavigator already inplements the IXmlLineInfo 
interface so you don't need to write your own derived classes. However I 
agree with Gerry that what we have works now o theres no need to change 
it. Besides that was my first contribution to Nant :)

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



RE: [nant-dev] XML Line Numbers

2002-06-04 Thread Scott Hernandez

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()

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.
 
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]. 

[1]
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/h
tml/frlrfSystemXmlIXmlLineInfoClassTopic.asp

 -Original Message-
 From: Ian MacLean [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, June 04, 2002 12:24 PM
 To: Gerry Shaw
 Cc: 'Scott Hernandez'; 'NantDev'
 Subject: Re: [nant-dev] XML Line Numbers
 
 
 
 Gerry Shaw wrote:
 
 It does seem like a pretty good solution but what we have does work
and
 has been tested and isn't causing any problems that I know of.  Its
also
 a lot fewer files.
 
 Still it's a pretty good sample and I'll likely use it in other
 projects.
 
 Thanks
 
 
 
 A sample just (a few days ago) got released on gotdotnet that
 tracks line numbers for a DOM object. It extends the DOM
 objects, and tracks the information internally. I think this
 would be a good way of doing it, instead of the current way.
 Any comments?
 
 Example showing how to extend the System.Xml DOM classes.
 The derived classes implement the IXmlLineInfo interface
 which allows users to return line information on the XML
 documents. -
http://www.gotdotnet.com/userfiles/XMLDom/extendDOM.zip
 
 
 
 
 In fact the XPathNvavigator already inplements the IXmlLineInfo
 interface so you don't need to write your own derived classes. However
I
 agree with Gerry that what we have works now o theres no need to
change
 it. Besides that was my first contribution to Nant :)
 
 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



Re: [nant-dev] XML Line Numbers

2002-06-04 Thread Ian MacLean



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;
IXmlLineInfolineInfo = 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



Re: [nant-dev] XML Line Numbers

2002-06-04 Thread Ian MacLean

Scott wrote

 
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]. 

[1]
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/h
tml/frlrfSystemXmlIXmlLineInfoClassTopic.asp
  

Ok in the previous example I sent what you actually get is an 
XPathDocumentNavigator which does implement IXmlLineInfo. This class is 
private to System.Xml.dll but you can see it using anakrino
http://www.saurik.com/net/exemplar/

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



RE: [nant-dev] XML Line Numbers

2002-06-04 Thread Scott Hernandez

My concern about the lines numbers was less about their need (or
accuracy), and more about the fact that the LocationMap generated errors
when the document is not file-backed. If we go with the DOM Extensions
then we can check for the IXmlLineInfo interface before we output the
info.

For now, I'll commit my changes with the altered LocationMap that check
for this case.

 -Original Message-
 From: Ian MacLean
 Subject: Re: [nant-dev] XML Line Numbers
 Scott Hernandez wrote:
 
 We need to do something. This code fails because there is no file
 associated with the document.
[snip]

 
 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.

Nope, I was thinking that we might want to output some of the
surrounding xml for context tho.


[snip]



___

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



Re: [nant-dev] XML Line Numbers

2002-06-04 Thread Ian MacLean



Scott Hernandez wrote:

My concern about the lines numbers was less about their need (or
accuracy), and more about the fact that the LocationMap generated errors
when the document is not file-backed. If we go with the DOM Extensions
then we can check for the IXmlLineInfo interface before we output the
info.

For now, I'll commit my changes with the altered LocationMap that check
for this case.

I think thats probably enough.  I think DOM Extensions is overkill 
considering that a non-file backed build document is really a boundary 
case. In what normal user pattern would you use a build document that 
does not come from a file ? NUnit test cases don't count as user patterns.

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



RE: [nant-dev] XML Line Numbers

2002-06-04 Thread Scott Hernandez

The VS.Net/OtherIDE add-ins :)

But I finish that up after the release.

 -Original Message-
 From: [EMAIL PROTECTED]
[mailto:nant-developers-
 [EMAIL PROTECTED]] On Behalf Of Ian MacLean
 Sent: Tuesday, June 04, 2002 3:34 PM
 To: Scott Hernandez
 Cc: 'NantDev'
 Subject: Re: [nant-dev] XML Line Numbers
 
 
 
 Scott Hernandez wrote:
 
 My concern about the lines numbers was less about their need (or
 accuracy), and more about the fact that the LocationMap generated
errors
 when the document is not file-backed. If we go with the DOM
Extensions
 then we can check for the IXmlLineInfo interface before we output the
 info.
 
 For now, I'll commit my changes with the altered LocationMap that
check
 for this case.
 
 I think thats probably enough.  I think DOM Extensions is overkill
 considering that a non-file backed build document is really a boundary
 case. In what normal user pattern would you use a build document that
 does not come from a file ? NUnit test cases don't count as user
patterns.
 
 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



___

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