private static void PopulateEnumerationValues(X12_IdDataType idType, XmlSchemaElement element)
        {
            if (idType == null || idType.AllowedValues == null || idType.AllowedValues.Count == 0)
            {
                return;
            }

            XmlSchemaSimpleType            simpleType  = element.SchemaType as XmlSchemaSimpleType;
            XmlSchemaSimpleTypeRestriction restriction = simpleType.Content as XmlSchemaSimpleTypeRestriction;

            foreach (KeyValuePair <string, string> kvp in idType.AllowedValues)
            {
                XmlSchemaEnumerationFacet facet = new XmlSchemaEnumerationFacet();
                facet.Value = kvp.Key;
                if (!string.IsNullOrEmpty(kvp.Value))
                {
                    XmlSchemaAnnotation    annotation = new XmlSchemaAnnotation();
                    XmlSchemaDocumentation doc        = new XmlSchemaDocumentation();
                    doc.Markup = TextToNodeArray(kvp.Value);
                    annotation.Items.Add(doc);
                    facet.Annotation = annotation;
                }

                restriction.Facets.Add(facet);
            }
        }
Esempio n. 2
0
        public static string ReadDocumentationFromEnumeration(XmlSchemaEnumerationFacet enumeration)
        {
            string documentation           = string.Empty;
            XmlSchemaAnnotation annotation = enumeration.Annotation;

            if (annotation != null && annotation.Items != null)
            {
                XmlSchemaObjectCollection coll = annotation.Items;
                foreach (XmlSchemaObject obj in coll)
                {
                    if (obj is XmlSchemaDocumentation)
                    {
                        XmlSchemaDocumentation doc = (XmlSchemaDocumentation)obj;
                        XmlNode[] node             = doc.Markup;
                        if (node != null)
                        {
                            for (int i = 0; i < node.Length; i++)
                            {
                                if (node[i] is XmlText)
                                {
                                    documentation = (node[i] as XmlText).InnerText;
                                }
                            }
                        }
                    }
                }
            }

            return(documentation);
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the first sentence of a documentation element and returns it as a string.
        /// </summary>
        /// <param name="annotation">The annotation in which to look for a documentation element.</param>
        /// <returns>The string representing the first sentence, or null if none found.</returns>
        private static string GetDocumentation(XmlSchemaAnnotation annotation)
        {
            string documentation = null;

            if (annotation != null && annotation.Items != null)
            {
                foreach (XmlSchemaObject obj in annotation.Items)
                {
                    XmlSchemaDocumentation schemaDocumentation = obj as XmlSchemaDocumentation;
                    if (schemaDocumentation != null)
                    {
                        if (schemaDocumentation.Markup.Length > 0)
                        {
                            XmlText text = schemaDocumentation.Markup[0] as XmlText;
                            if (text != null)
                            {
                                documentation = text.Value;
                            }
                        }
                        break;
                    }
                }
            }

            if (documentation != null)
            {
                documentation = documentation.Trim();
            }
            return(documentation);
        }
Esempio n. 4
0
        internal static void WriteDescription(this XmlSchemaAnnotated annotated, string description)
        {
            if (string.IsNullOrEmpty(description) == true)
            {
                return;
            }

            if (annotated.Annotation == null)
            {
                annotated.Annotation = new XmlSchemaAnnotation();
            }

            var annotation = annotated.Annotation;
            {
                var documentation = new XmlSchemaDocumentation();
                {
                    var doc      = new XmlDocument();
                    var textNode = doc.CreateTextNode(description);
                    documentation.Markup = new XmlNode[1] {
                        textNode
                    };
                }
                annotation.Items.Add(documentation);
            }
        }
Esempio n. 5
0
        private void AddInfo(XmlSchema xSchema, JsonSchema jSchema)
        {
            InfoKeyword info = jSchema.Get<InfoKeyword>();
            if (info != null)
            {
                XmlSchemaAnnotation annotation = new XmlSchemaAnnotation();
                XmlSchemaDocumentation documentation = new XmlSchemaDocumentation();
                annotation.Items.Add(documentation);

                List<XmlElement> elements = new List<XmlElement>();
                JsonObject infoObject = info.ToJson(new JsonSerializer()).Object;
                foreach (string attributeName in infoObject.Keys)
                {
                    XmlElement attrElement = xmlDocument.CreateElement("xs", "attribute", XML_SCHEMA_NS);
                    attrElement.SetAttribute("name", attributeName);
                    attrElement.SetAttribute("fixed", infoObject.TryGetString(attributeName));

                    elements.Add(attrElement);
                }

                documentation.Markup = elements.ToArray();

                xSchema.Items.Add(annotation);
            }
        }
 public void IterateThrough(XmlSchemaDocumentation obj)
 {
     if (_functionalVisitor.StartProcessing(obj))
     {
     }
     _functionalVisitor.EndProcessing(obj);
 }
        internal static XmlSchemaAnnotation CreateXmlSchemaAnnotation(string text, bool bExportXmlDoc, MemberInfo memberInfo)
        {
            XElement    element = null;
            XmlDocument doc     = new XmlDocument();

            if (memberInfo != null && bExportXmlDoc)
            {
                Type   type       = memberInfo.DeclaringType == null ? (Type)memberInfo : memberInfo.DeclaringType;
                string memberName = XmlDocumentation.CreateMemberName(memberInfo);
                element = XmlDocumentation.Load(memberName, type);
            }
            if (element == null)
            {
                element = new XElement("member", new XText(text));
            }
            else
            {
                element.AddFirst(new XText(text));
            }

            doc.LoadXml(element.ToString());

            XmlSchemaAnnotation    annotation    = new XmlSchemaAnnotation();
            XmlSchemaDocumentation documentation = new XmlSchemaDocumentation();

            documentation.Markup = doc.DocumentElement.ChildNodes.Cast <XmlNode>().ToArray();
            annotation.Items.Add(documentation);

            return(annotation);
        }
Esempio n. 8
0
 private void append(StringBuilder sb, XmlSchemaDocumentation doc)
 {
     sb.AppendLine(string.Format("(Source: {2} at Ln {0} Col {1})", doc.LineNumber, doc.LinePosition, doc.SourceUri));
     sb.AppendLine();
     sb.Append("     ");
     sb.AppendLine(doc.Markup[0].OuterXml.Trim());
 }
        private void AppendXsdDocumentationInformation(List <ClrAnnotation> annotations, XmlSchemaObject schemaObject)
        {
            XmlSchemaAnnotated annotatedObject = schemaObject as XmlSchemaAnnotated;

            if (annotatedObject != null &&
                annotatedObject.Annotation != null)
            {
                XmlNode[] markup;
                foreach (XmlSchemaObject annot in annotatedObject.Annotation.Items)
                {
                    XmlSchemaDocumentation doc = annot as XmlSchemaDocumentation;
                    if (doc != null)
                    {
                        markup = doc.Markup;
                    }
                    else
                    {
                        markup = ((XmlSchemaAppInfo)annot).Markup;
                    }

                    string text = String.Empty;
                    foreach (XmlNode xn in markup)
                    {
                        text += xn.InnerText;
                    }

                    if (text.Length > 0)
                    {
                        AppendMessage(annotations, "summary", text);
                    }
                }
            }
        }
Esempio n. 10
0
        private static string CleanAnnotation(XmlSchemaDocumentation item)
        {
            var text = "";

            text = item.Markup[0].InnerText.Substring(0, 1).Contains("\n") ? item.Markup[0].InnerText.Remove(0, 2) : item.Markup[0].InnerText;
            text = text.Replace("\n                  ", " ");
            text = text.Replace("\n                 ", " ");
            text = text.Replace("\n                ", " ");
            text = text.Replace("\n               ", " ");
            text = text.Replace("\n              ", " ");
            text = text.Replace("\n             ", " ");
            text = text.Replace("\n            ", " ");
            text = text.Replace("\n           ", " ");
            text = text.Replace("\n          ", " ");
            text = text.Replace("\n         ", " ");
            text = text.Replace("\n        ", " ");
            text = text.Replace("\n       ", " ");
            text = text.Replace("\n      ", " ");
            text = text.Replace("\n     ", " ");
            text = text.Replace("\n    ", " ");
            text = text.Replace("\n   ", " ");
            text = text.Replace("\n  ", " ");
            text = text.Replace("\n ", " ");
            text = text.Replace("\n", " ").Trim();
            text = text.Replace("'", "''");
            text = text.Replace("\t", "");
            return(text);
        }
Esempio n. 11
0
    }     //WriteXmlSchemaElement()

    //XmlSchemaAnnotation
    public static void WriteXmlSchemaAnnotation(XmlSchemaAnnotation annotation,
                                                XmlTextWriter myXmlTextWriter)
    {
        // Not a complete implementation
        myXmlTextWriter.WriteStartElement("annotation", XmlSchema.Namespace);
        foreach (object o in annotation.Items)
        {
            if (o is XmlSchemaDocumentation)
            {
                myXmlTextWriter.WriteStartElement("documentation", XmlSchema.Namespace);
                XmlSchemaDocumentation xmlsd = (XmlSchemaDocumentation)o;
                foreach (XmlNode n in xmlsd.Markup)
                {
                    myXmlTextWriter.WriteStartElement("documentation values", XmlSchema.Namespace);
                    myXmlTextWriter.WriteString(n.Value);
                    myXmlTextWriter.WriteEndElement();
                } //foreach
                myXmlTextWriter.WriteEndElement();
            }     //if
            else
            {
                if (o is XmlSchemaAppInfo)
                {
                    XmlSchemaAppInfo xsai = (XmlSchemaAppInfo)o;
                    foreach (XmlNode n in xsai.Markup)
                    {
                        myXmlTextWriter.WriteStartElement("appinfo values", XmlSchema.Namespace);
                        myXmlTextWriter.WriteString(n.Value);
                        myXmlTextWriter.WriteEndElement();
                    } //foreach
                }     //if
            }         //else
        }             //foreach
        myXmlTextWriter.WriteEndElement();
    }                 //WriteXmlSchemaAnnotation()
        protected internal virtual void Write(XmlSchemaObject obj)
        {
            var annotated = (XmlSchemaAnnotated)obj;

            foreach (var doc in Documentation)
            {
                var xmlDoc = new XmlSchemaDocumentation();

                if (doc.Language != null)
                {
                    xmlDoc.Language = doc.Language;
                }

                if (doc.Text != null)
                {
                    xmlDoc.Markup = new XmlNode[] { _xmlDoc.CreateTextNode(doc.Text) };
                }

                annotated.Annotation = new XmlSchemaAnnotation {
                    Items = { xmlDoc }
                };
            }

            WriteSmeAttributes(obj);
        }
