コード例 #1
0
ファイル: XmlParser.cs プロジェクト: l4es/ComputerVision
        IEnumerable <XObject> CreateProtoSimpleContent(XmlSchemaSimpleContent simpleContent, XmlSchemaType baseType)
        {
            var content = simpleContent.Content as XmlSchemaSimpleContentExtension;

            if (baseType != null)
            {
                foreach (var x in CreateProtoAnyType(baseType))
                {
                    yield return(x);
                }
            }

            foreach (XmlSchemaAttribute attr in content.Attributes)
            {
                if (attr.Use == XmlSchemaUse.Required)
                {
                    var    name   = attr.QualifiedName.ToXName();
                    string retres = null;
                    if (attr.FixedValue != null)
                    {
                        throw new Exception("not implemented");
                    }
                    else if (attr.DefaultValue != null)
                    {
                        retres = attr.DefaultValue;
                    }
                    else
                    {
                        retres = CreateProtoSimpleType(attr.AttributeSchemaType);
                    }
                    yield return(new XAttribute(name, retres));
                }
            }
        }
コード例 #2
0
ファイル: SampleGenerator.cs プロジェクト: shachaoshu/WsdlUI
        string FindBuiltInType(XmlQualifiedName qname)
        {
            if (qname.Namespace == XmlSchema.Namespace)
            {
                return(qname.Name);
            }

            XmlSchemaComplexType ct = FindComplexTyype(qname);

            if (ct != null)
            {
                XmlSchemaSimpleContent sc = ct.ContentModel as XmlSchemaSimpleContent;
                if (sc == null)
                {
                    throw new InvalidOperationException("Invalid schema");
                }
                return(FindBuiltInType(GetContentBaseType(sc.Content)));
            }

            XmlSchemaSimpleType st = (XmlSchemaSimpleType)schemas.Find(qname, typeof(XmlSchemaSimpleType));

            if (st != null)
            {
                return(FindBuiltInType(st));
            }

            throw new InvalidOperationException("Definition of type " + qname + " not found");
        }
コード例 #3
0
        private static void RemoveElementsAndAttributesFromComplexType(XmlSchemaComplexType complexType, UpccModelXsdTypes remainingXsdTypes)
        {
            if (complexType.Particle is XmlSchemaGroupBase)
            {
                RemoveElementsFromXsdGroup((XmlSchemaGroupBase)complexType.Particle, complexType.QualifiedName.Name, remainingXsdTypes);
            }

            if (complexType.ContentModel is XmlSchemaSimpleContent)
            {
                XmlSchemaSimpleContent contentModel = (XmlSchemaSimpleContent)complexType.ContentModel;

                if (contentModel.Content is XmlSchemaSimpleContentExtension)
                {
                    RemoveAttributesFromComplexType(((XmlSchemaSimpleContentExtension)contentModel.Content).Attributes, complexType.QualifiedName.Name, remainingXsdTypes);
                }
                else if (contentModel.Content is XmlSchemaSimpleContentRestriction)
                {
                    RemoveAttributesFromComplexType(((XmlSchemaSimpleContentRestriction)contentModel.Content).Attributes, complexType.QualifiedName.Name, remainingXsdTypes);
                }
            }

            RemoveAttributesFromComplexType(complexType.Attributes, complexType.QualifiedName.Name, remainingXsdTypes);

            if (complexType.BaseXmlSchemaType != null)
            {
                if (complexType.BaseXmlSchemaType is XmlSchemaComplexType)
                {
                    RemoveElementsAndAttributesFromComplexType((XmlSchemaComplexType)complexType.BaseXmlSchemaType, remainingXsdTypes);
                }
            }
        }
コード例 #4
0
        private DataSchemaNode MakeSchemaElement(XmlSchemaElement element)
        {
            string typeName = (string)null;
            Type   type     = (Type)null;

            if (element.ElementSchemaType != null && element.ElementSchemaType.Datatype != null)
            {
                type = element.ElementSchemaType.Datatype.ValueType;
            }
            else if (element.SchemaTypeName != (XmlQualifiedName)null && element.SchemaTypeName.Name != string.Empty)
            {
                typeName = element.SchemaTypeName.Name;
            }
            if (type != (Type)null)
            {
                type     = this.ConvertType(type);
                typeName = type.Name;
            }
            string               str               = this.ProcessQualifiedName(element.QualifiedName);
            SchemaNodeTypes      nodeType          = element.MaxOccurs > new Decimal(1) ? SchemaNodeTypes.Collection : SchemaNodeTypes.Property;
            DataSchemaNode       schemaNode        = new DataSchemaNode(str, str, nodeType, typeName, type, (IDataSchemaNodeDelayLoader)null);
            XmlSchemaComplexType schemaComplexType = element.ElementSchemaType as XmlSchemaComplexType;

            if (schemaComplexType != null)
            {
                XmlSchemaObjectCollection objectCollection = (XmlSchemaObjectCollection)null;
                if (schemaComplexType.Attributes.Count > 0)
                {
                    objectCollection = schemaComplexType.Attributes;
                }
                else
                {
                    XmlSchemaSimpleContent schemaSimpleContent = schemaComplexType.ContentModel as XmlSchemaSimpleContent;
                    if (schemaSimpleContent != null)
                    {
                        XmlSchemaSimpleContentExtension contentExtension = schemaSimpleContent.Content as XmlSchemaSimpleContentExtension;
                        if (contentExtension != null)
                        {
                            objectCollection = contentExtension.Attributes;
                        }
                    }
                }
                if (objectCollection != null)
                {
                    foreach (XmlSchemaAttribute attribute in objectCollection)
                    {
                        DataSchemaNode child = this.MakeSchemaAttribute(attribute);
                        schemaNode.AddChild(child);
                    }
                }
                XmlSchemaGroupBase xmlSchemaGroupBase = schemaComplexType.Particle as XmlSchemaGroupBase;
                if (xmlSchemaGroupBase != null)
                {
                    this.ProcessSchemaItems(schemaNode, xmlSchemaGroupBase.Items);
                }
            }
            return(schemaNode);
        }
