internal bool IsXDRField(XmlElement node, XmlElement typeNode)
        {
            int minOccurs = 1;
            int maxOccurs = 1;

            if (!this.IsTextOnlyContent(typeNode))
            {
                return(false);
            }
            for (XmlNode node2 = typeNode.FirstChild; node2 != null; node2 = node2.NextSibling)
            {
                if (XMLSchema.FEqualIdentity(node2, "element", "urn:schemas-microsoft-com:xml-data") || XMLSchema.FEqualIdentity(node2, "attribute", "urn:schemas-microsoft-com:xml-data"))
                {
                    return(false);
                }
            }
            if (XMLSchema.FEqualIdentity(node, "element", "urn:schemas-microsoft-com:xml-data"))
            {
                this.GetMinMax(node, ref minOccurs, ref maxOccurs);
                if ((maxOccurs == -1) || (maxOccurs > 1))
                {
                    return(false);
                }
            }
            return(true);
        }
 internal void LoadSchema(XmlElement schemaRoot, DataSet ds)
 {
     if (schemaRoot != null)
     {
         this._schemaRoot = schemaRoot;
         this._ds         = ds;
         this._schemaName = schemaRoot.GetAttribute("name");
         this._schemaUri  = "";
         if ((this._schemaName == null) || (this._schemaName.Length == 0))
         {
             this._schemaName = "NewDataSet";
         }
         ds.Namespace = this._schemaUri;
         for (XmlNode node = schemaRoot.FirstChild; node != null; node = node.NextSibling)
         {
             if (node is XmlElement)
             {
                 XmlElement element = (XmlElement)node;
                 if (XMLSchema.FEqualIdentity(element, "ElementType", "urn:schemas-microsoft-com:xml-data"))
                 {
                     this.HandleTable(element);
                 }
             }
         }
         this._schemaName = XmlConvert.DecodeName(this._schemaName);
         if (ds.Tables[this._schemaName] == null)
         {
             ds.DataSetName = this._schemaName;
         }
     }
 }
        internal DataTable InstantiateSimpleTable(DataSet dataSet, XmlElement node)
        {
            XmlAttributeCollection attrs = node.Attributes;
            int    minOccurs             = 1;
            int    maxOccurs             = 1;
            string instanceName          = this.GetInstanceName(node);

            if (dataSet.Tables.GetTable(instanceName, this._schemaUri) != null)
            {
                throw ExceptionBuilder.DuplicateDeclaration(instanceName);
            }
            string    tableName = XmlConvert.DecodeName(instanceName);
            DataTable instance  = new DataTable(tableName)
            {
                Namespace = this._schemaUri
            };

            this.GetMinMax(node, ref minOccurs, ref maxOccurs);
            instance.MinOccurs = minOccurs;
            instance.MaxOccurs = maxOccurs;
            XMLSchema.SetProperties(instance, attrs);
            instance.repeatableElement = true;
            this.HandleColumn(node, instance);
            instance.Columns[0].ColumnName = tableName + "_Column";
            this._ds.Tables.Add(instance);
            return(instance);
        }
        internal XmlElement FindTypeNode(XmlElement node)
        {
            if (XMLSchema.FEqualIdentity(node, "ElementType", "urn:schemas-microsoft-com:xml-data"))
            {
                return(node);
            }
            string attribute = node.GetAttribute("type");

            if (XMLSchema.FEqualIdentity(node, "element", "urn:schemas-microsoft-com:xml-data") || XMLSchema.FEqualIdentity(node, "attribute", "urn:schemas-microsoft-com:xml-data"))
            {
                if ((attribute == null) || (attribute.Length == 0))
                {
                    return(null);
                }
                XmlNode firstChild    = node.OwnerDocument.FirstChild;
                XmlNode ownerDocument = node.OwnerDocument;
                while (firstChild != ownerDocument)
                {
                    if (((XMLSchema.FEqualIdentity(firstChild, "ElementType", "urn:schemas-microsoft-com:xml-data") && XMLSchema.FEqualIdentity(node, "element", "urn:schemas-microsoft-com:xml-data")) || (XMLSchema.FEqualIdentity(firstChild, "AttributeType", "urn:schemas-microsoft-com:xml-data") && XMLSchema.FEqualIdentity(node, "attribute", "urn:schemas-microsoft-com:xml-data"))) && ((firstChild is XmlElement) && (((XmlElement)firstChild).GetAttribute("name") == attribute)))
                    {
                        return((XmlElement)firstChild);
                    }
                    if (firstChild.FirstChild != null)
                    {
                        firstChild = firstChild.FirstChild;
                    }
                    else
                    {
                        if (firstChild.NextSibling == null)
                        {
                            goto Label_0115;
                        }
                        firstChild = firstChild.NextSibling;
                    }
                    continue;
Label_00FD:
                    firstChild = firstChild.ParentNode;
                    if (firstChild.NextSibling != null)
                    {
                        firstChild = firstChild.NextSibling;
                        continue;
                    }
Label_0115:
                    if (firstChild != ownerDocument)
                    {
                        goto Label_00FD;
                    }
                }
            }
            return(null);
        }
        internal string GetInstanceName(XmlElement node)
        {
            string attribute;

            if (XMLSchema.FEqualIdentity(node, "ElementType", "urn:schemas-microsoft-com:xml-data") || XMLSchema.FEqualIdentity(node, "AttributeType", "urn:schemas-microsoft-com:xml-data"))
            {
                attribute = node.GetAttribute("name");
                if ((attribute == null) || (attribute.Length == 0))
                {
                    throw ExceptionBuilder.MissingAttribute("Element", "name");
                }
                return(attribute);
            }
            attribute = node.GetAttribute("type");
            if ((attribute == null) || (attribute.Length == 0))
            {
                throw ExceptionBuilder.MissingAttribute("Element", "type");
            }
            return(attribute);
        }
 internal void HandleTypeNode(XmlElement typeNode, DataTable table, ArrayList tableChildren)
 {
     for (XmlNode node = typeNode.FirstChild; node != null; node = node.NextSibling)
     {
         if (node is XmlElement)
         {
             if (XMLSchema.FEqualIdentity(node, "element", "urn:schemas-microsoft-com:xml-data"))
             {
                 DataTable table2 = this.HandleTable((XmlElement)node);
                 if (table2 != null)
                 {
                     tableChildren.Add(table2);
                     continue;
                 }
             }
             if (XMLSchema.FEqualIdentity(node, "attribute", "urn:schemas-microsoft-com:xml-data") || XMLSchema.FEqualIdentity(node, "element", "urn:schemas-microsoft-com:xml-data"))
             {
                 this.HandleColumn((XmlElement)node, table);
             }
         }
     }
 }
        internal DataTable InstantiateTable(DataSet dataSet, XmlElement node, XmlElement typeNode)
        {
            DataTable table;
            string    name = "";
            XmlAttributeCollection attrs = node.Attributes;
            int       minOccurs          = 1;
            int       maxOccurs          = 1;
            string    str2          = null;
            ArrayList tableChildren = new ArrayList();

            if (attrs.Count > 0)
            {
                name  = this.GetInstanceName(node);
                table = dataSet.Tables.GetTable(name, this._schemaUri);
                if (table != null)
                {
                    return(table);
                }
            }
            table = new DataTable(XmlConvert.DecodeName(name))
            {
                Namespace = this._schemaUri
            };
            this.GetMinMax(node, ref minOccurs, ref maxOccurs);
            table.MinOccurs = minOccurs;
            table.MaxOccurs = maxOccurs;
            this._ds.Tables.Add(table);
            this.HandleTypeNode(typeNode, table, tableChildren);
            XMLSchema.SetProperties(table, attrs);
            if (str2 != null)
            {
                string[]     strArray    = str2.TrimEnd(null).Split(null);
                int          length      = strArray.Length;
                DataColumn[] columnArray = new DataColumn[length];
                for (int i = 0; i < length; i++)
                {
                    DataColumn column2 = table.Columns[strArray[i], this._schemaUri];
                    if (column2 == null)
                    {
                        throw ExceptionBuilder.ElementTypeNotFound(strArray[i]);
                    }
                    columnArray[i] = column2;
                }
                table.PrimaryKey = columnArray;
            }
            foreach (DataTable table2 in tableChildren)
            {
                DataRelation           relation       = null;
                DataRelationCollection childRelations = table.ChildRelations;
                for (int j = 0; j < childRelations.Count; j++)
                {
                    if (childRelations[j].Nested && (table2 == childRelations[j].ChildTable))
                    {
                        relation = childRelations[j];
                    }
                }
                if (relation == null)
                {
                    DataColumn parentKey   = table.AddUniqueKey();
                    DataColumn childColumn = table2.AddForeignKey(parentKey);
                    relation = new DataRelation(table.TableName + "_" + table2.TableName, parentKey, childColumn, true)
                    {
                        CheckMultipleNested = false,
                        Nested = true
                    };
                    table2.DataSet.Relations.Add(relation);
                    relation.CheckMultipleNested = true;
                }
            }
            return(table);
        }
        internal void HandleColumn(XmlElement node, DataTable table)
        {
            DataColumn column;
            Type       type;
            string     str3;
            string     str4;
            int        minOccurs = 0;
            int        maxOccurs = 1;

            node.GetAttribute("use");
            if (node.Attributes.Count > 0)
            {
                string str7 = node.GetAttribute("ref");
                if ((str7 != null) && (str7.Length > 0))
                {
                    return;
                }
                str3   = str4 = this.GetInstanceName(node);
                column = table.Columns[str4, this._schemaUri];
                if (column != null)
                {
                    if (column.ColumnMapping == MappingType.Attribute)
                    {
                        if (XMLSchema.FEqualIdentity(node, "attribute", "urn:schemas-microsoft-com:xml-data"))
                        {
                            throw ExceptionBuilder.DuplicateDeclaration(str3);
                        }
                    }
                    else if (XMLSchema.FEqualIdentity(node, "element", "urn:schemas-microsoft-com:xml-data"))
                    {
                        throw ExceptionBuilder.DuplicateDeclaration(str3);
                    }
                    str4 = XMLSchema.GenUniqueColumnName(str3, table);
                }
            }
            else
            {
                str3 = str4 = "";
            }
            XmlElement element = this.FindTypeNode(node);
            SimpleType type2   = null;

            if (element == null)
            {
                throw ExceptionBuilder.UndefinedDatatype(node.GetAttribute("type"));
            }
            string attribute = element.GetAttribute("type", "urn:schemas-microsoft-com:datatypes");
            string dtValues  = element.GetAttribute("values", "urn:schemas-microsoft-com:datatypes");

            if ((attribute == null) || (attribute.Length == 0))
            {
                attribute = "";
                type      = typeof(string);
            }
            else
            {
                type = this.ParseDataType(attribute, dtValues);
                if (attribute == "float")
                {
                    attribute = "";
                }
                if (attribute == "char")
                {
                    attribute = "";
                    type2     = SimpleType.CreateSimpleType(type);
                }
                if (attribute == "enumeration")
                {
                    attribute = "";
                    type2     = SimpleType.CreateEnumeratedType(dtValues);
                }
                if (attribute == "bin.base64")
                {
                    attribute = "";
                    type2     = SimpleType.CreateByteArrayType("base64");
                }
                if (attribute == "bin.hex")
                {
                    attribute = "";
                    type2     = SimpleType.CreateByteArrayType("hex");
                }
            }
            bool isAttribute = XMLSchema.FEqualIdentity(node, "attribute", "urn:schemas-microsoft-com:xml-data");

            this.GetMinMax(node, isAttribute, ref minOccurs, ref maxOccurs);
            string str2 = null;

            str2 = node.GetAttribute("default");
            bool flag2 = false;

            column = new DataColumn(XmlConvert.DecodeName(str4), type, null, isAttribute ? MappingType.Attribute : MappingType.Element);
            XMLSchema.SetProperties(column, node.Attributes);
            column.XmlDataType = attribute;
            column.SimpleType  = type2;
            column.AllowDBNull = (minOccurs == 0) || flag2;
            column.Namespace   = isAttribute ? string.Empty : this._schemaUri;
            if (node.Attributes != null)
            {
                for (int i = 0; i < node.Attributes.Count; i++)
                {
                    if ((node.Attributes[i].NamespaceURI == "urn:schemas-microsoft-com:xml-msdata") && (node.Attributes[i].LocalName == "Expression"))
                    {
                        column.Expression = node.Attributes[i].Value;
                        break;
                    }
                }
            }
            string str5 = node.GetAttribute("targetNamespace");

            if ((str5 != null) && (str5.Length > 0))
            {
                column.Namespace = str5;
            }
            table.Columns.Add(column);
            if ((str2 != null) && (str2.Length != 0))
            {
                try
                {
                    column.DefaultValue = SqlConvert.ChangeTypeForXML(str2, type);
                }
                catch (FormatException)
                {
                    throw ExceptionBuilder.CannotConvert(str2, type.FullName);
                }
            }
            for (XmlNode node2 = node.FirstChild; node2 != null; node2 = node2.NextSibling)
            {
                if (XMLSchema.FEqualIdentity(node2, "description", "urn:schemas-microsoft-com:xml-data"))
                {
                    column.Description(((XmlElement)node2).InnerText);
                }
            }
        }