Esempio n. 13
0
        private void AnnotateTaskElement(Type taskType, XmlSchemaAnnotated taskElement)
        {
            if (!this.documentationLoader.HasDocumentation(taskType.Assembly))
            {
                return;
            }
            // let's find the element
            string summary = this.documentationLoader.GetTypeSummary(taskType);

            if (string.IsNullOrEmpty(summary))
            {
                return;
            }

            taskElement.Annotation = new XmlSchemaAnnotation();
            XmlSchemaDocumentation doc = new XmlSchemaDocumentation();

            taskElement.Annotation.Items.Add(doc);
            XmlText text = new XmlDocument().CreateTextNode(summary);

            if (ReflectionHelper.HasAttribute <ObsoleteAttribute>(taskType))
            {
                text.Value = "[Obsolete] " + text.Value;
            }
            doc.Markup = new XmlNode[] { text };
        }
        private void AppendXsdDocumentationInformation(List <ClrAnnotation> annotations, XmlSchemaObject schemaObject)
        {
            XmlNode[]          markup;
            XmlSchemaAnnotated annotatedObject = schemaObject as XmlSchemaAnnotated;

            if ((annotatedObject == null ? false : annotatedObject.Annotation != null))
            {
                foreach (XmlSchemaObject annot in annotatedObject.Annotation.Items)
                {
                    XmlSchemaDocumentation doc = annot as XmlSchemaDocumentation;
                    markup = (doc == null ? ((XmlSchemaAppInfo)annot).Markup : doc.Markup);
                    string    text          = string.Empty;
                    XmlNode[] xmlNodeArrays = markup;
                    for (int i = 0; i < (int)xmlNodeArrays.Length; i++)
                    {
                        XmlNode xn = xmlNodeArrays[i];
                        text = string.Concat(text, xn.InnerText);
                    }
                    if (text.Length > 0)
                    {
                        this.AppendMessage(annotations, "summary", text);
                    }
                }
            }
        }