コード例 #5
0
        /*
         * const string SchemaString =
         * "<xsd:schema xmlns:xsd='" + XmlSchema.Namespace + "'>" +
         * "    <xsd:complexType name='XPathMessageFilter'>" +
         * "      <xsd:sequence>" +
         * "        <xsd:element name='" + InnerElem + "' >" +
         * "          <xsd:complexType>" +
         * "            <xsd:simpleContent>" +
         * "              <xsd:extension base='xsd:string'>" +
         * "                <xsd:attribute name='" + DialectAttr + "' type='xsd:string' use='optional'/>" +
         * "              </xsd:extension>" +
         * "            </xsd:simpleContent>" +
         * "          </xsd:complexType>" +
         * "        </xsd:element>" +
         * "      </xsd:sequence>" +
         * "      <xsd:attribute name='" + NodeQuotaAttr + "' type='xsd:int' use='optional'/>" +
         * "    </xsd:complexType>" +
         * "</xsd:schema>";
         *
         * static XPathMessageFilter()
         * {
         *  XPathMessageFilter.schema = XmlSchema.Read(new StringReader(SchemaString), null);
         * }
         */

        static XmlSchemaComplexType CreateOuterType()
        {
            // Dialect attribute
            XmlSchemaAttribute dAttr = new XmlSchemaAttribute();

            dAttr.Name           = DialectAttr;
            dAttr.SchemaTypeName = new XmlQualifiedName("string", XmlSchema.Namespace);
            dAttr.Use            = XmlSchemaUse.Optional;

            // Inner extension
            XmlSchemaSimpleContentExtension innerExt = new XmlSchemaSimpleContentExtension();

            innerExt.BaseTypeName = new XmlQualifiedName("string", XmlSchema.Namespace);
            innerExt.Attributes.Add(dAttr);

            // Inner content
            XmlSchemaSimpleContent innerContent = new XmlSchemaSimpleContent();

            innerContent.Content = innerExt;

            // Inner complexType
            XmlSchemaComplexType innerType = new XmlSchemaComplexType();

            innerType.ContentModel = innerContent;

            // Inner element
            XmlSchemaElement element = new XmlSchemaElement();

            element.Name       = InnerElem;
            element.SchemaType = innerType;

            // Seq around innner elem
            XmlSchemaSequence sequence = new XmlSchemaSequence();

            sequence.Items.Add(element);

            // NodeQuota attribute
            XmlSchemaAttribute nqAttr = new XmlSchemaAttribute();

            nqAttr.Name           = NodeQuotaAttr;
            nqAttr.SchemaTypeName = new XmlQualifiedName("int", XmlSchema.Namespace);
            nqAttr.Use            = XmlSchemaUse.Optional;

            // anyAttribute on outer type
            // any namespace is the default
            XmlSchemaAnyAttribute anyAttr = new XmlSchemaAnyAttribute();

            // Outer type
            XmlSchemaComplexType outerType = new XmlSchemaComplexType();

            outerType.Name     = OuterTypeName;
            outerType.Particle = sequence;
            outerType.Attributes.Add(nqAttr);
            outerType.AnyAttribute = anyAttr;

            return(outerType);
        }
コード例 #6
0
        void GetAttributeCompletionData(XmlCompletionDataList data, XmlSchemaSimpleContent simpleContent)
        {
            var extension = simpleContent.Content as XmlSchemaSimpleContentExtension;

            if (extension != null)
            {
                GetAttributeCompletionData(data, extension);
            }
        }
コード例 #7
0
        private static IEnumerable <XmlSchemaObject> GetChildElementsAndAttributesDefinedByXsdType(XmlSchemaType xmlSchemaType)
        {
            List <XmlSchemaObject> myChildren = new List <XmlSchemaObject>();

            if (xmlSchemaType is XmlSchemaComplexType)
            {
                XmlSchemaComplexType complexType = (XmlSchemaComplexType)xmlSchemaType;

                if (complexType.Particle is XmlSchemaGroupBase)
                {
                    myChildren.AddRange(GetChildElementsAndAttributesDefinedByXsdGroup((XmlSchemaGroupBase)complexType.Particle));
                }

                if (complexType.ContentModel is XmlSchemaSimpleContent)
                {
                    XmlSchemaSimpleContent contentModel = (XmlSchemaSimpleContent)complexType.ContentModel;

                    if (contentModel.Content is XmlSchemaSimpleContentExtension)
                    {
                        foreach (XmlSchemaObject attribute in ((XmlSchemaSimpleContentExtension)contentModel.Content).Attributes)
                        {
                            myChildren.Add(attribute);
                        }
                    }
                    else if (contentModel.Content is XmlSchemaSimpleContentRestriction)
                    {
                        foreach (XmlSchemaObject attribute in ((XmlSchemaSimpleContentRestriction)contentModel.Content).Attributes)
                        {
                            myChildren.Add(attribute);
                        }
                    }
                }

                foreach (XmlSchemaAttribute attribute in complexType.Attributes)
                {
                    myChildren.Add(attribute);
                }

                foreach (XmlSchemaObject child in myChildren)
                {
                    yield return(child);
                }
            }

            if (xmlSchemaType.BaseXmlSchemaType != null)
            {
                List <XmlSchemaObject> x = new List <XmlSchemaObject>(GetChildElementsAndAttributesDefinedByXsdType(xmlSchemaType.BaseXmlSchemaType));
                foreach (var child in x)
                {
                    if (!ContainsXsdObject(myChildren, child))
                    {
                        yield return(child);
                    }
                }
            }
        }
