public XmlDocument Generate(XmlDocument metadataXml, long id,bool addEmptyNode = false)
{
addAlsoEmptyNode = addEmptyNode;
#region abcd (metadata from bexis to abcd)
XmlDocument newMetadata = new XmlDocument();
XmlDeclaration declaration = newMetadata.CreateXmlDeclaration("1.0", "utf-8", null);
newMetadata.AppendChild(declaration);
newMetadata.AppendChild(newMetadata.CreateElement(xmlMapper.Header.Destination.Prefix, xmlMapper.Header.Destination.XPath, xmlMapper.Header.Destination.NamepsaceURI));
XmlNode root = newMetadata.DocumentElement;
XmlAttribute rootAttr = newMetadata.CreateAttribute("xmlns");
rootAttr.Value = xmlSchemaManager.Schema.TargetNamespace;
root.Attributes.Append(rootAttr);
// create nodes
newMetadata = mapNode(newMetadata, newMetadata.DocumentElement, metadataXml.DocumentElement);
// add required attributes
newMetadata = addAttributes(newMetadata, newMetadata.DocumentElement);
//add root attributes
foreach (KeyValuePair<string, string> attribute in xmlMapper.Header.Attributes)
{
XmlAttribute attr = newMetadata.CreateAttribute(attribute.Key);
attr.Value = attribute.Value;
root.Attributes.Append(attr);
}
//add root namespaces
foreach (KeyValuePair<string, string> package in xmlMapper.Header.Packages)
{
XmlAttribute attr = newMetadata.CreateAttribute(package.Key);
attr.Value = package.Value;
root.Attributes.Append(attr);
}
string path = Path.Combine(AppConfiguration.GetModuleWorkspacePath("DIM"), "Metadata " + id + ".xml");
newMetadata.Save(path);
// the following call to Validate succeeds.
//document.Validate(eventHandler);
#endregion
return newMetadata;
}