Esempio n. 15
0
        private void SetDiccionaryValidate(XmlSchema myschema)
        {
            foreach (XmlSchemaObject shemaO in myschema.Items)
            {
                if (shemaO.GetType().Name != "XmlSchemaSimpleType")
                {
                    continue;
                }


                foreach (XmlSchemaObject shema1 in ((XmlSchemaSimpleType)shemaO).Annotation.Items)
                {
                    if (shema1.GetType().Name != "XmlSchemaDocumentation")
                    {
                        continue;
                    }

                    XmlSchemaDocumentation documentacion = (XmlSchemaDocumentation)shema1;
                    if (documentacion.Source != null && documentacion.Markup[0].Value != null)
                    {
                        _diccionarioData.Add(documentacion.Source, documentacion.Markup[0].Value);
                    }
                }
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Запись в класс SeSchemaItem описания из Annotation в XSD
        /// </summary>
        /// <param name="schemaElement">Элемент из List(SeShemaItem)</param>
        /// <returns>Содержимое Annotation->Documentation из файла XSD (string)</returns>
        public string GetAnnotation(XmlSchemaObject schemaElement)
        {
            XmlSchemaAnnotation discriptionAnn = new XmlSchemaAnnotation();

            if (schemaElement is XmlSchemaElement)
            {
                XmlSchemaElement schemaElementAnn = schemaElement as XmlSchemaElement;
                discriptionAnn = schemaElementAnn.Annotation;
            }
            else if (schemaElement is XmlSchemaComplexType)
            {
                XmlSchemaComplexType schemaElementAnn = schemaElement as XmlSchemaComplexType;
                discriptionAnn = schemaElementAnn.Annotation;
            }
            else if (schemaElement is XmlSchemaSimpleType)
            {
                XmlSchemaSimpleType schemaElementAnn = schemaElement as XmlSchemaSimpleType;
                discriptionAnn = schemaElementAnn.Annotation;
            }
            XmlSchemaDocumentation discriptionDoc = new XmlSchemaDocumentation();

            if (discriptionAnn != null)
            {
                foreach (XmlSchemaDocumentation MarkupSchemaItem in discriptionAnn.Items)
                {
                    if (MarkupSchemaItem.Markup[0] != null)
                    {
                        return(MarkupSchemaItem.Markup[0].Value.ToString());
                    }
                }
            }
            return(null);
        }
Esempio n. 17
0
        /// <summary>
        /// Запись в класс SeSchemaItem описания из <xsd:Annotation>
        /// </summary>
        /// <param name="schemaElement">Элемент из List(SeShemaItem)</param>
        /// <returns>Содержимое Annotation->Documentation из файла XSD (string)</returns>
        public string GetAnnotation(XmlSchemaObject schemaElement)
        {
            XmlSchemaAnnotation discriptionAnn = new XmlSchemaAnnotation();

            //прикрепление XmlSchemaAnnotation к текущему объекту
            if (schemaElement is XmlSchemaElement)
            {
                XmlSchemaElement schemaElementAnn = schemaElement as XmlSchemaElement;
                discriptionAnn = schemaElementAnn.Annotation;
            }
            else
            {
                XmlSchemaComplexType schemaElementAnn = schemaElement as XmlSchemaComplexType;
                discriptionAnn = schemaElementAnn.Annotation;
            }
            //Чтение содержимого Annotation
            XmlSchemaDocumentation discriptionDoc = new XmlSchemaDocumentation();

            if (discriptionAnn != null)
            {
                foreach (XmlSchemaDocumentation MarkupSchemaItem in discriptionAnn.Items)
                {
                    if (MarkupSchemaItem.Markup[0] != null)
                    {
                        return(MarkupSchemaItem.Markup[0].Value.ToString());
                    }
                }
            }
            return(null);
        }
Esempio n. 18
0
        static string GetMarkup(XmlSchemaAnnotation ann, string filter)
        {
            StringBuilder sb = new StringBuilder();

            foreach (XmlSchemaObject o in ann.Items)
            {
                // for xs:documentation nodes
                if (o is XmlSchemaDocumentation)
                {
                    XmlSchemaDocumentation d = (XmlSchemaDocumentation)o;
                    XmlNode[] ma             = d.Markup;
                    if (ma != null)
                    {
                        // if we only have the xs:documentation node (no markup)...
                        foreach (XmlNode n in ma)
                        {
                            if (string.IsNullOrEmpty(filter) ||
                                string.Compare(filter, n.LocalName, StringComparison.InvariantCultureIgnoreCase) == 0)
                            {
                                sb.Append(n.InnerText);
                            }
                        }
                    }
                }
            }
            return(sb.ToString());
        }
Esempio n. 19
0
 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;
     }
 }