Beispiel #9
0
        private void SelectSchemaElement(XMLSchema.openAttrs openAttrs, string nameSpace)
        {
            this.propertyGridSchemaObject.SelectedObject = openAttrs;
            ShowDocumentation(null);

            XMLSchema.annotated annotated = openAttrs as XMLSchema.annotated;
            if (annotated != null)
            {
                // Element documentation
                if (annotated.annotation != null)
                    ShowDocumentation(annotated.annotation);

                // Show the enumeration
                ShowEnumerate(annotated);

                // Attributes enumeration
                List<XSDAttribute> listAttributes = new List<XSDAttribute>();
                if (annotated is XMLSchema.element)
                {
                    XMLSchema.element element = annotated as XMLSchema.element;

                    if (element.Item is XMLSchema.complexType)
                    {
                        XMLSchema.complexType complexType = element.Item as XMLSchema.complexType;
                        listAttributes.AddRange(ShowAttributes(complexType, nameSpace));
                    }
                    else if (element.type != null)
                    {
                        //XSDObject xsdObject = this.schema.ElementsByName[QualifiedNameToFullName("type", element.type)] as XSDObject;
                        //if (xsdObject != null)
                        XSDObject xsdObject;
                        if (this.schema.ElementsByName.TryGetValue(QualifiedNameToFullName("type", element.type), out xsdObject) && xsdObject != null)
                        {
                            XMLSchema.annotated annotatedElement = xsdObject.Tag as XMLSchema.annotated;
                            if (annotatedElement is XMLSchema.complexType)
                            {
                                XMLSchema.complexType complexType = annotatedElement as XMLSchema.complexType;
                                listAttributes.AddRange(ShowAttributes(complexType, nameSpace));
                            }
                            else
                            {
                            }
                        }
                        else
                        {
                        }
                    }
                    else
                    {
                    }
                }
                else if (annotated is XMLSchema.complexType)
                {
                    XMLSchema.complexType complexType = annotated as XMLSchema.complexType;
                    listAttributes.AddRange(ShowAttributes(complexType, nameSpace));
                }
                //RC++ Original code
                //else
                //{
                //}

                //this.listViewAttributes.Items.Clear();
                //foreach (XSDAttribute attribute in listAttributes)
                //    this.listViewAttributes.Items.Add(new ListViewItem(new string[] { attribute.Name, attribute.Type, attribute.Use, attribute.DefaultValue })).Tag = attribute;
                //RC--

                //Adrian++
                //This part i modify
                else if (annotated is XMLSchema.simpleType)
                {
                    XMLSchema.attribute attr = new XMLSchema.attribute();
                    XMLSchema.localSimpleType def = new XMLSchema.localSimpleType();
                    def.Item = (annotated as XMLSchema.simpleType).Item;
                    attr.simpleType = def;
                    string type = "";
                    if (def.Item is XMLSchema.restriction) type = (def.Item as XMLSchema.restriction)[email protected];
                    XSDAttribute XSDattr = new XSDAttribute("filename", (annotated as XMLSchema.simpleType).name, "namespace", type, false, "", "", attr);
                    listAttributes.Add(XSDattr);

                }
                //This part i modify
                this.listViewAttributes.Items.Clear();
                listAttributes.Reverse();
                foreach (XSDAttribute attribute in listAttributes)
                {
                    string s = "";
                    //dgis fix github issue 2 (attribute.Tag == null ???)
                    if (attribute.Tag != null && attribute.Tag.simpleType != null && attribute.Tag.simpleType.Item is XMLSchema.restriction)
                    {
                        XMLSchema.restriction r = attribute.Tag.simpleType.Item as XMLSchema.restriction;
                        if (r.Items != null)
                        {
                            for (int i = 0; i < r.Items.Length; i++)
                            {
                                s += r.ItemsElementName[i].ToString() + "(" + r.Items[i].id + " " + r.Items[i].value + ");";
                            }
                        }
                    }

                    this.listViewAttributes.Items.Add(new ListViewItem(new string[] { attribute.Name, attribute.Type, attribute.Use, attribute.DefaultValue, s })).Tag = attribute;
                }
                //Adrian--
            }
        }
