Esempio n. 1
0
 private static void Equal(XmlSchemaSimpleContentExtension expected, XmlSchemaSimpleContentExtension actual)
 {
     AnnotatedEqual(expected, actual);
     Assert.Equal(expected.BaseTypeName, actual.BaseTypeName);
     IsEquivalentTo(expected.Attributes, actual.Attributes);
     IsEquivalentTo(expected.AnyAttribute, actual.AnyAttribute);
 }
Esempio n. 2
0
        /// <summary>
        /// Processes an XmlSchemaSimpleContentExtension into corresponding types.
        /// </summary>
        /// <param name="typeName">Name of the type being generated.</param>
        /// <param name="simpleContent">XmlSchemaSimpleContentExtension being processed.</param>
        /// <param name="documentation">Documentation for the simple content.</param>
        /// <param name="codeNamespace">CodeNamespace to be used when outputting code.</param>
        /// <param name="outputXmlMethod">Method to use when outputting Xml.</param>
        /// <param name="abstractClass">If true, generate an abstract class.</param>
        private static void ProcessSimpleContent(string typeName, XmlSchemaSimpleContentExtension simpleContent, string documentation, CodeNamespace codeNamespace, CodeMemberMethod outputXmlMethod, bool abstractClass)
        {
            CodeTypeDeclaration typeDeclaration = new CodeTypeDeclaration(typeName);

            typeDeclaration.Attributes = MemberAttributes.Public;
            typeDeclaration.IsClass    = true;

            if (documentation != null)
            {
                GenerateSummaryComment(typeDeclaration.Comments, documentation);
            }

            if (abstractClass)
            {
                typeDeclaration.TypeAttributes = System.Reflection.TypeAttributes.Abstract | System.Reflection.TypeAttributes.Public;
            }

            // TODO: Handle xs:anyAttribute here.
            foreach (XmlSchemaAttribute schemaAttribute in simpleContent.Attributes)
            {
                ProcessAttribute(schemaAttribute, typeDeclaration, outputXmlMethod);
            }

            // This needs to come last, so that the generation code generates the inner content after the attributes.
            string contentDocumentation = GetDocumentation(simpleContent.Annotation);

            GenerateFieldAndProperty("Content", (string)simpleTypeNamesToClrTypeNames[simpleContent.BaseTypeName.Name], typeDeclaration, outputXmlMethod, null, contentDocumentation, true, false);

            typeDeclaration.BaseTypes.Add(new CodeTypeReference("ISchemaElement"));
            typeDeclaration.Members.Add(outputXmlMethod);
            codeNamespace.Types.Add(typeDeclaration);
        }