Esempio n. 20
0
        public override XmlSchemaObject VisitASTType(ASTType astType)
        {
            var t = new XmlSchemaComplexType
            {
                Name = astType.Name
            };

            var fields = astType.Fields.Select(Visit);
            var all    = new XmlSchemaAll();

            foreach (var field in fields)
            {
                all.Items.Add(field);
            }

            t.Particle = all;

            var description      = string.Join(" ", astType.Annotations.Select(a => a.Value));
            var schemaAnnotation = new XmlSchemaAnnotation();
            var docs             = new XmlSchemaDocumentation()
            {
                Markup = TextToNodeArray(description)
            };

            schemaAnnotation.Items.Add(docs);
            t.Annotation = schemaAnnotation;

            this.Schema.Items.Add(t);

            ExtractElement(astType);

            return(t);
        }
Esempio n. 21
0
        private static XmlSchemaDocumentation CreateDocumentationItem(string text)
        {
            XmlDocument            doc     = new XmlDocument();
            XmlSchemaDocumentation comment = new XmlSchemaDocumentation();
            XmlNode node = doc.CreateTextNode(text);

            comment.Markup = new XmlNode[] { node };
            return(comment);
        }
Esempio n. 22
0
        /// <summary>
        /// Запись Annotation в новый файл XSD
        /// </summary>
        /// <param name="newschemaItem">Текущий экземпляр класса SeSchemaItem(список List(SeSchemaItem) класса SeSchema</param>
        /// <param name="discriptionAnn">Новый элемент XmlSchemaAnnotation</param>
        /// <returns>Измененный элемент XmlSchemaAnnotation</returns>
        public XmlSchemaAnnotation SetAnnotation(SeSchemaItem newschemaItem)
        {
            XmlSchemaAnnotation    discriptionAnn = new XmlSchemaAnnotation();
            XmlSchemaDocumentation discriptionDoc = new XmlSchemaDocumentation();

            discriptionAnn.Items.Add(discriptionDoc);
            discriptionDoc.Markup = TextToNodeArray(newschemaItem.Description);
            return(discriptionAnn);
        }