Beispiel #10
0
        private void ParseAttributeGroup(string nameSpace, List<XSDAttribute> listAttributes, XMLSchema.attributeGroup attributeGroup, bool isRestriction)
        {
            if (attributeGroup is XMLSchema.attributeGroupRef && attributeGroup.@ref != null)
            {
                object o = null;
                this.schema.AttributesByName.TryGetValue(QualifiedNameToFullName("attributeGroup", attributeGroup.@ref), out o);
                if (o is XSDAttributeGroup)
                {
                    XSDAttributeGroup xsdAttributeGroup = o as XSDAttributeGroup;
                    XMLSchema.attributeGroup attributeGroupInstance = xsdAttributeGroup.Tag;

                    foreach (XMLSchema.annotated annotated in attributeGroupInstance.Items)
                    {
                        if (annotated is XMLSchema.attribute)
                        {
                            ParseAttribute(nameSpace, listAttributes, annotated as XMLSchema.attribute, isRestriction);
                        }
                        else if (annotated is XMLSchema.attributeGroup)
                        {
                            ParseAttributeGroup(nameSpace, listAttributes, annotated as XMLSchema.attributeGroup, isRestriction);
                        }
                    }
                }
            }
            else
            {

            }
        }
Beispiel #11
0
        private XSDAttribute ParseAttribute(string nameSpace, List<XSDAttribute> listAttributes, XMLSchema.attribute attribute, bool isRestriction)
        {
            bool isReference = false;
            string filename = "";
            string name = attribute.name;
            string type = "";
            if (attribute.@ref != null)
            {
                object o = null;
                this.schema.AttributesByName.TryGetValue(QualifiedNameToFullName("attribute", attribute.@ref), out o);
                if (o is XSDAttribute)
                {
                    XSDAttribute xsdAttributeInstance = o as XSDAttribute;
                    XSDAttribute refXSDAttribute = ParseAttribute(nameSpace, listAttributes, xsdAttributeInstance.Tag, isRestriction);
                    if(refXSDAttribute != null)
                    {
                        // Override the "use" field with
                        refXSDAttribute.Use = attribute.use.ToString();
                    }
                    return null;
                }
                else // Reference not found!
                {
                    type = QualifiedNameToAttributeTypeName(attribute.@ref);
                    name = [email protected];
                    nameSpace = [email protected];
                    isReference = true;
                }
            }
            else if (attribute.type != null)
            {
                type = QualifiedNameToAttributeTypeName(attribute.type);
                nameSpace = attribute.type.Namespace;
            }
            else if (attribute.simpleType != null)
            {
                XMLSchema.simpleType simpleType = attribute.simpleType as XMLSchema.simpleType;
                if (simpleType.Item is XMLSchema.restriction)
                {
                    XMLSchema.restriction restriction = simpleType.Item as XMLSchema.restriction;
                    type = QualifiedNameToAttributeTypeName(restriction.@base);
                    nameSpace = [email protected];
                }
                else if (simpleType.Item is XMLSchema.list)
                {
                    XMLSchema.list list = simpleType.Item as XMLSchema.list;
                    type = QualifiedNameToAttributeTypeName(list.itemType);
                    nameSpace = list.itemType.Namespace;
                }
                else
                {
                }
            }
            else
            {

            }
            if (string.IsNullOrEmpty(attribute.name) && string.IsNullOrEmpty(name))
            {
            }
            if (isRestriction)
            {
                if (attribute.use == XMLSchema.attributeUse.prohibited)
                {
                    foreach (XSDAttribute xsdAttribute in listAttributes)
                    {
                        if (xsdAttribute.Name == name)
                        {
                            //listAttributes.Remove(xsdAttribute);
                            xsdAttribute.Use = attribute.use.ToString();
                            break;
                        }
                    }
                }
            }
            else
            {
                XSDAttribute xsdAttribute = new XSDAttribute(filename, name, nameSpace, type, isReference, attribute.@default, attribute.use.ToString(), attribute);
                listAttributes.Insert(0, xsdAttribute);
                return xsdAttribute;

            }
            return null;
        }