コード例 #8
0
        void CheckForSimpleRestriction()
        {
            XmlSchemaComplexType   ct = this.ComplexType;
            XmlSchemaSimpleContent sc = ct.ContentModel as XmlSchemaSimpleContent;

            if (sc != null)
            {
                this.simpleSubElements.Add(this.element);
            }
        }
コード例 #9
0
        XmlQualifiedName ExportStructMapping(StructMapping mapping, string ns)
        {
            if (mapping.TypeDesc.IsRoot)
            {
                needToExportRoot = true;
                return(XmlQualifiedName.Empty);
            }
            XmlSchemaComplexType type = (XmlSchemaComplexType)types[mapping];

            if (type == null)
            {
                if (!mapping.IncludeInSchema)
                {
                    throw new InvalidOperationException(Res.GetString(Res.XmlCannotIncludeInSchema, mapping.TypeDesc.Name));
                }
                CheckForDuplicateType(mapping.TypeName, mapping.Namespace);
                type      = new XmlSchemaComplexType();
                type.Name = mapping.TypeName;
                types.Add(mapping, type);
                AddSchemaItem(type, mapping.Namespace, ns);
                type.IsAbstract = mapping.TypeDesc.IsAbstract;

                if (mapping.BaseMapping != null && mapping.BaseMapping.IncludeInSchema)
                {
                    if (mapping.HasSimpleContent)
                    {
                        XmlSchemaSimpleContent          model     = new XmlSchemaSimpleContent();
                        XmlSchemaSimpleContentExtension extension = new XmlSchemaSimpleContentExtension();
                        extension.BaseTypeName = ExportStructMapping(mapping.BaseMapping, mapping.Namespace);
                        model.Content          = extension;
                        type.ContentModel      = model;
                    }
                    else
                    {
                        XmlSchemaComplexContentExtension extension = new XmlSchemaComplexContentExtension();
                        extension.BaseTypeName = ExportStructMapping(mapping.BaseMapping, mapping.Namespace);
                        XmlSchemaComplexContent model = new XmlSchemaComplexContent();
                        model.Content     = extension;
                        model.IsMixed     = XmlSchemaImporter.IsMixed((XmlSchemaComplexType)types[mapping.BaseMapping]);
                        type.ContentModel = model;
                    }
                }
                ExportTypeMembers(type, mapping.Members, mapping.TypeName, mapping.Namespace, mapping.HasSimpleContent);
                ExportDerivedMappings(mapping);
                if (mapping.XmlnsMember != null)
                {
                    AddXmlnsAnnotation(type, mapping.XmlnsMember.Name);
                }
            }
            else
            {
                AddSchemaImport(mapping.Namespace, ns);
            }
            return(new XmlQualifiedName(type.Name, mapping.Namespace));
        }
コード例 #10
0
ファイル: SampleGenerator.cs プロジェクト: shachaoshu/WsdlUI
        void WriteSimpleContent(XmlTextWriter xtw, XmlSchemaSimpleContent content)
        {
            XmlSchemaSimpleContentExtension ext = content.Content as XmlSchemaSimpleContentExtension;

            if (ext != null)
            {
                WriteAttributes(xtw, ext.Attributes, ext.AnyAttribute);
            }

            XmlQualifiedName qname = GetContentBaseType(content.Content);

            xtw.WriteString(GetLiteral(FindBuiltInType(qname)));
        }
コード例 #11
0
    public static void Main()
    {
        XmlSchema schema = new XmlSchema();

        // <xs:element name="generalPrice">
        XmlSchemaElement generalPrice = new XmlSchemaElement();

        generalPrice.Name = "generalPrice";

        // <xs:complexType>
        XmlSchemaComplexType ct = new XmlSchemaComplexType();

        // <xs:simpleContent>
        XmlSchemaSimpleContent simpleContent = new XmlSchemaSimpleContent();

        // <xs:extension base="xs:decimal">
        XmlSchemaSimpleContentExtension simpleContent_extension = new XmlSchemaSimpleContentExtension();

        simpleContent_extension.BaseTypeName = new XmlQualifiedName("decimal", "http://www.w3.org/2001/XMLSchema");

        // <xs:attribute name="currency" type="xs:string" />
        XmlSchemaAttribute currency = new XmlSchemaAttribute();

        currency.Name           = "currency";
        currency.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");
        simpleContent_extension.Attributes.Add(currency);

        simpleContent.Content   = simpleContent_extension;
        ct.ContentModel         = simpleContent;
        generalPrice.SchemaType = ct;

        schema.Items.Add(generalPrice);

        XmlSchemaSet schemaSet = new XmlSchemaSet();

        schemaSet.ValidationEventHandler += new ValidationEventHandler(ValidationCallbackOne);
        schemaSet.Add(schema);
        schemaSet.Compile();

        XmlSchema compiledSchema = null;

        foreach (XmlSchema schema1 in schemaSet.Schemas())
        {
            compiledSchema = schema1;
        }

        XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable());

        nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema");
        compiledSchema.Write(Console.Out, nsmgr);
    }