Esempio n. 23
0
        private XmlSchemaDocumentation CreateSimpleDocumentation(string type, string description)
        {
            XmlSchemaDocumentation documentation = new XmlSchemaDocumentation();

            XmlNode[] nodes = { xmlDocument.CreateTextNode(description) };
            documentation.Markup = nodes;
            documentation.Source = type;

            return documentation;
        }
Esempio n. 24
0
        void AddAnnotation(XmlSchemaAnnotated element, string value)
        {
            var annotation    = new XmlSchemaAnnotation();
            var documentation = new XmlSchemaDocumentation();
            var document      = new XmlDocument();

            documentation.Markup = new[] { document.CreateTextNode(value) };
            annotation.Items.Add(documentation);
            element.Annotation = annotation;
        }
 private static void SetDocumentation(IPluglet pluglet, XmlSchemaElement element)
 {
     if (!string.IsNullOrEmpty(pluglet.Definition))
     {
         XmlSchemaAnnotation    annotation = new XmlSchemaAnnotation();
         XmlSchemaDocumentation doc        = new XmlSchemaDocumentation();
         doc.Markup = TextToNodeArray(pluglet.Definition);
         annotation.Items.Add(doc);
         element.Annotation = annotation;
     }
 }
Esempio n. 26
0
        /// <summary>
        /// Extracts annotation section from passes XmlSchema object
        /// </summary>
        /// <param name="annotatedElement">Annotation element of XSD schema with documentation and appinfo tags</param>
        /// <returns>Extracted Documentation and AppInfo</returns>
        public static Dictionary <string, string> GetDocumentationForElement(XmlSchemaAnnotated annotatedElement)
        {
            Dictionary <string, string> annotationElements = new Dictionary <string, string>();
            StringBuilder       documatationHolder         = new StringBuilder();
            StringBuilder       appInfoHolder = new StringBuilder();
            XmlSchemaAnnotation annotation    = annotatedElement.Annotation;

            // Look inside the Annotation element
            if (annotation != null)
            {
                XmlSchemaObjectCollection annotationItems = annotation.Items;
                if (annotationItems.Count > 0)
                {
                    // Cannot use for..each
                    for (int elementCount = 0; elementCount < annotationItems.Count; elementCount++)
                    {
                        XmlSchemaDocumentation xsdDocumentation = annotationItems[elementCount] as XmlSchemaDocumentation;
                        if (xsdDocumentation != null)
                        {
                            XmlNode[] documentationMarkups = xsdDocumentation.Markup;
                            if (documentationMarkups.Length > 0)
                            {
                                documatationHolder.Append(documentationMarkups[0].InnerText);
                                documatationHolder.Append(" ");
                            }
                        }

                        XmlSchemaAppInfo xsdAppInfo = annotationItems[elementCount] as XmlSchemaAppInfo;
                        if (xsdAppInfo != null)
                        {
                            XmlNode[] appInfoMarkups = xsdAppInfo.Markup;
                            if (appInfoMarkups.Length > 0)
                            {
                                appInfoHolder.Append(appInfoMarkups[0].InnerText);
                                appInfoHolder.Append(" ");
                            }
                        }
                    }

                    if (documatationHolder.Length > 0)
                    {
                        annotationElements.Add("DOC", documatationHolder.ToString());
                    }

                    if (appInfoHolder.Length > 0)
                    {
                        annotationElements.Add("APPINFO", appInfoHolder.ToString());
                    }
                }
            }

            return(annotationElements);
        }
 void ReadDocumentationFromAnnotation(XmlSchemaObjectCollection annotationItems)
 {
     foreach (XmlSchemaObject schemaObject in annotationItems)
     {
         XmlSchemaDocumentation schemaDocumentation = schemaObject as XmlSchemaDocumentation;
         if (schemaDocumentation != null)
         {
             ReadSchemaDocumentationFromMarkup(schemaDocumentation.Markup);
         }
     }
     RemoveWhitespaceFromDocumentation();
 }