Beispiel #12
0
        void diagram_RequestAnyElement(DiagramItem diagramElement, out XMLSchema.element element, out string nameSpace)
        {
            element = null;
            nameSpace = "";

            //ElementsForm elementsForm = new ElementsForm();
            //elementsForm.Location = MousePosition; //diagramElement.Location //MousePosition;
            //elementsForm.ListBoxElements.Items.Clear();
            //elementsForm.ListBoxElements.Items.Insert(0, "(Cancel)");
            //foreach (XSDObject xsdObject in this.schema.ElementsByName.Values)
            //    if (xsdObject != null && xsdObject.Type == "element")
            //        elementsForm.ListBoxElements.Items.Add(xsdObject);
            //if (elementsForm.ShowDialog(this.diagramControl) == DialogResult.OK && (elementsForm.ListBoxElements.SelectedItem as XSDObject) != null)
            //{
            //    XSDObject xsdObject = elementsForm.ListBoxElements.SelectedItem as XSDObject;
            //    element = xsdObject.Tag as XMLSchema.element;
            //    nameSpace = xsdObject.NameSpace;
            //}
        }
Beispiel #13
0
        private void ShowEnumerate(XMLSchema.simpleType simpleType)
        {
            if (simpleType != null)
            {
                if (simpleType.Item != null)
                {
                    XMLSchema.restriction restriction = simpleType.Item as XMLSchema.restriction;
                    if (restriction != null && restriction.ItemsElementName != null)
                    {
                        for (int i = 0; i < restriction.ItemsElementName.Length; i++)
                        {
                            if (restriction.ItemsElementName[i] == XMLSchema.ItemsChoiceType.enumeration)
                            {
                                XMLSchema.facet facet = restriction.Items[i] as XMLSchema.facet;
                                if (facet != null)
                                    this.listViewEnumerate.Items.Add(facet.value).Tag = facet;
                            }
                        }

                        if (this.listViewEnumerate.Items.Count != 0)
                            this.listViewEnumerate.Columns[0].Width = -1;
                    }
                }
            }
        }
