public static XmlDocument CreateMessage(string schemaName, string rootNode, string assembly)
{
XmlDocument doc = new XmlDocument();
DocumentSpec docSpec;
BtsCatalogExplorer catalog = new BtsCatalogExplorer();
catalog.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings[BTS_CONNECTION_STRING].ConnectionString;
Schema schema = null;
if (assembly == string.Empty)
schema = catalog.Schemas[schemaName];
else
schema = catalog.Schemas[schemaName, assembly];
if (schema == null)
throw new BTSUtilitiesException(string.Format("Failed to retrieve the {0} schema from the management database.", schemaName));
else
{
docSpec = new DocumentSpec(rootNode, schema.BtsAssembly.DisplayName);
if (docSpec == null)
throw new BTSUtilitiesException(string.Format("Failed to build the document {0}.", rootNode));
else
{
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
try
{
doc.Load(docSpec.CreateXmlInstance(sw));
}
finally
{
sw.Dispose();
}
}
}
return doc;
}