コード例 #12
0
 protected virtual void WriteContentModel(XmlSchemaComplexType type,
                                          XmlWriter writer)
 {
     if (type.ContentModel != null)
     {
         if (type.ContentModel is XmlSchemaSimpleContent)
         {
             XmlSchemaSimpleContent            content     = type.ContentModel as XmlSchemaSimpleContent;
             XmlSchemaSimpleContentRestriction restriction =
                 content.Content as XmlSchemaSimpleContentRestriction;
             if (restriction != null)
             {
                 WriteExampleValue(type.QualifiedName.Name, restriction.BaseType, writer);
             }
             else
             {
                 XmlSchemaSimpleContentExtension extension =
                     content.Content as XmlSchemaSimpleContentExtension;
             }
         }
         else if (type.Particle == null && type.ContentModel is XmlSchemaComplexContent)
         {
             XmlSchemaComplexContent complexContent =
                 type.ContentModel as XmlSchemaComplexContent;
             XmlSchemaComplexContentExtension ext =
                 type.ContentModel.Content as XmlSchemaComplexContentExtension;
             if (type.BaseXmlSchemaType != null)
             {
                 XmlSchemaComplexType baseType =
                     type.BaseXmlSchemaType as XmlSchemaComplexType;
                 if (baseType != null)
                 {
                     WriteContentModel(baseType, writer);
                 }
             }
             if (ext != null && ext.Particle != null)
             {
                 if (ext.BaseTypeName != null)
                 {
                     object ao = Schema.Elements[ext.BaseTypeName];
                     //string data = ao.ToString();
                 }
                 WriteExampleParticle(ext.Particle, writer);
             }
         }
     }
     if (type.Particle != null)
     {
         WriteExampleParticle(type.Particle, writer);
     }
 }
コード例 #13
0
    public static void Main()
    {
        XmlSchema schema = new XmlSchema();

        // <element name="stringElementWithAnyAttribute">
        XmlSchemaElement element = new XmlSchemaElement();

        schema.Items.Add(element);
        element.Name = "stringElementWithAnyAttribute";

        // <complexType>
        XmlSchemaComplexType complexType = new XmlSchemaComplexType();

        element.SchemaType = complexType;

        // <simpleContent>
        XmlSchemaSimpleContent simpleContent = new XmlSchemaSimpleContent();

        complexType.ContentModel = simpleContent;

        // <extension base="xs:string">
        XmlSchemaSimpleContentExtension extension = new XmlSchemaSimpleContentExtension();

        simpleContent.Content  = extension;
        extension.BaseTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");

        // <anyAttribute namespace="##targetNamespace"/>
        XmlSchemaAnyAttribute anyAttribute = new XmlSchemaAnyAttribute();

        extension.AnyAttribute = anyAttribute;
        anyAttribute.Namespace = "##targetNamespace";

        XmlSchemaSet schemaSet = new XmlSchemaSet();

        schemaSet.ValidationEventHandler += new ValidationEventHandler(ValidationCallbackOne);
        schemaSet.Add(schema);
        schemaSet.Compile();

        XmlSchema compiledSchema = null;

        foreach (XmlSchema schema1 in schemaSet.Schemas())
        {
            compiledSchema = schema1;
        }

        XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable());

        nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema");
        compiledSchema.Write(Console.Out, nsmgr);
    }
        void Parse_SimpleContent(TreeNode inner, XmlSchemaSimpleContent content)
        {
            XmlSchemaSimpleContentExtension   ext = content.Content as XmlSchemaSimpleContentExtension;
            XmlSchemaSimpleContentRestriction rst = content.Content as XmlSchemaSimpleContentRestriction;

            if (ext != null)
            {
                Add_Attributes(inner, ext.Attributes, ext.AnyAttribute);
            }

            XmlQualifiedName qname = GetContentBaseType(content.Content);
            TreeNode         node  = new TreeNode((GetBuiltInTypeName(qname)));

            inner.Nodes.Add(node);
        }
コード例 #15
0
ファイル: Program.cs プロジェクト: samhithavr1/Codeproject
        private static string ProcessSchemaSimpleContent(XmlSchemaSimpleContent schemaContent)
        {
            StringBuilder result = new StringBuilder();

            result.Append(ProcessAnnotation(schemaContent.Annotation));

            if (schemaContent.Content is XmlSchemaSimpleContentExtension)
            {
                result.Append(ProcessSchemaSimpleContentExtension((XmlSchemaSimpleContentExtension)schemaContent.Content));
            }
            else
            {
                result.AppendLine(string.Format("Unsupport content extension: {0}", schemaContent.Content));
            }
            return(result.ToString());
        }
コード例 #16
0
 public void GetExpectedValues(XmlSchemaType si, XmlIntellisenseList list)
 {
     if (si == null)
     {
         return;
     }
     if (si is XmlSchemaSimpleType)
     {
         XmlSchemaSimpleType st = (XmlSchemaSimpleType)si;
         GetExpectedValues(st, list);
     }
     else if (si is XmlSchemaComplexType)
     {
         XmlSchemaComplexType ct = (XmlSchemaComplexType)si;
         if (ct.ContentModel is XmlSchemaComplexContent)
         {
             XmlSchemaComplexContent cc = (XmlSchemaComplexContent)ct.ContentModel;
             if (cc.Content is XmlSchemaComplexContentExtension)
             {
                 XmlSchemaComplexContentExtension ce = (XmlSchemaComplexContentExtension)cc.Content;
                 GetExpectedValues(GetTypeInfo(ce.BaseTypeName), list);
             }
             else if (cc.Content is XmlSchemaComplexContentRestriction)
             {
                 XmlSchemaComplexContentRestriction cr = (XmlSchemaComplexContentRestriction)cc.Content;
                 GetExpectedValues(GetTypeInfo(cr.BaseTypeName), list);
             }
         }
         else if (ct.ContentModel is XmlSchemaSimpleContent)
         {
             XmlSchemaSimpleContent sc = (XmlSchemaSimpleContent)ct.ContentModel;
             if (sc.Content is XmlSchemaSimpleContentExtension)
             {
                 XmlSchemaSimpleContentExtension ce = (XmlSchemaSimpleContentExtension)sc.Content;
                 GetExpectedValues(GetTypeInfo(ce.BaseTypeName), list);
             }
             else if (sc.Content is XmlSchemaSimpleContentRestriction)
             {
                 XmlSchemaSimpleContentRestriction cr = (XmlSchemaSimpleContentRestriction)sc.Content;
                 GetExpectedValues(GetTypeInfo(cr.BaseTypeName), list);
             }
         }
     }
     return;
 }