Beispiel #14
0
        private void ShowEnumerate(XMLSchema.annotated annotated)
        {
            this.listViewEnumerate.Items.Clear();

            if (annotated != null)
            {
                XMLSchema.element element = annotated as XMLSchema.element;
                if (element != null && element.type != null)
                {
                    //XSDObject xsdObject = this.schema.ElementsByName[QualifiedNameToFullName("type", element.type)] as XSDObject;
                    //if (xsdObject != null)
                    XSDObject xsdObject;
                    if (this.schema.ElementsByName.TryGetValue(QualifiedNameToFullName("type", element.type), out xsdObject) && xsdObject != null)
                    {
                        XMLSchema.annotated annotatedElement = xsdObject.Tag as XMLSchema.annotated;
                        if (annotatedElement is XMLSchema.simpleType)
                            ShowEnumerate(annotatedElement as XMLSchema.simpleType);
                    }
                }
            }
        }
Beispiel #15
0
        private void ShowDocumentation(XMLSchema.annotation annotation)
        {
            if (this.textBoxAnnotation == null)
            {
                //
                // webBrowserDocumentation
                //
                if(webBrowserSupported)
                {
                    this.webBrowserDocumentation = new System.Windows.Forms.WebBrowser();
                    this.webBrowserDocumentation.Dock = System.Windows.Forms.DockStyle.Fill;
                    this.webBrowserDocumentation.Location = new System.Drawing.Point(0, 0);
                    this.webBrowserDocumentation.MinimumSize = new System.Drawing.Size(20, 20);
                    this.webBrowserDocumentation.Name = "webBrowserDocumentation";
                    this.webBrowserDocumentation.Size = new System.Drawing.Size(214, 117);
                    this.webBrowserDocumentation.TabIndex = 1;
                    this.splitContainerDiagramElement.Panel2.Controls.Add(this.webBrowserDocumentation);
                }
                else
                    this.webBrowserDocumentation = null;
                //
                // textBoxAnnotation
                //
                this.textBoxAnnotation = new System.Windows.Forms.TextBox();
                this.textBoxAnnotation.Dock = System.Windows.Forms.DockStyle.Fill;
                this.textBoxAnnotation.Location = new System.Drawing.Point(0, 0);
                this.textBoxAnnotation.Multiline = true;
                this.textBoxAnnotation.Name = "textBoxAnnotation";
                this.textBoxAnnotation.ReadOnly = true;
                this.textBoxAnnotation.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
                this.textBoxAnnotation.Size = new System.Drawing.Size(214, 117);
                this.textBoxAnnotation.TabIndex = 0;
                this.splitContainerDiagramElement.Panel2.Controls.Add(this.textBoxAnnotation);
            }
            if (annotation == null)
            {
                this.textBoxAnnotation.Text = "";
                this.textBoxAnnotation.Visible = true;
                if (this.webBrowserDocumentation != null)
                    this.webBrowserDocumentation.Visible = false;

                return;
            }

            foreach (object o in annotation.Items)
            {
                if (o is XMLSchema.documentation)
                {
                    XMLSchema.documentation documentation = o as XMLSchema.documentation;
                    if (documentation.Any != null && documentation.Any.Length > 0 && documentation.Any[0].Value != null)
                    {
                        string text = documentation.Any[0].Value;
                        text = text.Replace("\n", " ");
                        text = text.Replace("\t", " ");
                        text = text.Replace("\r", "");
                        text = Regex.Replace(text, " +", " ");
                        text = text.Trim();

                        //text = text.Replace(, " ");

                        //text = text.Trim('\n', '\t', '\r', ' ');
                        //string[] textLines = text.Split(new char[] { '\n' });
                        //for (int i = 0; i < textLines.Length; i++)
                        //    textLines[i] = textLines[i].Trim('\n', '\t', '\r', ' ');
                        //text = string.Join("\r\n", textLines);
                        this.textBoxAnnotation.Text = text;
                        this.textBoxAnnotation.Visible = true;
                        if (this.webBrowserDocumentation != null)
                            this.webBrowserDocumentation.Visible = false;
                    }
                    else if (documentation.source != null)
                    {
                        if (this.webBrowserDocumentation != null)
                        {
                            this.textBoxAnnotation.Visible = false;
                            this.webBrowserDocumentation.Visible = true;
                            this.webBrowserDocumentation.Navigate(documentation.source);
                        }
                        else
                        {
                            this.textBoxAnnotation.Text = documentation.source;
                            this.textBoxAnnotation.Visible = true;
                        }
                    }
                    break;
                }
            }
        }