Esempio n. 28
0
        public bool AddMaxDistanceConstraint(string Km, string Latitude, string Longitude)
        {
            double km, lat, lon;

            if (!double.TryParse(Km, out km) || km < 0)
            {
                return(false);
            }
            if (!double.TryParse(Latitude, out lat))
            {
                return(false);
            }
            if (!double.TryParse(Longitude, out lon))
            {
                return(false);
            }

            if (lat < -90 || lat > 90)
            {
                return(false);
            }
            if (lon < -180 || lon > 180)
            {
                return(false);
            }

            // custom constraint (close your eyes =)
            XmlSchemaComplexContentExtension cce = (XmlSchemaComplexContentExtension)((XmlSchemaComplexContent)(((XmlSchemaComplexType)baseSchema.Items[0])).ContentModel).Content;

            XmlSchemaAnnotation sa = (cce.Annotation == null) ? new XmlSchemaAnnotation() : cce.Annotation;

            cce.Annotation = sa;

            XmlSchemaDocumentation sd = new XmlSchemaDocumentation();

            sa.Items.Add(sd);

            XmlDocument doc  = new XmlDocument();
            XmlNode     node = doc.CreateElement("maxDistanceFrom");

            sd.Markup = new XmlNode[1] {
                node
            };

            node.AppendChild(doc.CreateElement("Distance"));
            node.AppendChild(doc.CreateElement("Latitude"));
            node.AppendChild(doc.CreateElement("Longitude"));
            node.ChildNodes[0].InnerText = km.ToString();
            node.ChildNodes[1].InnerText = lat.ToString();
            node.ChildNodes[2].InnerText = lon.ToString();

            return(true);
        }
