Beispiel #1
0
        public void TestAnyAtomicTypeConversionFromString()
        {
            Assert.DoesNotThrow(() => {
                var ncName = new localSimpleType()
                {
                    restriction = new restriction()
                    {
                        enumeration =
                        {
                            new enumeration(new noFixedFacet()
                            {
                                value = "default"
                            }),
                            new enumeration(new noFixedFacet()
                            {
                                value = "preserve"
                            })
                        }
                    }
                };

                var str = XTypedServices.GetXmlString("default",
                                                      XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.AnyAtomicType).Datatype, XElement.Parse("<element />"));
            });
        }
        public void TestPublicTypeConstruction()
        {
            var ncName = new localSimpleType()
            {
                restriction = new restriction()
                {
                    enumeration =
                    {
                        new enumeration(new noFixedFacet()
                        {
                            value = "default"
                        }),
                        new enumeration(new noFixedFacet()
                        {
                            value = "preserve"
                        })
                    }
                }
            };

            var xsdExample = new schema()
            {
                targetNamespace = new Uri("http://www.w3.org/XML/1998/namespace"),
                attribute       = new List <attribute>()
                {
                    new attribute(new topLevelAttribute()
                    {
                        name = "base", type = new XmlQualifiedName("anyURI")
                    }),
                    new attribute(new topLevelAttribute()
                    {
                        name = "lang", type = new XmlQualifiedName("language")
                    }),
                    new attribute(new topLevelAttribute()
                    {
                        name = "space", simpleType = ncName
                    })
                },
                attributeGroup = new List <attributeGroup>()
                {
                    new attributeGroup(new namedAttributeGroup()
                    {
                        name      = "specialAttrs",
                        attribute =
                        {
                            new topLevelAttribute()
                            {
                                @ref = new XmlQualifiedName("base")
                            },
                            new topLevelAttribute()
                            {
                                @ref = new XmlQualifiedName("lang")
                            },
                            new topLevelAttribute()
                            {
                                @ref = new XmlQualifiedName("space")
                            },
                        }
                    })
                }
            };

            Assert.DoesNotThrow(() => { xsdExample.lang = "en-GB"; });

            var xsdString = xsdExample.ToString();

            Assert.DoesNotThrow(() => {
                schema schema = schema.Parse(xsdString);

                Assert.IsNotNull(schema.lang as string);
            });
        }
 public attribute()
 {
     this.simpleTypeField = new localSimpleType();
     this.useField = attributeUse.optional;
 }
 public restriction()
 {
     //this.itemsElementNameField = new List<restrictionChoiceType>();
     //this.itemsField = new List<facet>();
     this.simpleTypeField = new localSimpleType();
 }
 public list()
 {
     this.simpleTypeField = new localSimpleType();
 }