Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CompileAttribute()

void System.Xml.Schema.SchemaCollectionCompiler.CompileAttribute ( XmlSchemaAttribute xa)
inlineprivate

Definition at line 1814 of file SchemaCollectionCompiler.cs.

1815 {
1816 if (xa.IsProcessing)
1817 {
1819 }
1820 else
1821 {
1822 if (xa.AttDef != null)
1823 {
1824 return;
1825 }
1826 xa.IsProcessing = true;
1827 SchemaAttDef schemaAttDef = null;
1828 try
1829 {
1830 if (!xa.RefName.IsEmpty)
1831 {
1832 XmlSchemaAttribute xmlSchemaAttribute = (XmlSchemaAttribute)_schema.Attributes[xa.RefName];
1833 if (xmlSchemaAttribute == null)
1834 {
1835 throw new XmlSchemaException(System.SR.Sch_UndeclaredAttribute, xa.RefName.ToString(), xa);
1836 }
1838 if (xmlSchemaAttribute.AttDef == null)
1839 {
1840 throw new XmlSchemaException(System.SR.Sch_RefInvalidAttribute, xa.RefName.ToString(), xa);
1841 }
1842 schemaAttDef = xmlSchemaAttribute.AttDef.Clone();
1843 if (schemaAttDef.Datatype != null)
1844 {
1845 if (xmlSchemaAttribute.FixedValue != null)
1846 {
1847 if (xa.DefaultValue != null)
1848 {
1849 throw new XmlSchemaException(System.SR.Sch_FixedDefaultInRef, xa.RefName.ToString(), xa);
1850 }
1851 if (xa.FixedValue != null)
1852 {
1853 if (xa.FixedValue != xmlSchemaAttribute.FixedValue)
1854 {
1855 throw new XmlSchemaException(System.SR.Sch_FixedInRef, xa.RefName.ToString(), xa);
1856 }
1857 }
1858 else
1859 {
1860 schemaAttDef.Presence = SchemaDeclBase.Use.Fixed;
1861 SchemaAttDef schemaAttDef2 = schemaAttDef;
1862 string defaultValueRaw = (schemaAttDef.DefaultValueExpanded = xmlSchemaAttribute.FixedValue);
1863 schemaAttDef2.DefaultValueRaw = defaultValueRaw;
1864 schemaAttDef.DefaultValueTyped = schemaAttDef.Datatype.ParseValue(schemaAttDef.DefaultValueRaw, base.NameTable, new SchemaNamespaceManager(xa), createAtomicValue: true);
1865 }
1866 }
1867 else if (xmlSchemaAttribute.DefaultValue != null && xa.DefaultValue == null && xa.FixedValue == null)
1868 {
1869 schemaAttDef.Presence = SchemaDeclBase.Use.Default;
1870 SchemaAttDef schemaAttDef3 = schemaAttDef;
1871 string defaultValueRaw = (schemaAttDef.DefaultValueExpanded = xmlSchemaAttribute.DefaultValue);
1872 schemaAttDef3.DefaultValueRaw = defaultValueRaw;
1873 schemaAttDef.DefaultValueTyped = schemaAttDef.Datatype.ParseValue(schemaAttDef.DefaultValueRaw, base.NameTable, new SchemaNamespaceManager(xa), createAtomicValue: true);
1874 }
1875 }
1876 xa.SetAttributeType(xmlSchemaAttribute.AttributeSchemaType);
1877 }
1878 else
1879 {
1880 schemaAttDef = new SchemaAttDef(xa.QualifiedName);
1881 if (xa.SchemaType != null)
1882 {
1883 CompileSimpleType(xa.SchemaType);
1884 xa.SetAttributeType(xa.SchemaType);
1885 schemaAttDef.SchemaType = xa.SchemaType;
1886 schemaAttDef.Datatype = xa.SchemaType.Datatype;
1887 }
1888 else if (!xa.SchemaTypeName.IsEmpty)
1889 {
1890 XmlSchemaSimpleType simpleType = GetSimpleType(xa.SchemaTypeName);
1891 if (simpleType == null)
1892 {
1893 throw new XmlSchemaException(System.SR.Sch_UndeclaredSimpleType, xa.SchemaTypeName.ToString(), xa);
1894 }
1895 xa.SetAttributeType(simpleType);
1898 }
1899 else
1900 {
1901 schemaAttDef.SchemaType = DatatypeImplementation.AnySimpleType;
1902 schemaAttDef.Datatype = DatatypeImplementation.AnySimpleType.Datatype;
1903 xa.SetAttributeType(DatatypeImplementation.AnySimpleType);
1904 }
1905 }
1906 if (schemaAttDef.Datatype != null)
1907 {
1908 schemaAttDef.Datatype.VerifySchemaValid(_schema.Notations, xa);
1909 }
1910 if (xa.DefaultValue != null || xa.FixedValue != null)
1911 {
1912 if (xa.DefaultValue != null)
1913 {
1914 schemaAttDef.Presence = SchemaDeclBase.Use.Default;
1915 SchemaAttDef schemaAttDef4 = schemaAttDef;
1916 string defaultValueRaw = (schemaAttDef.DefaultValueExpanded = xa.DefaultValue);
1917 schemaAttDef4.DefaultValueRaw = defaultValueRaw;
1918 }
1919 else
1920 {
1921 schemaAttDef.Presence = SchemaDeclBase.Use.Fixed;
1922 SchemaAttDef schemaAttDef5 = schemaAttDef;
1923 string defaultValueRaw = (schemaAttDef.DefaultValueExpanded = xa.FixedValue);
1924 schemaAttDef5.DefaultValueRaw = defaultValueRaw;
1925 }
1926 if (schemaAttDef.Datatype != null)
1927 {
1928 schemaAttDef.DefaultValueTyped = schemaAttDef.Datatype.ParseValue(schemaAttDef.DefaultValueRaw, base.NameTable, new SchemaNamespaceManager(xa), createAtomicValue: true);
1929 }
1930 }
1931 else
1932 {
1933 switch (xa.Use)
1934 {
1935 case XmlSchemaUse.None:
1936 case XmlSchemaUse.Optional:
1937 schemaAttDef.Presence = SchemaDeclBase.Use.Implied;
1938 break;
1939 case XmlSchemaUse.Required:
1940 schemaAttDef.Presence = SchemaDeclBase.Use.Required;
1941 break;
1942 }
1943 }
1946 }
1947 catch (XmlSchemaException ex)
1948 {
1949 if (ex.SourceSchemaObject == null)
1950 {
1951 ex.SetSource(xa);
1952 }
1954 xa.AttDef = SchemaAttDef.Empty;
1955 }
1956 finally
1957 {
1958 xa.IsProcessing = false;
1959 }
1960 }
1961 }
static string Sch_UndeclaredSimpleType
Definition SR.cs:560
static string Sch_FixedInRef
Definition SR.cs:538
static string Sch_FixedDefaultInRef
Definition SR.cs:540
static string Sch_RefInvalidAttribute
Definition SR.cs:1064
static string Sch_AttributeCircularRef
Definition SR.cs:926
static string Sch_UndeclaredAttribute
Definition SR.cs:414
Definition SR.cs:7
void SendValidationEvent(string code, XmlSchemaObject source)
XmlSchemaSimpleType GetSimpleType(XmlQualifiedName name)
void CompileSimpleType(XmlSchemaSimpleType simpleType)
XmlSchemaObjectTable Notations
Definition XmlSchema.cs:310
XmlSchemaObjectTable Attributes
Definition XmlSchema.cs:230

References System.Xml.Schema.SchemaCollectionCompiler._schema, System.Xml.Schema.DatatypeImplementation.AnySimpleType, System.Xml.Schema.XmlSchema.Attributes, System.Xml.Schema.SchemaCollectionCompiler.CompileAttribute(), System.Xml.Schema.SchemaCollectionCompiler.CompileSimpleType(), System.Xml.Dictionary, System.Xml.Schema.SchemaAttDef.Empty, System.Xml.Schema.SchemaCollectionCompiler.GetSimpleType(), System.Xml.Schema.XmlSchema.Notations, System.SR.Sch_AttributeCircularRef, System.SR.Sch_FixedDefaultInRef, System.SR.Sch_FixedInRef, System.SR.Sch_RefInvalidAttribute, System.SR.Sch_UndeclaredAttribute, System.SR.Sch_UndeclaredSimpleType, and System.Xml.Schema.BaseProcessor.SendValidationEvent().

Referenced by System.Xml.Schema.SchemaCollectionCompiler.Compile(), System.Xml.Schema.SchemaCollectionCompiler.CompileAttribute(), System.Xml.Schema.SchemaCollectionCompiler.CompileAttributeGroup(), and System.Xml.Schema.SchemaCollectionCompiler.CompileLocalAttributes().