Esempio n. 29
0
        public XmlSchema GetDataSchemas(XmlSchema querySchema, IEnumerable <Registration> registrations)
        {
            var schema = new XmlSchema {
                TargetNamespace = RegistrationStorage.Dataspace
            };

            schema.Namespaces.Add("", RegistrationStorage.Dataspace);
            var guid = CreateGuidType();

            schema.Items.Add(guid);
            schema.Includes.Add(new XmlSchemaImport {
                Schema = querySchema, Namespace = querySchema.TargetNamespace
            });
            foreach (var registration in registrations)
            {
                var etype = new XmlSchemaComplexType
                {
                    Name       = registration.ResourceName,
                    Annotation = new XmlSchemaAnnotation()
                };
                var doc = new XmlSchemaDocumentation {
                    Markup = TextToNode(registration.ResourceType.FullName)
                };
                etype.Annotation.Items.Add(doc);
                etype.Block = XmlSchemaDerivationMethod.Extension;
                var idAttr = new XmlSchemaAttribute
                {
                    Name           = "Id",
                    SchemaTypeName = new XmlQualifiedName(guid.Name, RegistrationStorage.Dataspace),
                    Use            = XmlSchemaUse.Required
                };
                etype.Attributes.Add(idAttr);
                var noChildrenAttr = new XmlSchemaAttribute
                {
                    Name       = RegistrationStorage.DefinitlyNoChildren,
                    SchemaType = XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Boolean),
                    Use        = XmlSchemaUse.Optional
                };
                etype.Attributes.Add(noChildrenAttr);
                if (querySchema.Items.OfType <XmlSchemaAttributeGroup>().Any(k => k.Name == etype.Name))
                {
                    var group = new XmlSchemaAttributeGroupRef();
                    group.RefName = new XmlQualifiedName(etype.Name.Replace(" ", "_"), querySchema.TargetNamespace);
                    etype.Attributes.Add(group);
                }
                schema.Items.Add(etype);
            }

            return(schema);
        }
Esempio n. 30
0
        private XmlSchemaAnnotation GetXmlAnnotattion(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(null);
            }

            var annotation    = new XmlSchemaAnnotation();
            var documentation = new XmlSchemaDocumentation();

            documentation.Markup = TextToNodeArray(text);
            annotation.Items.Add(documentation);

            return(annotation);
        }