Beispiel #16
0
 private List<XSDAttribute> ShowAttributes(XMLSchema.complexType complexType, string nameSpace)
 {
     List<XSDAttribute> listAttributes = new List<XSDAttribute>();
     ParseComplexTypeAttributes(nameSpace, listAttributes, complexType, false);
     return listAttributes;
 }
Beispiel #17
0
        private void LoadRowData(DataRow row, XmlElement rowElement)
        {
            DataTable table = row.Table;

            if (this.FromInference)
            {
                table.Prefix = rowElement.Prefix;
            }
            Hashtable hashtable = new Hashtable();

            row.BeginEdit();
            XmlNode    firstChild     = rowElement.FirstChild;
            DataColumn textOnlyColumn = this.GetTextOnlyColumn(row);

            if (textOnlyColumn != null)
            {
                hashtable[textOnlyColumn] = textOnlyColumn;
                string valueForTextOnlyColums = this.GetValueForTextOnlyColums(firstChild);
                if (XMLSchema.GetBooleanAttribute(rowElement, "nil", "http://www.w3.org/2001/XMLSchema-instance", false) && ADP.IsEmpty(valueForTextOnlyColums))
                {
                    row[textOnlyColumn] = DBNull.Value;
                }
                else
                {
                    this.SetRowValueFromXmlText(row, textOnlyColumn, valueForTextOnlyColums);
                }
            }
            while ((firstChild != null) && (firstChild != rowElement))
            {
                if (firstChild.NodeType == XmlNodeType.Element)
                {
                    XmlElement node          = (XmlElement)firstChild;
                    object     schemaForNode = this.nodeToSchemaMap.GetSchemaForNode(node, this.FIgnoreNamespace(node));
                    if ((schemaForNode is DataTable) && this.FColumnElement(node))
                    {
                        schemaForNode = this.nodeToSchemaMap.GetColumnSchema(node, this.FIgnoreNamespace(node));
                    }
                    if ((schemaForNode == null) || (schemaForNode is DataColumn))
                    {
                        firstChild = node.FirstChild;
                        if ((schemaForNode != null) && (schemaForNode is DataColumn))
                        {
                            DataColumn col = (DataColumn)schemaForNode;
                            if (((col.Table == row.Table) && (col.ColumnMapping != MappingType.Attribute)) && (hashtable[col] == null))
                            {
                                hashtable[col] = col;
                                string str = this.GetValueForTextOnlyColums(firstChild);
                                if (XMLSchema.GetBooleanAttribute(node, "nil", "http://www.w3.org/2001/XMLSchema-instance", false) && ADP.IsEmpty(str))
                                {
                                    row[col] = DBNull.Value;
                                }
                                else
                                {
                                    this.SetRowValueFromXmlText(row, col, str);
                                }
                            }
                        }
                        else if ((schemaForNode == null) && (firstChild != null))
                        {
                            continue;
                        }
                        if (firstChild == null)
                        {
                            firstChild = node;
                        }
                    }
                }
                while ((firstChild != rowElement) && (firstChild.NextSibling == null))
                {
                    firstChild = firstChild.ParentNode;
                }
                if (firstChild != rowElement)
                {
                    firstChild = firstChild.NextSibling;
                }
            }
            foreach (XmlAttribute attribute in rowElement.Attributes)
            {
                object columnSchema = this.nodeToSchemaMap.GetColumnSchema(attribute, this.FIgnoreNamespace(attribute));
                if ((columnSchema != null) && (columnSchema is DataColumn))
                {
                    DataColumn column3 = (DataColumn)columnSchema;
                    if ((column3.ColumnMapping == MappingType.Attribute) && (hashtable[column3] == null))
                    {
                        hashtable[column3] = column3;
                        firstChild         = attribute.FirstChild;
                        this.SetRowValueFromXmlText(row, column3, this.GetInitialTextFromNodes(ref firstChild));
                    }
                }
            }
            foreach (DataColumn column in row.Table.Columns)
            {
                if ((hashtable[column] == null) && XmlToDatasetMap.IsMappedColumn(column))
                {
                    if (!column.AutoIncrement)
                    {
                        if (column.AllowDBNull)
                        {
                            row[column] = DBNull.Value;
                        }
                        else
                        {
                            row[column] = column.DefaultValue;
                        }
                    }
                    else
                    {
                        column.Init(row.tempRecord);
                    }
                }
            }
            row.EndEdit();
        }
