Show navigation | Frontpage | Contact us | Sitemap

The ICustomXmlProvider interface

Custom XML Providers must implement the interface ICustomXmlProvider located in the namespace Composite.Cms.Pub.Interfaces. ICustomXmlProvider is a fairly simple interface to implement which you can see from its definition:

using System.Collections.Generic;
using System.Xml;

namespace Composite.Cms.Pub.Interfaces
{ 
    public interface ICustomXmlProvider 
    { 
        void WriteXml(Dictionary<string, string> parameters, XmlWriter xmlTarget); 
    }
}

A Custom XML Provider is expected to implement one function, WriteXml, which gets a string based dictionary object (parameters, from the XSLT developer) and an XmlWriter object (xmlTarget, where you emit your XML to the XSLT developer).

Here is a “Hello World” sample of a C# class implementing ICustomXmlProvider:

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

public class HelloWorldXmlProvider : ICustomXmlProvider
{ 
    public void WriteXml(Dictionary<string, string> parameters, XmlWriter xmlTarget) 
    { 
        // Start the document... 
        xmlTarget.WriteStartDocument(); 

        // Write XML root element start 
        xmlTarget.WriteStartElement("Greeting"); 

        // Write string 
        xmlTarget.WriteString("Hello World"); 

        // End the root element 
        xmlTarget.WriteEndElement(); 

        // End the document 
        xmlTarget.WriteEndDocument(); 
    }
}

This code will emit the following XML:

<Greeting> 
  Hello World
</Greeting>

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-1688.htm
Findes på denne sti: Composite Developer | 3.x technologies | ASP.NET | Custom XML Providers | ICustomXmlProvider