Convert to XML or Generate XSD

Serialization to XML

Convert any EDI object to XML by simply serializing it. All EDI Specs are marked for serialization.

Serialize EDI object

public static  XDocument Serialize(EdiMessage instance)
{
    if (instance == null)
        throw new ArgumentNullException("instance");

    var serializer = new XmlSerializer(instance.GetType());
    using (var ms = new MemoryStream())
    {
        serializer.Serialize(ms, instance);
        ms.Position = 0;
        return XDocument.Load(ms, LoadOptions.PreserveWhitespace);
    }
}

Generate XSD from EDI Specs

Use XSD.exe to generate XSD for an assembly containing EDI Specs.

xsd.exe C:\InputEdiSpecFolder\EdiFabric.Rules.X12EdiSpec.dll /o:C:\OutputXsdFolder