Building Custom XmlResolvers Article on MSDN XML Developer Center


In between re-writing and updating the chapters for the beta version of the my book A First Look at ADO.NET and System.Xml V2.0, I found some time to write an article on Building Custom XmlResolvers for MSDN. What's so great about this class is that it enables you to redirect the location of the XML that you want to load, as well as allowing you to define your own schemes, if necessary (e.g. db:// to load from a database). There are all sorts of great things that you can do with an XmlResolver and you can come up with some fairly intelligent caching solutions if your applications needs this. One aspect that I did not cover in this article is the use of the credentials property of the XmlResolver which there is a good KB article about here

As this went to press I was talking to a PM on the Frontpage team who complained that one problem they were having is that they did multiple round trips to a SQL Server data base in order to load <xsl:include> stylesheets i.e. one trip per include and this was obviously having a impact on stylesheet compile time in some scenarios. No problem I said, simply write your own XmlResolver that batches up all the <xsl:include> requests into a single batch call to the database and caches them in-memory. You will need to parse the <xsl:include>s in advance is order to know which stylesheets to load, but a quick read with an XmlTextReader on the XSLT stylesheet can tell you the list, which you can then give to the XmlResolver.

It would be good to hear of any uses that you have for custom XmlResolvers in your applications.

Comments (6)

  1. So that means it’s gonna be second edition of your book? When?

  2. Now that it’s not so far away from Beta2, I’ll get the book 😉 … hopefully, there won’t be many changes from there on…

    I’ve used a custom EmbeddedResourceResolver where I use mem:// to pull XML from embedded resources (obviously). Resolvers are way cool 🙂

  3. Mark Fussell: In between re-writing and updating the chapters for the beta version of the my book A First Look at ADO.NET and System.Xml V2.0, I found some time to write an article on Building Custom XmlResolvers for MSDN. It’s really good artilce, highly recommended reading for those who still…

  4. I was very interested to see this article, using a schema embedded as a resource in an assembly is something I’ve been wanting to do for quite a while. However I must say I was a bit disappointed to see that the provided code only works for .NET Framework 2.0. Is there any chance that you can provide code for .NET Framework 1.1 as well?

Skip to main content