private void setAnnotation(AbstractDef def, XmlSchemaAnnotation annotation) { if (annotation != null) { string desc = string.Empty; foreach (XmlSchemaObject o in annotation.Items) { XmlSchemaDocumentation description = o as XmlSchemaDocumentation; if (description != null) { foreach (XmlNode node in description.Markup) { desc += node.OuterXml; } } else { XmlSchemaAppInfo appinfo = o as XmlSchemaAppInfo; if (o != null) { def.SetFlags(appinfo.Markup[0].InnerText); } } } def.Desc = desc; } }
private AbstractDef BuildObjectFromElement(XmlSchemaElement element, ObjectDef parent, bool attachToParent) { //System.Diagnostics.Debug.Assert( !( element.QualifiedName.Name == "FineInfo" ) ); AbstractDef returnVal = null; if (element.ElementSchemaType is XmlSchemaComplexType) { ObjectDef def = fDB.GetObject(element.QualifiedName.Name); if (def != null) { if (parent != null && attachToParent) { returnVal = parent.DefineElement(def.Name, def.Name); if (parent.Infra) { def.setInfra(); } returnVal.SetFlags(getFlags(element)); setAnnotation(returnVal, element.Annotation); } if (parent == null) { // Reset the source location def.SourceLocation = element.SourceUri + ";line:" + element.LineNumber; def.LocalPackage = getLocalPackage(element.SourceUri); setAnnotation(def, element.Annotation); } // Console.WriteLine( element.QualifiedName.Name + " is already defined, ignoring." ); return(def); } //System.Diagnostics.Debug.Assert( !( element.QualifiedName.Name == "StaffPersonal" ) ); def = fDB.defineObject (0, element.QualifiedName.Name, getLocalPackage(element.SourceUri), element.SourceUri + ";line:" + element.LineNumber); returnVal = def; XmlSchemaComplexType type = (XmlSchemaComplexType)element.ElementSchemaType; BuildAttributes(type.Attributes, def); BuildContentModel(type, def); if (parent != null && attachToParent) { returnVal = parent.DefineElement(def.Name, def.Name); if (parent.Infra) { def.setInfra(); } } } else { if (parent == null) { Console.WriteLine ("Unexpected Root Simple element found: " + element.QualifiedName.Name); } else { bool isEnum; string dataType = GetClassTypeFromDataType (element.ElementSchemaType, element.QualifiedName.Name, parent.Name, out isEnum); if (isEnum) { Debug.Assert(element.QualifiedName.Name != "SchoolYear"); returnVal = parent.DefineElement(element.QualifiedName.Name, null); ((FieldDef)returnVal).SetEnum(dataType); } else { returnVal = parent.DefineElement(element.QualifiedName.Name, dataType); } } } if (returnVal != null) { returnVal.SetFlags(getFlags(element)); setAnnotation(returnVal, element.Annotation); } return(returnVal); }
private void setAnnotation( AbstractDef def, XmlSchemaAnnotation annotation ) { if ( annotation != null ) { string desc = string.Empty; foreach ( XmlSchemaObject o in annotation.Items ) { XmlSchemaDocumentation description = o as XmlSchemaDocumentation; if ( description != null ) { foreach ( XmlNode node in description.Markup ) { desc += node.OuterXml; } } else { XmlSchemaAppInfo appinfo = o as XmlSchemaAppInfo; if ( o != null ) { def.SetFlags( appinfo.Markup[0].InnerText ); } } } def.Desc = desc; } }