Welcome to EDXLSharp

What is EDXLSharp?

EDXLSharp is a C# / .NET 4.0 implementation of the OASIS Emergency Data Exchange Language (EDXL) family of standards. The purpose of these libraries are to allow developers to:
  • Parse EDXL Messages from a string / underlying stream
  • Programmatically create EDXL messages
  • Validate EDXL Messages to the schema
  • Validate that EDXL Messages conform to the additional business rules specified in the standards documentation
  • Write EDXL messages to a string / underlying stream


This code was generated as part of the internally funded research & development program, the MITRE Innovation Program (MIP) as MITRE Sponsored Research (MSR) effort called IC.NET.

Getting Started

  1. Install EDXL Sharp
    1. Download the latest version of the msi installer from the project download section
    2. Run the installer
  2. Start a new project in Visual Studio
  3. In your newly created project, right click on “References” and select “Add Reference”
    1. In the Add Reference Window, select the “Browse” Tab
  4. Navigate to the directory where EDXLSharp was installed and select all of the dll files
  5. You are now ready to include the EDXLSharp namespace in your project

Tutorial: How to Use EDXLSharp

Programmatically Creating a Message & Writing it to a File

  1. Begin by completing the steps in the Getting Started Section. For this example you can create a simple C# console application.
  2. Note: Since these libraries also produce / convert EDXL messages to Syndication / Feed Items, there are server-side .NET libraries referenced. As such, you will need the non-client profile of .NET 4.0 installed
  3. For this example we will programmatically create an EDXL-DE message. First, include the namespaces for EDXLSharp:

using EDXLSharp;
using EDXLSharp.EDXLDELib;
  • In your Main function create and instantiate a new empty EDXL-DE object. In this example we have called our EDXLDE object ‘DEXMLObj’:

EDXLDE DEXMLObj = new EDXLDE();
  • The EDXL-DE standard has a number of required elements. The sample code below will initialize the required elements through the EDXLDE public accessors:

DEXMLObj.DistributionStatus = StatusValue.Test;
DEXMLObj.DistributionType = TypeValue.Report;
DEXMLObj.CombinedConfidentiality = "U";
DEXMLObj.DistributionID = "EDXL Sharp Test Message";
DEXMLObj.SenderID = "test@edxlsharp.codeplex.com";
DEXMLObj.DateTimeSent = DateTime.UtcNow;
DEXMLObj.Language = "en-US";
  • Now let’s add some content. Let’s say we have an EDXL-HAVE object already populated with data.
  • All message types in EDXLSharp implement the IContentObject interface. This interface allows us to call the static helper function in EDXLDEUtils called box.
  • This function will create a new content object from the HAVE object, pre-populate some of the valuelists in the contentobject for routing, and add it to the DE object:

//Assume we have a populated object 'have' of type EDXLHAVE
//This would be created by the statement EDXLHAVE have = new EDXLHAVE();
DEObj.ContentObjects.Add(EDXLDEUtils.Box(have));
  • Now we have a simple EDXL-DE message. Let’s write it to an underlying stream; in this case a filestream to the file “DEXMLObj.xml”:

StreamWriter sw = new StreamWriter(".\\RandomIOCAP\\CAP" + i.ToString() + ".xml", false, System.Text.Encoding.UTF8);
DEObj.WriteXML(sw.BaseStream);
sw.Flush();
sw.Close();

Parsing a Message From an Underlying Stream

  • Begin by completing the steps in the Getting Started Section. For this example you can create a simple C# console application.
  • For this example we will read an EDXL-DE message from an underlying stream. First, include the namespaces for EDXLSharp:

using EDXLSharp;
using EDXLSharp.EDXLDELib;
  • We will parse an EDXL-DE message from a file called “DEExample.xml”

StreamReader sr = new StreamReader("..\\..\\..\\TestData\\DEExample.xml");
EDXLDE de = new EDXLDE(sr.ReadToEnd());
sr.Close();
  • Alternatively let’s say you had an EDXL-DE message stored in a string called “s” and wanted to read it in:

EDXLDE de = new EDXLDE();
de.ReadXML(s);

Other Coding Examples:

See Also

Last edited Mar 15, 2013 at 7:29 PM by bwilkinsnh, version 15

Comments

No comments yet.