コード例 #17
0
        private static void AddElementAndType(XmlSchema schema, string baseXsdType, string ns)
        {
            var item = new XmlSchemaElement();

            item.Name           = baseXsdType;
            item.SchemaTypeName = new XmlQualifiedName(baseXsdType, ns);
            schema.Items.Add(item);
            var type = new XmlSchemaComplexType();

            type.Name = baseXsdType;
            var content = new XmlSchemaSimpleContent();

            type.ContentModel = content;
            var extension = new XmlSchemaSimpleContentExtension();

            extension.BaseTypeName = new XmlQualifiedName(baseXsdType, "http://www.w3.org/2001/XMLSchema");
            content.Content        = extension;
            schema.Items.Add(type);
        }
コード例 #18
0
        private void LoadXmlSchemaComplexType(XmlSchemaComplexType ctype)
        {
            if (ctype == null)
            {
                return;
            }
            LoadXmlSchemaObjectCollection(ctype.Attributes);
            XmlSchemaComplexContent content = ctype.ContentModel as XmlSchemaComplexContent;

            if (content != null)
            {
                XmlSchemaComplexContentExtension cext = content.Content as XmlSchemaComplexContentExtension;
                if (cext != null)
                {
                    LoadXmlSchemaObjectCollection(cext.Attributes);
                    if (cext.BaseTypeName != null)
                    {
                        string typeName = cext.BaseTypeName.Name;
                        if (xcontoler._complexTypes.ContainsKey(typeName))
                        {
                            LoadXmlSchemaComplexType(xcontoler._complexTypes[typeName]);
                        }
                    }
                    LoadXmlSchemaObject(cext.Particle);
                }
            }
            else
            {
                XmlSchemaSimpleContent scontent = ctype.ContentModel as XmlSchemaSimpleContent;
                if (scontent != null)
                {
                    XmlSchemaSimpleContentExtension sext = scontent.Content as XmlSchemaSimpleContentExtension;
                    if (sext != null)
                    {
                        LoadXmlSchemaObjectCollection(sext.Attributes);
                    }
                }
                else
                {
                    LoadXmlSchemaObject(ctype.Particle);
                }
            }
        }
コード例 #19
0
ファイル: Wsdl.cs プロジェクト: paymedia/WebServiceStudio
        private static void AddElementAndType(XmlSchema schema, string baseXsdType, string ns)
        {
            XmlSchemaElement element1 = new XmlSchemaElement();

            element1.Name           = baseXsdType;
            element1.SchemaTypeName = new XmlQualifiedName(baseXsdType, ns);
            schema.Items.Add(element1);
            XmlSchemaComplexType type1 = new XmlSchemaComplexType();

            type1.Name = baseXsdType;
            XmlSchemaSimpleContent content1 = new XmlSchemaSimpleContent();

            type1.ContentModel = content1;
            XmlSchemaSimpleContentExtension extension1 = new XmlSchemaSimpleContentExtension();

            extension1.BaseTypeName = new XmlQualifiedName(baseXsdType, "http://www.w3.org/2001/XMLSchema");
            content1.Content        = extension1;
            schema.Items.Add(type1);
        }
コード例 #20
0
        /// <summary>
        /// Creates the schema type representing a property type
        /// </summary>
        /// <returns>Type definition for a property</returns>
        static XmlSchemaType CreatePropertyType()
        {
            XmlSchemaSimpleContentExtension Extension = new XmlSchemaSimpleContentExtension();

            Extension.BaseTypeName = StringTypeName;
            Extension.Attributes.Add(CreateSchemaAttribute("Name", ScriptSchemaStandardType.Name, XmlSchemaUse.Required));
            Extension.Attributes.Add(CreateSchemaAttribute("Value", StringTypeName, XmlSchemaUse.Optional));
            Extension.Attributes.Add(CreateSchemaAttribute("If", ScriptSchemaStandardType.BalancedString, XmlSchemaUse.Optional));

            XmlSchemaSimpleContent ContentModel = new XmlSchemaSimpleContent();

            ContentModel.Content = Extension;

            XmlSchemaComplexType PropertyType = new XmlSchemaComplexType();

            PropertyType.Name         = GetTypeName(ScriptSchemaStandardType.Property);
            PropertyType.ContentModel = ContentModel;
            return(PropertyType);
        }
コード例 #21
0
 private void Write36_XmlSchemaSimpleContent(XmlSchemaSimpleContent o)
 {
     if (o != null)
     {
         this.WriteStartElement("simpleContent");
         this.WriteAttribute("id", "", o.Id);
         this.WriteAttributes(o.UnhandledAttributes, o);
         this.Write5_XmlSchemaAnnotation(o.Annotation);
         if (o.Content is XmlSchemaSimpleContentRestriction)
         {
             this.Write40_XmlSchemaSimpleContentRestriction((XmlSchemaSimpleContentRestriction)o.Content);
         }
         else if (o.Content is XmlSchemaSimpleContentExtension)
         {
             this.Write38_XmlSchemaSimpleContentExtension((XmlSchemaSimpleContentExtension)o.Content);
         }
         this.WriteEndElement();
     }
 }