Esempio n. 3
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);
        }
        /*
         * 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);
        }
Esempio n. 5
0
        protected virtual void Visit(XmlSchemaSimpleContentExtension extension)
        {
            Traverse(extension.Attributes);

            if (extension.AnyAttribute != null)
            {
                Traverse(extension.AnyAttribute);
            }
        }
        /// <summary>
        /// Process an IFCXML schema file
        /// </summary>
        /// <param name="ifcxmlSchemaFile">the IfcXML schema file info</param>
        public static bool ProcessIFCSchema(FileInfo ifcxmlSchemaFile)
        {
            if (ifcxmlSchemaFile.Name.Equals(loadedSchema) && IfcSchemaEntityTree.EntityDict.Count > 0)
            {
                return(false); // The schema file has been processed and loaded before
            }
            loadedSchema = ifcxmlSchemaFile.Name;
            IfcSchemaEntityTree.Initialize(loadedSchema);
            XmlTextReader reader    = new XmlTextReader(ifcxmlSchemaFile.FullName);
            XmlSchema     theSchema = XmlSchema.Read(reader, ValidationCallback);

            foreach (XmlSchemaObject item in theSchema.Items)
            {
                if (!(item is XmlSchemaComplexType))
                {
                    continue;
                }

                XmlSchemaComplexType ct = item as XmlSchemaComplexType;
                string entityName       = ct.Name;

                if (string.Compare(entityName, 0, "Ifc", 0, 3, ignoreCase: true) != 0)
                {
                    continue;
                }

                string parentName = string.Empty;

                if (ct.ContentModel == null)
                {
                    continue;
                }

                if (ct.ContentModel.Parent == null)
                {
                    continue;
                }

                if (ct.ContentModel.Parent is XmlSchemaComplexType)
                {
                    XmlSchemaComplexType             parent            = ct.ContentModel.Parent as XmlSchemaComplexType;
                    XmlSchemaSimpleContentExtension  parentSimpleType  = parent.ContentModel.Content as XmlSchemaSimpleContentExtension;
                    XmlSchemaComplexContentExtension parentComplexType = parent.ContentModel.Content as XmlSchemaComplexContentExtension;
                    if (parentSimpleType != null)
                    {
                        parentName = parentSimpleType.BaseTypeName.Name;
                    }
                    if (parentComplexType != null)
                    {
                        parentName = parentComplexType.BaseTypeName.Name;
                    }
                }

                IfcSchemaEntityTree.Add(entityName, parentName, isAbstract: ct.IsAbstract);
            }
            return(true);
        }
Esempio n. 7
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));
        }
Esempio n. 8
0
        private static string ProcessSchemaSimpleContentExtension(XmlSchemaSimpleContentExtension schemaContentExtension)
        {
            StringBuilder result = new StringBuilder();

            //if (schemaContentExtension.Annotation != null)
            //{
            //    result.AppendLine("May have nested data.");
            //    result.Append(ProcessAnnotation(schemaContentExtension.Annotation));
            //}
            result.Append(Process(schemaContentExtension.Attributes));
            return(result.ToString());
        }
Esempio n. 9
0
        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)));
        }
Esempio n. 10
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);
    }
Esempio n. 11
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);
     }
 }
Esempio n. 12
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);
    }
Esempio n. 13
0
        private void AddValueProperty(ClassInfo classInfo, XmlSchemaSimpleContentExtension sce)
        {
            var propInfo = new PropertyInfo(classInfo)
            {
                IsList         = false,
                XmlName        = "Value",
                XmlType        = ResolveSimpleTypeName(sce.BaseTypeName.Name),
                IsElementValue = true
            };

            if (!classInfo.Elements.Contains(propInfo))
            {
                classInfo.Elements.Add(propInfo);
            }
        }
        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);
        }
Esempio n. 15
0
 private void Write38_XmlSchemaSimpleContentExtension(XmlSchemaSimpleContentExtension o)
 {
     if (o != null)
     {
         this.WriteStartElement("extension");
         this.WriteAttribute("id", "", o.Id);
         this.WriteAttributes(o.UnhandledAttributes, o);
         if (!o.BaseTypeName.IsEmpty)
         {
             this.WriteAttribute("base", "", o.BaseTypeName);
         }
         this.Write5_XmlSchemaAnnotation(o.Annotation);
         this.WriteSortedItems(o.Attributes);
         this.Write33_XmlSchemaAnyAttribute(o.AnyAttribute);
         this.WriteEndElement();
     }
 }
Esempio n. 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;
 }
Esempio n. 17
0
        // See https://stackoverflow.com/questions/626319/add-attributes-to-a-simpletype-or-restriction-to-a-complextype-in-xml-schema/626385#626385
        private static XmlSchemaComplexType CreateSchemaTypeWithAttributes <T>(XmlSchemaType baseType, params XmlSchemaAttribute[] attributes) where T : IXmlSerializable
        {
            var content = new XmlSchemaSimpleContentExtension {
                BaseTypeName = baseType.QualifiedName
            };

            foreach (var attribute in attributes)
            {
                content.Attributes.Add(attribute);
            }
            return(new XmlSchemaComplexType
            {
                Name = typeof(T).Name,
                ContentModel = new XmlSchemaSimpleContent {
                    Content = content
                }
            });
        }
Esempio n. 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);
                }
            }
        }
Esempio n. 19
0
        void Write38_XmlSchemaSimpleContentExtension(XmlSchemaSimpleContentExtension o)
        {
            if ((object)o == null)
            {
                return;
            }
            WriteStartElement("extension");

            WriteAttribute(@"id", @"", ((System.String)o.@Id));
            WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
            if ([email protected])
            {
                WriteAttribute(@"base", @"", o.@BaseTypeName);
            }
            Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
            WriteSortedItems(o.Attributes);
            Write33_XmlSchemaAnyAttribute((XmlSchemaAnyAttribute)o.@AnyAttribute);
            WriteEndElement();
        }
Esempio n. 20
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);
        }
Esempio n. 21
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);
        }
Esempio n. 22
0
        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);
        }
        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);
        }
Esempio n. 24
0
File: xsd.cs Progetto: 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);
        }
Esempio n. 25
0
        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);
        }
Esempio n. 26
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);
        }
Esempio n. 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);
        }
        public void IterateThrough(XmlSchemaSimpleContentExtension obj)
        {
            if (_functionalVisitor.StartProcessing(obj))
            {
                if (obj.Attributes != null)
                {
                    var en = obj.Attributes.GetEnumerator();
                    while (en.MoveNext())
                    {
                        en.Current.Accept(this);
                    }
                }

                var baseType = XmlSchemaExtensions.GetComplexType(_schemaSet, obj.BaseTypeName);

                if (baseType != null && obj.BaseTypeName.Namespace != XmlSchema.Namespace)
                {
                    baseType.Accept(this);
                }
            }

            _functionalVisitor.EndProcessing(obj);
        }
Esempio n. 29
0
        public ElementWrapper(XmlSchemaElement element, bool collectSubElements)
        {
            this.element = element;
            this.schema  = GetSchema();
            XmlSchemaComplexType ct = this.ComplexType;

            if (collectSubElements && ct != null)
            {
                GetAnnotations();
                CollectSubElements();
                CheckForSimpleRestriction();
                CollectAttributes(ct.Attributes);
                XmlSchemaSimpleContentExtension scex = this.SimpleContentExtension;
                if (scex != null)
                {
                    CollectAttributes(scex.Attributes);
                }
                XmlSchemaSimpleContentRestriction scr = this.SimpleContentRestriction;
                if (scr != null)
                {
                    CollectAttributes(scr.Attributes);
                }
            }
        }
Esempio n. 30
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);
        }