public override XElement GenerateForXSD( ObjectGeneration obj, XElement rootElement, XElement choiceElement, TypeGeneration typeGen, string nameOverride = null) { var common = XmlMod.CommonXSDLocation(obj.ProtoGen); var relativePath = common.GetRelativePathTo(XmlMod.ObjectXSDLocation(obj)); var includeElem = new XElement( XmlTranslationModule.XSDNamespace + "include", new XAttribute("schemaLocation", relativePath)); if (!rootElement.Elements().Any((e) => e.ContentEqual(includeElem))) { rootElement.AddFirst(includeElem); } var elem = new XElement(XmlTranslationModule.XSDNamespace + "element"); elem.Add(new XAttribute("name", nameOverride ?? typeGen.Name)); elem.Add(new XAttribute("type", Nullable ? "NullableValueType" : "ValueType")); choiceElement.Add(elem); return(elem); }
public override XElement GenerateForXSD( ObjectGeneration objGen, XElement rootElement, XElement choiceElement, TypeGeneration typeGen, string nameOverride = null) { LoquiType loqui = typeGen as LoquiType; var targetObject = loqui.TargetObjectGeneration; var targetNamespace = XmlMod.ObjectNamespace(targetObject); var diffNamespace = !targetNamespace.Equals(XmlMod.ObjectNamespace(objGen)); if (diffNamespace) { rootElement.Add( new XAttribute(XNamespace.Xmlns + $"{targetObject.Name.ToLower()}", XmlMod.ObjectNamespace(targetObject))); } FilePath xsdPath = XmlMod.ObjectXSDLocation(targetObject); var relativePath = xsdPath.GetRelativePathTo(objGen.TargetDir); var importElem = new XElement( XmlTranslationModule.XSDNamespace + "include", new XAttribute("schemaLocation", relativePath)); if (diffNamespace && !rootElement.Elements().Any((e) => e.ContentEqual(importElem))) { importElem.Add(new XAttribute("namespace", XmlMod.ObjectNamespace(targetObject))); } if (!rootElement.Elements().Any((e) => e.ContentEqual(importElem))) { rootElement.AddFirst(importElem); } var elem = new XElement( XmlTranslationModule.XSDNamespace + "element", new XAttribute("name", nameOverride ?? loqui.Name)); if (diffNamespace) { elem.Add( new XAttribute("type", $"{targetObject.Name.ToLower()}:{loqui.TargetObjectGeneration.Name}Type")); } else { elem.Add( new XAttribute("type", $"{loqui.TargetObjectGeneration.Name}Type")); } choiceElement.Add(elem); return(elem); }