コード例 #22
0
        void Write36_XmlSchemaSimpleContent(XmlSchemaSimpleContent o)
        {
            if ((object)o == null)
            {
                return;
            }
            WriteStartElement("simpleContent");

            WriteAttribute(@"id", @"", ((System.String)o.@Id));
            WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
            Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
            if (o.@Content is XmlSchemaSimpleContentRestriction)
            {
                Write40_XmlSchemaSimpleContentRestriction((XmlSchemaSimpleContentRestriction)o.@Content);
            }
            else if (o.@Content is XmlSchemaSimpleContentExtension)
            {
                Write38_XmlSchemaSimpleContentExtension((XmlSchemaSimpleContentExtension)o.@Content);
            }
            WriteEndElement();
        }
コード例 #23
0
        private static XmlSchemaComplexType CreateOuterType()
        {
            XmlSchemaAttribute item = new XmlSchemaAttribute {
                Name           = "Dialect",
                SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"),
                Use            = XmlSchemaUse.Optional
            };
            XmlSchemaSimpleContentExtension extension = new XmlSchemaSimpleContentExtension {
                BaseTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema")
            };

            extension.Attributes.Add(item);
            XmlSchemaSimpleContent content = new XmlSchemaSimpleContent {
                Content = extension
            };
            XmlSchemaComplexType type = new XmlSchemaComplexType {
                ContentModel = content
            };
            XmlSchemaElement element = new XmlSchemaElement {
                Name       = "XPath",
                SchemaType = type
            };
            XmlSchemaSequence sequence = new XmlSchemaSequence();

            sequence.Items.Add(element);
            XmlSchemaAttribute attribute2 = new XmlSchemaAttribute {
                Name           = "NodeQuota",
                SchemaTypeName = new XmlQualifiedName("int", "http://www.w3.org/2001/XMLSchema"),
                Use            = XmlSchemaUse.Optional
            };
            XmlSchemaAnyAttribute attribute3 = new XmlSchemaAnyAttribute();
            XmlSchemaComplexType  type2      = new XmlSchemaComplexType {
                Name     = "XPathMessageFilter",
                Particle = sequence
            };

            type2.Attributes.Add(attribute2);
            type2.AnyAttribute = attribute3;
            return(type2);
        }
コード例 #24
0
ファイル: XsdAnalyzer.cs プロジェクト: mirkomaty/NDO
        public XmlQualifiedName GetBaseTypeName(XmlSchemaComplexType ct)
        {
            XmlSchemaSimpleContent sc = ct.ContentModel as XmlSchemaSimpleContent;

            if (sc == null)
            {
                return(null);
            }
            XmlSchemaSimpleContentExtension ex = sc.Content as XmlSchemaSimpleContentExtension;

            if (ex != null)
            {
                return(ex.BaseTypeName);
            }
            XmlSchemaSimpleContentRestriction cr = sc.Content as XmlSchemaSimpleContentRestriction;

            if (cr != null)
            {
                return(cr.BaseTypeName);
            }
            return(null);
        }
コード例 #25
0
        static void AddScopesType(DiscoveryVersion discoveryVersion, XmlSchema schema)
        {
            // <xs:complexType name="ScopesType">
            XmlSchemaComplexType scopesType = new XmlSchemaComplexType();

            scopesType.Name = ProtocolStrings.SchemaNames.ScopesType;

            //    <xs:simpleContent>
            XmlSchemaSimpleContent scopesTypeContent = new XmlSchemaSimpleContent();

            //       <xs:extension base="tns:UriListType">
            XmlSchemaSimpleContentExtension scopesTypeContentExtension = new XmlSchemaSimpleContentExtension();

            scopesTypeContentExtension.BaseTypeName = discoveryVersion.Implementation.QualifiedNames.UriListType;

            //          <xs:attribute name="MatchBy" type="xs:anyURI" />
            XmlSchemaAttribute matchBy = new XmlSchemaAttribute();

            matchBy.Name           = ProtocolStrings.SchemaNames.MatchByAttribute;
            matchBy.SchemaTypeName = discoveryVersion.Implementation.QualifiedNames.AnyUriType;

            //          <xs:anyAttribute namespace="##other" processContents="lax" />
            XmlSchemaAnyAttribute anyAttribute = new XmlSchemaAnyAttribute();

            anyAttribute.Namespace       = "##other";
            anyAttribute.ProcessContents = XmlSchemaContentProcessing.Lax;

            //       </xs:extension>
            scopesTypeContentExtension.Attributes.Add(matchBy);
            scopesTypeContentExtension.AnyAttribute = anyAttribute;

            //    </xs:simpleContent>
            scopesTypeContent.Content = scopesTypeContentExtension;

            // <xs:complexType name="ScopesType">
            scopesType.ContentModel = scopesTypeContent;

            schema.Items.Add(scopesType);
        }
コード例 #26
0
ファイル: xsd.cs プロジェクト: ydunk/masters
        private static void AddElementAndType(XmlSchema schema, string baseXsdType, string ns)
        {
            // name the element and soap-encoding type the same as the base XSD type
            XmlSchemaElement el = new XmlSchemaElement();

            el.Name           = baseXsdType;
            el.SchemaTypeName = new XmlQualifiedName(baseXsdType, ns);
            schema.Items.Add(el);

            XmlSchemaComplexType type = new XmlSchemaComplexType();

            type.Name = baseXsdType;
            XmlSchemaSimpleContent model = new XmlSchemaSimpleContent();

            type.ContentModel = model;

            XmlSchemaSimpleContentExtension ex = new XmlSchemaSimpleContentExtension();

            ex.BaseTypeName = new XmlQualifiedName(baseXsdType, XmlSchema.Namespace);
            model.Content   = ex;
            schema.Items.Add(type);
        }