Beispiel #18
0
 private void ParseComplexTypeAttributes(string nameSpace, List<XSDAttribute> listAttributes, XMLSchema.complexType complexType, bool isRestriction)
 {
     if (complexType.ItemsElementName != null)
     {
         for (int i = 0; i < complexType.ItemsElementName.Length; i++)
         {
             switch (complexType.ItemsElementName[i])
             {
                 case XMLSchema.ItemsChoiceType4.attribute:
                     {
                         XMLSchema.attribute attribute = complexType.Items[i] as XMLSchema.attribute;
                         ParseAttribute(nameSpace, listAttributes, attribute, false);
                     }
                     break;
                 case XMLSchema.ItemsChoiceType4.attributeGroup:
                     {
                         XMLSchema.attributeGroup attributeGroup = complexType.Items[i] as XMLSchema.attributeGroup;
                         ParseAttributeGroup(nameSpace, listAttributes, attributeGroup, false);
                     }
                     break;
                 case XMLSchema.ItemsChoiceType4.anyAttribute:
                     XMLSchema.wildcard wildcard = complexType.Items[i] as XMLSchema.wildcard;
                     XSDAttribute xsdAttribute = new XSDAttribute("", "*", wildcard.@namespace, "", false, null, null, null);
                     listAttributes.Add(xsdAttribute);
                     break;
                 case XMLSchema.ItemsChoiceType4.simpleContent:
                 case XMLSchema.ItemsChoiceType4.complexContent:
                     XMLSchema.annotated annotatedContent = null;
                     if (complexType.Items[i] is XMLSchema.complexContent)
                     {
                         XMLSchema.complexContent complexContent = complexType.Items[i] as XMLSchema.complexContent;
                         annotatedContent = complexContent.Item;
                     }
                     else if (complexType.Items[i] is XMLSchema.simpleContent)
                     {
                         XMLSchema.simpleContent simpleContent = complexType.Items[i] as XMLSchema.simpleContent;
                         annotatedContent = simpleContent.Item;
                     }
                     if (annotatedContent is XMLSchema.extensionType)
                     {
                         XMLSchema.extensionType extensionType = annotatedContent as XMLSchema.extensionType;
                         //XSDObject xsdExtensionType = this.schema.ElementsByName[QualifiedNameToFullName("type", extensionType.@base)] as XSDObject;
                         //if (xsdExtensionType != null)
                         XSDObject xsdExtensionType;
                         if (this.schema.ElementsByName.TryGetValue(QualifiedNameToFullName("type", extensionType.@base), out xsdExtensionType) && xsdExtensionType != null)
                         {
                             XMLSchema.annotated annotatedExtension = xsdExtensionType.Tag as XMLSchema.annotated;
                             if (annotatedExtension != null)
                             {
                                 if (annotatedExtension is XMLSchema.complexType)
                                     ParseComplexTypeAttributes([email protected], listAttributes, annotatedExtension as XMLSchema.complexType, false);
                             }
                         }
                         if (extensionType.Items != null)
                         {
                             foreach (XMLSchema.annotated annotated in extensionType.Items)
                             {
                                 if (annotated is XMLSchema.attribute)
                                 {
                                     ParseAttribute(nameSpace, listAttributes, annotated as XMLSchema.attribute, false);
                                 }
                                 else if (annotated is XMLSchema.attributeGroup)
                                 {
                                     ParseAttributeGroup(nameSpace, listAttributes, annotated as XMLSchema.attributeGroup, false);
                                 }
                             }
                         }
                     }
                     else if (annotatedContent is XMLSchema.restrictionType)
                     {
                         XMLSchema.restrictionType restrictionType = annotatedContent as XMLSchema.restrictionType;
                         //XSDObject xsdRestrictionType = this.schema.ElementsByName[QualifiedNameToFullName("type", restrictionType.@base)] as XSDObject;
                         //if (xsdRestrictionType != null)
                         XSDObject xsdRestrictionType;
                         if (this.schema.ElementsByName.TryGetValue(QualifiedNameToFullName("type", restrictionType.@base), out xsdRestrictionType) && xsdRestrictionType != null)
                         {
                             XMLSchema.annotated annotatedRestriction = xsdRestrictionType.Tag as XMLSchema.annotated;
                             if (annotatedRestriction != null)
                             {
                                 if (annotatedRestriction is XMLSchema.complexType)
                                     ParseComplexTypeAttributes([email protected], listAttributes, annotatedRestriction as XMLSchema.complexType, false);
                             }
                         }
                         if (restrictionType.Items1 != null)
                         {
                             foreach (XMLSchema.annotated annotated in restrictionType.Items1)
                             {
                                 if (annotated is XMLSchema.attribute)
                                 {
                                     ParseAttribute(nameSpace, listAttributes, annotated as XMLSchema.attribute, true);
                                 }
                                 else if (annotated is XMLSchema.attributeGroup)
                                 {
                                     ParseAttributeGroup(nameSpace, listAttributes, annotated as XMLSchema.attributeGroup, true);
                                 }
                             }
                         }
                     }
                     break;
             }
         }
     }
     else
     {
     }
 }