Mvp.Xml Project: XPointer.NET module

The XPointer.NET module provides an implementation of the XPointer Framework Recommendation written in C# for the .NET platform. XPointer.NET supports XPointer element() Scheme, XPointer xmlns() Scheme, XPointer xpath1() Scheme and XPointer xpointer() Scheme (XPath subset only). XPointer.NET was designed and implemented for the XInclude.NET module, but it can be used on its own.

Requirements

XInclude.NET module as well as a whole Mvp.Xml library is .NET Framework application and requires .NET Framework version 1.X or 2.0 to be installed.

Download

Go to the Downloads page. XPointer.NET module is a part of the Mvp.Xml library release.

Installation and Documentation

Find precompiled Mvp.Xml.dll  assembly in the "bin" directiory. The "src" directory contains XPointer.NET sources in Visual Studio .NET 2003 (XPointer/src/v1) and Visual Studio 2005 (XPointer/src/v2) solution form. The documentation can be found in the "doc" directory (online version). Samples and test cases can be found in the "test" directory.
In addition to the API documentation, refer to the "Combining XML Documents with XInclude" article at the MSDN, which introduces XPointer itself and provides details on usage and implementation of the XPointer.NET module. Additionally doen't forget the normative specs:

History

Done in 2.0 release:
Done since 1.2 release:

Usage

XPointerReader class, found in the Mvp.Xml.XPointer namespace, is the key class. It's customized  XmlReader, which implements XPointer Framework, XPointer element() Scheme, XPointer xmlns() Scheme, The XPointer xpath1() Scheme and XPointer xpointer() Scheme (XPath subset only) in a caching forward-only fashion.

Usage samples:

1. Basic identifying of subresources using XPointer:
XPointerReader r =
    new XPointerReader("books.xml", "xpointer(//book)");          
while (r.Read())
    Console.WriteLine(r.ReadOuterXml());
r.Close();

2. Running XPointerReader on an in-memory XML store:

XPathDocument doc = new XPathDocument("books.xml");
XPointerReader r =
    new XPointerReader(doc, "xpointer(//book)");          
while (r.Read())
    Console.WriteLine(r.ReadOuterXml());
r.Close();

or

XmlDocument doc = new XmlDocument();
doc.Load("books.xml");
XPointerReader r =
    new XPointerReader(doc, "xpointer(//book)");          
while (r.Read())
    Console.WriteLine(r.ReadOuterXml());
r.Close();

3. When running XPointerReader on XPathDocument or XmlDocument, you can get underlying XPathNavigator via IHasXPathNavigator interface:
XPathNavigator nav = ((IHasXPathNavigator)reader).GetNavigator();

4. Namespace-aware XPointers:
XPointerReader r =
    new XPointerReader("books.xml", "xmlns(bk=http://books.com)xpointer(//bk:book)");

5. Fallback-like XPointers. Recall that XPointer can consist of a several pointer parts, which are evaluated in turn until one identifies any subresource. That property can be used to create more reliable XPointers:
XPointerReader r =
    new XPointerReader("books.xml", "element(bk101)xpointer(//book[@id='bk101'])");

Conformance Issues

  1. Only XPath subset of the XPointer xpointer() Scheme is currently supported.

License

XPointer.NET as part of the Mvp.Xml project is subject to the GPL License - OSI approved free open-source license.

Support

You can get support on using XInclude.NET module using the following options:


The project is hosted at SourceForge. Find more at the Mvp.Xml project page at SourceForge.
SourceForge logo
$Id: index.html,v 1.6 2005/11/02 13:21:27 helgy Exp $