I'm making a 6-tiered application that is using Xml to tie the various
layers together in a very clean manner. I'm also trying to do this on the
1.1 Framework although I'm willing to switch to the 1.0 Framework if need
be.
One layer, which I call a Data Persistence Layer, uses the
System.Xml.Serialization.XmlSerializer to transform our business/domain
objects into the appropriate Xml format.
The layer below that is what I call a Data Transformation/Translation Layer.
This layer converts the Xml from the Persistence layer into the appropriate
format for storage (Sql server, file system, e-mails, web services, etc.)
The key to our architecture is being able to move between layers as quickly
and as efficiently as possible. Although serialization is an expensive
operation, we have determined that these performance costs are acceptable
given appropriate caching mechanisms of the XmlSerializer objects.
The issue I'm encountering is with the .NET API. It seems that the
XmlSerializer wants to work on streams while the XslTranform wants to work
with XPathNavigator/IXPathNavigatable.
So my question is: what is the best way to represent my Xml when I pass it
between layers. Based on an episode of MSDN TV, I tried to pass everything
around as an XPathNavigator as it seemed that this would provide an
efficient yet robust API for Xml access. The problem is that I couldn't
figure out a way to get the XmlSerializer to work with this since it demands
the use of an XmlReader, TextReader, or System.IO.Stream. Try as I might, I
couldn't figure out how to get an XmlReader from an XPathNavigator without
resorting to the costly operation of creating a new document in memory.
Of course, if I use the 1.0 Framework then the XslTransform object will
accept an XPathNavigator, however in the 1.1 Framework this is deprecated.
Thus, I assume that there is a preferred method for being able to use the
XslTranform on data generated by the XmlSerializer.
Right now I've gotten rough prototypes working using a string (I know, I
know, awful!) and another using XmlNode to pass data between layers. The
XmlNode is little more prone to throwing exceptions than I'd like, however.
Anyone know what the magic data type I should use is? Any samples you can
point me to would be most appreciated.
There just has to be a way to get the XmlSerializer and the XslTransform to
use each others output without having to resort to really costly operations
like cloning documents or resorting to the file system.
Much thanks for all of your help in advance.
Kevin Conroy
Programmer/Analyst