コード例 #27
0
        private XmlSchemaComplexType ExtractComplexTypeSimpleContent(string name, JsonSchema jSchema)
        {
            List <string>        requiredProperties = GetterExtensions.Required(jSchema);
            XmlSchemaComplexType complexType        = new XmlSchemaComplexType
            {
                Name = name,
            };

            AddAnnotations(complexType, jSchema);

            XmlSchemaSimpleContent          simpleContent = new XmlSchemaSimpleContent();
            XmlSchemaSimpleContentExtension extension     = new XmlSchemaSimpleContentExtension();

            simpleContent.Content = extension;
            foreach (KeyValuePair <string, JsonSchema> item in jSchema.Properties())
            {
                if (item.Key.Equals("value") || HasSimpleContentAnnotation(item.Value))
                {
                    extension.BaseTypeName = new XmlQualifiedName(
                        ExtractTypeFromDefinitionReference(GetterExtensions.Ref(item.Value)));
                }
                else
                {
                    XmlSchemaAttribute attributeDefinition = ExtractAttribute(item.Key, item.Value);
                    if (requiredProperties.Contains(item.Key))
                    {
                        attributeDefinition.Use = XmlSchemaUse.Required;
                    }

                    extension.Attributes.Add(attributeDefinition);
                }
            }

            complexType.ContentModel = simpleContent;

            AddUnhandledAttributes(jSchema, complexType);

            return(complexType);
        }
コード例 #28
0
        private XmlSchemaObject GetSpecificationDataRowTypes()
        {
            var cvlAttribute = new XmlSchemaAttribute
            {
                Name           = "cvl",
                Use            = XmlSchemaUse.Optional,
                SchemaTypeName = new XmlQualifiedName("string", W3Namespace)
            };
            var complexDataType = new XmlSchemaComplexType();

            var simpleContent = new XmlSchemaSimpleContent();

            complexDataType.ContentModel = simpleContent;

            var extension = new XmlSchemaSimpleContentExtension();

            simpleContent.Content  = extension;
            extension.BaseTypeName = new XmlQualifiedName("string", W3Namespace);
            extension.Attributes.Add(cvlAttribute);

            complexDataType.Name = "StringType";

            return(complexDataType);
        }
コード例 #29
0
        void ExportClassSchema(XmlTypeMapping map)
        {
            if (IsMapExported(map))
            {
                return;
            }
            SetMapExported(map);

            if (map.TypeData.Type == typeof(object))
            {
                foreach (XmlTypeMapping dmap in map.DerivedTypes)
                {
                    if (dmap.TypeData.SchemaType == SchemaTypes.Class)
                    {
                        ExportClassSchema(dmap);
                    }
                }
                return;
            }

            XmlSchema            schema = GetSchema(map.XmlTypeNamespace);
            XmlSchemaComplexType stype  = new XmlSchemaComplexType();

            stype.Name = map.XmlType;
            schema.Items.Add(stype);

            ClassMap cmap = (ClassMap)map.ObjectMap;

            if (cmap.HasSimpleContent)
            {
                XmlSchemaSimpleContent simple = new XmlSchemaSimpleContent();
                stype.ContentModel = simple;
                XmlSchemaSimpleContentExtension ext = new XmlSchemaSimpleContentExtension();
                simple.Content = ext;
                XmlSchemaSequence     particle;
                XmlSchemaAnyAttribute anyAttribute;
                ExportMembersMapSchema(schema, cmap, map.BaseMap, ext.Attributes, out particle, out anyAttribute);
                ext.AnyAttribute = anyAttribute;
                if (map.BaseMap == null)
                {
                    ext.BaseTypeName = cmap.SimpleContentBaseType;
                }
                else
                {
                    ext.BaseTypeName = new XmlQualifiedName(map.BaseMap.XmlType, map.BaseMap.XmlTypeNamespace);
                    ImportNamespace(schema, map.BaseMap.XmlTypeNamespace);
                    ExportClassSchema(map.BaseMap);
                }
            }
            else if (map.BaseMap != null && map.BaseMap.IncludeInSchema)
            {
                XmlSchemaComplexContent          cstype = new XmlSchemaComplexContent();
                XmlSchemaComplexContentExtension ext    = new XmlSchemaComplexContentExtension();
                ext.BaseTypeName   = new XmlQualifiedName(map.BaseMap.XmlType, map.BaseMap.XmlTypeNamespace);
                cstype.Content     = ext;
                stype.ContentModel = cstype;

                XmlSchemaSequence     particle;
                XmlSchemaAnyAttribute anyAttribute;
                ExportMembersMapSchema(schema, cmap, map.BaseMap, ext.Attributes, out particle, out anyAttribute);
                ext.Particle     = particle;
                ext.AnyAttribute = anyAttribute;
                stype.IsMixed    = HasMixedContent(map);
                cstype.IsMixed   = BaseHasMixedContent(map);

                ImportNamespace(schema, map.BaseMap.XmlTypeNamespace);
                ExportClassSchema(map.BaseMap);
            }
            else
            {
                XmlSchemaSequence     particle;
                XmlSchemaAnyAttribute anyAttribute;
                ExportMembersMapSchema(schema, cmap, map.BaseMap, stype.Attributes, out particle, out anyAttribute);
                stype.Particle     = particle;
                stype.AnyAttribute = anyAttribute;
                stype.IsMixed      = cmap.XmlTextCollector != null;
            }

            foreach (XmlTypeMapping dmap in map.DerivedTypes)
            {
                if (dmap.TypeData.SchemaType == SchemaTypes.Class)
                {
                    ExportClassSchema(dmap);
                }
            }
        }
