all groups > dotnet xml > march 2006 >
You're in the

dotnet xml

group:

Implementing XPathNavigator on my class



Implementing XPathNavigator on my class Vinayak Kamat
3/30/2006 8:55:26 AM
dotnet xml: Hi,

I've an 'Employee' class. In my program this object is manipulated,
children (List<T>) added, properties modified etc. Everytime this
happens I want to be able to show some relevent html to the user. So I
use XSLTransform. This Employee class is basically an XML serializable
class produced out of an XML file when the program loads for the first
time. Later on, if I've to show the modifications done to this object,
I don't want to go back to save this object into the file, then load it
to XMLdocument object and then use XSLTransform on it. This is tedious,
nasty and inefficient (as per MS experts).

So comes to the rescue - XPathNavigator. I am supposed to implement
this abstract class in my Employee class and provide implementations
for 20 odd properties and methods. So when I am ready with this
Xpathnavigable employee class, I just need to pass this to Xsltransform
and whoosh. I am done with the display.

I referred to the objectXpathnavigator on MSDN
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconxpathnavigatoroverdifferentstores.asp),
and FileSystemNavigator, AssemblyNavigator and RegistryNavigator by
Aaron over here.
(http://msdn.microsoft.com/msdnmag/issues/01/09/xml/)
While the former is buggy (Especially with XSLTransform) and unusable,
Aaron's navigators are complex and hard to follow/replicate. I even
downloaded them and tried to study them. They look complex.

I am looking for some real help in this regard to implement
XPathNavigator on top of my class. Is there a step by step guide on how
to achieve this in the most easiest and intuitive way. I am using
List<PrevEmployer> in my Employee class as well.
Isn't there a much better easier way of achieving this? in .Net 2.0?

Your help is much appreciated.

Thanks,

Vin
Re: Implementing XPathNavigator on my class Sergey Dubinet
3/30/2006 9:35:46 AM
Your intention is very correct and you are right that this is quite
complicated task.
We had some time ago reflection based XPathNavigator that was able to
iterate through arbitrary object tree.
I am not sure that it was ever published. If I find it I send it to you.

Sergey

[quoted text, click to view]

Re: Implementing XPathNavigator on my class Vin
3/30/2006 12:28:06 PM
@Martin:
you are very correct, I am in .Net 2.0 world, and for sure I am using
XslCompiledTransform. I meant it implicitely. I hate the old world
Xsltransform. No worries with that. And thanks for your pointers on
some samples.

@Sergey:
Thanks for your comments.
Please do send across your reflection based XPathNavigator, that is
exactly what I am looking for. I would appreciate for this helpful act
of yours.

Thanks very much,
Awaiting your navigator,
Vin
Re: Implementing XPathNavigator on my class Martin Honnen
3/30/2006 7:20:12 PM


[quoted text, click to view]

List<T> sounds like you are using .NET 2.0. With .NET 2.0 XslTransform
is obsolete and you should use XslCompiledTransform instead.

As for example XPathNavigator implementations, the XML MVP project has
at least one with Mvp.Xml.Common.XPath.SubtreeXPathNavigator, see the
documentation on
<http://www.xmlmvp.org/>


--

Martin Honnen --- MVP XML
AddThis Social Bookmark Button