Show navigation | Frontpage | Contact us | Sitemap

Developing Custom Xml Providers with Visual Studio 2005

The following guide helps you establish a project in Visual Studio where you can develop and debug your first Custom Xml Provider.

Prerequisites

You need the following to complete the steps defined below:

  • Microsoft Visual Studio 2005
  • Composite 3.8 installed on you local machine or on a local development server with remote debugging enabled.

Creating a custom provider:

  1. Download a debug project for Visual Studio and launch it.

  2. If your web root does not contain a folder named “App_Code” create it.

  3. Right click the App_Code folder and select “Add New Item”

  4. Select “Class” and name it MyFirstProvider.cs

  5. The following lines at the top (in the using section):

    using System.Xml;
    using System.Collections.Generic;
    using Composite.Cms.Pub.Interfaces;

  6. Change the line

    public class MyFirstProvider

    to

    public class MyFirstProvider : ICustomXmlProvider

  7. Right-click the text ICustomXmlProvider and select “Implement interface” (twice)

  8. Replace the body of the WriteXml() function with the following code:

    XmlDocument doc = new XmlDocument();
    doc.LoadXml(
    "<MyFirstProvider>Hello World</MyFirstProvider>");
    doc.WriteTo(xmlTarget);

  9. Save. Build to ensure no compile errors exist.

Registering the Custom Xml Provider with the XSLT tools

  1. Open the administrative window and browse to Datamap | Data Connection Definitions and ensure that a Data Connection named “Custom XML Providers” has bee created.

    If the connection has not been defined, right click the “Data Connection Definitions”, click “Add” and create a definition named “Custom XML Provider” with the following connection string:

    Provider=CustomXmlProvider

  2. To create a query, open the Data Query Definitions element, right click the “Custom XML Provider” element and select “Add”

  3. Specify “MyFirstProvider” as both name and command. Note that the name can be any value. The command must be the full name of your class.

  4. Save.

The XML from your provider is now available to XSLT developers. If you edit an XSL Render Identifier you can see your provider located in the “Custom XML Providers” section.

Debugging your provider

To debug your provider execute the following steps:

  1. Ensure that an XSL Render identifier subscribes to XML from your provider
  2. Ensure that the XSL Render identifier is active on a page or template
  3. In your Visual Studio project, place a breakpoint in your provider code.
  4. Press F5 (say yes if VS asks for permission to enable debugging in web.config).
  5. Your default browser will launch.
  6. Browse to a page containing the identifier subscribing to your providers XML
  7. VS will stop at your breakpoint.
To get a view of the XML data from your provider please see the XSL Render <Debug /> feature.

My modules


© 2008 Composite A/S, Danmark
Tlf: +45 39 15 76 00 | info@composite.net
Composite A/S er Microsoft Certified Partner
Composite CMS overholder standarden for valid CSS
Composite CMS overholder standarden for valid XHTML 1.0
Printet fra http://www.composite.net/composite-1691.htm
Findes på denne sti: Composite Developer | 3.x technologies | ASP.NET | Custom XML Providers | Using Visual Studio