コード例 #30
0
        static void Check(ConformanceCheckContext ctx, ConformanceChecker checker, Hashtable visitedObjects, XmlSchemaObject value)
        {
            if (value == null)
            {
                return;
            }

            if (visitedObjects.Contains(value))
            {
                return;
            }
            visitedObjects.Add(value, value);

            if (value is XmlSchemaImport)
            {
                XmlSchemaImport so = (XmlSchemaImport)value;
                checker.Check(ctx, so);
            }
            else if (value is XmlSchemaAll)
            {
                XmlSchemaAll so = (XmlSchemaAll)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Items);
            }
            else if (value is XmlSchemaAnnotation)
            {
                XmlSchemaAnnotation so = (XmlSchemaAnnotation)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Items);
            }
            else if (value is XmlSchemaAttribute)
            {
                XmlSchemaAttribute so = (XmlSchemaAttribute)value;
                checker.Check(ctx, so);
            }
            else if (value is XmlSchemaAttributeGroup)
            {
                XmlSchemaAttributeGroup so = (XmlSchemaAttributeGroup)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Attributes);
                Check(ctx, checker, visitedObjects, so.AnyAttribute);
                Check(ctx, checker, visitedObjects, so.RedefinedAttributeGroup);
            }
            else if (value is XmlSchemaAttributeGroupRef)
            {
                XmlSchemaAttributeGroupRef so = (XmlSchemaAttributeGroupRef)value;
                checker.Check(ctx, so);
            }
            else if (value is XmlSchemaChoice)
            {
                XmlSchemaChoice so = (XmlSchemaChoice)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Items);
            }
            else if (value is XmlSchemaComplexContent)
            {
                XmlSchemaComplexContent so = (XmlSchemaComplexContent)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.Content);
            }
            else if (value is XmlSchemaComplexContentExtension)
            {
                XmlSchemaComplexContentExtension so = (XmlSchemaComplexContentExtension)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.Particle);
                CheckObjects(ctx, checker, visitedObjects, so.Attributes);
                Check(ctx, checker, visitedObjects, so.AnyAttribute);
            }
            else if (value is XmlSchemaComplexContentRestriction)
            {
                XmlSchemaComplexContentRestriction so = (XmlSchemaComplexContentRestriction)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.Particle);
                CheckObjects(ctx, checker, visitedObjects, so.Attributes);
                Check(ctx, checker, visitedObjects, so.AnyAttribute);
            }
            else if (value is XmlSchemaComplexType)
            {
                XmlSchemaComplexType so = (XmlSchemaComplexType)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.ContentModel);
                Check(ctx, checker, visitedObjects, so.Particle);
                CheckObjects(ctx, checker, visitedObjects, so.Attributes);
                Check(ctx, checker, visitedObjects, so.AnyAttribute);
                Check(ctx, checker, visitedObjects, so.ContentTypeParticle);
                Check(ctx, checker, visitedObjects, so.AttributeWildcard);
            }
            else if (value is XmlSchemaElement)
            {
                XmlSchemaElement so = (XmlSchemaElement)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.SchemaType);
                CheckObjects(ctx, checker, visitedObjects, so.Constraints);
            }
            else if (value is XmlSchemaGroup)
            {
                XmlSchemaGroup so = (XmlSchemaGroup)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.Particle);
            }
            else if (value is XmlSchemaGroupRef)
            {
                XmlSchemaGroupRef so = (XmlSchemaGroupRef)value;
                checker.Check(ctx, so);
            }
            else if (value is XmlSchemaIdentityConstraint)
            {
                XmlSchemaIdentityConstraint so = (XmlSchemaIdentityConstraint)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Fields);
                Check(ctx, checker, visitedObjects, so.Selector);
            }
            else if (value is XmlSchemaKeyref)
            {
                XmlSchemaKeyref so = (XmlSchemaKeyref)value;
                checker.Check(ctx, so);
            }
            else if (value is XmlSchemaRedefine)
            {
                XmlSchemaRedefine so = (XmlSchemaRedefine)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Items);
            }
            else if (value is XmlSchemaSequence)
            {
                XmlSchemaSequence so = (XmlSchemaSequence)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Items);
            }
            else if (value is XmlSchemaSimpleContent)
            {
                XmlSchemaSimpleContent so = (XmlSchemaSimpleContent)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.Content);
            }
            else if (value is XmlSchemaSimpleContentExtension)
            {
                XmlSchemaSimpleContentExtension so = (XmlSchemaSimpleContentExtension)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Attributes);
                Check(ctx, checker, visitedObjects, so.AnyAttribute);
            }
            else if (value is XmlSchemaSimpleContentRestriction)
            {
                XmlSchemaSimpleContentRestriction so = (XmlSchemaSimpleContentRestriction)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Attributes);
                Check(ctx, checker, visitedObjects, so.AnyAttribute);
                CheckObjects(ctx, checker, visitedObjects, so.Facets);
            }
            else if (value is XmlSchemaSimpleType)
            {
                XmlSchemaSimpleType so = (XmlSchemaSimpleType)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.Content);
            }
            else if (value is XmlSchemaSimpleTypeList)
            {
                XmlSchemaSimpleTypeList so = (XmlSchemaSimpleTypeList)value;
                checker.Check(ctx, so);
            }
            else if (value is XmlSchemaSimpleTypeRestriction)
            {
                XmlSchemaSimpleTypeRestriction so = (XmlSchemaSimpleTypeRestriction)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Facets);
            }
            else if (value is XmlSchemaSimpleTypeUnion)
            {
                XmlSchemaSimpleTypeUnion so = (XmlSchemaSimpleTypeUnion)value;
                checker.Check(ctx, so);
            }
        }