本文整理汇总了C#中System.Xml.Schema.XmlSchemaAttribute.SetAttributeType方法的典型用法代码示例。如果您正苦于以下问题:C# XmlSchemaAttribute.SetAttributeType方法的具体用法?C# XmlSchemaAttribute.SetAttributeType怎么用?C# XmlSchemaAttribute.SetAttributeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Schema.XmlSchemaAttribute
的用法示例。
在下文中一共展示了XmlSchemaAttribute.SetAttributeType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompileAttribute
private void CompileAttribute(XmlSchemaAttribute xa)
{
if (xa.IsProcessing)
{
base.SendValidationEvent("Sch_AttributeCircularRef", xa);
}
else if (xa.AttDef == null)
{
xa.IsProcessing = true;
SchemaAttDef def = null;
try
{
if (!xa.RefName.IsEmpty)
{
XmlSchemaAttribute attribute = (XmlSchemaAttribute) this.schema.Attributes[xa.RefName];
if (attribute == null)
{
throw new XmlSchemaException("Sch_UndeclaredAttribute", xa.RefName.ToString(), xa);
}
this.CompileAttribute(attribute);
if (attribute.AttDef == null)
{
throw new XmlSchemaException("Sch_RefInvalidAttribute", xa.RefName.ToString(), xa);
}
def = attribute.AttDef.Clone();
if (def.Datatype != null)
{
if (attribute.FixedValue != null)
{
if (xa.DefaultValue != null)
{
throw new XmlSchemaException("Sch_FixedDefaultInRef", xa.RefName.ToString(), xa);
}
if (xa.FixedValue != null)
{
if (xa.FixedValue != attribute.FixedValue)
{
throw new XmlSchemaException("Sch_FixedInRef", xa.RefName.ToString(), xa);
}
}
else
{
def.Presence = SchemaDeclBase.Use.Fixed;
def.DefaultValueRaw = def.DefaultValueExpanded = attribute.FixedValue;
def.DefaultValueTyped = def.Datatype.ParseValue(def.DefaultValueRaw, base.NameTable, new SchemaNamespaceManager(xa), true);
}
}
else if (((attribute.DefaultValue != null) && (xa.DefaultValue == null)) && (xa.FixedValue == null))
{
def.Presence = SchemaDeclBase.Use.Default;
def.DefaultValueRaw = def.DefaultValueExpanded = attribute.DefaultValue;
def.DefaultValueTyped = def.Datatype.ParseValue(def.DefaultValueRaw, base.NameTable, new SchemaNamespaceManager(xa), true);
}
}
xa.SetAttributeType(attribute.AttributeSchemaType);
}
else
{
def = new SchemaAttDef(xa.QualifiedName);
if (xa.SchemaType != null)
{
this.CompileSimpleType(xa.SchemaType);
xa.SetAttributeType(xa.SchemaType);
def.SchemaType = xa.SchemaType;
def.Datatype = xa.SchemaType.Datatype;
}
else if (!xa.SchemaTypeName.IsEmpty)
{
XmlSchemaSimpleType simpleType = this.GetSimpleType(xa.SchemaTypeName);
if (simpleType == null)
{
throw new XmlSchemaException("Sch_UndeclaredSimpleType", xa.SchemaTypeName.ToString(), xa);
}
xa.SetAttributeType(simpleType);
def.Datatype = simpleType.Datatype;
def.SchemaType = simpleType;
}
else
{
def.SchemaType = DatatypeImplementation.AnySimpleType;
def.Datatype = DatatypeImplementation.AnySimpleType.Datatype;
xa.SetAttributeType(DatatypeImplementation.AnySimpleType);
}
}
if (def.Datatype != null)
{
def.Datatype.VerifySchemaValid(this.schema.Notations, xa);
}
if ((xa.DefaultValue != null) || (xa.FixedValue != null))
{
if (xa.DefaultValue != null)
{
def.Presence = SchemaDeclBase.Use.Default;
def.DefaultValueRaw = def.DefaultValueExpanded = xa.DefaultValue;
}
else
{
def.Presence = SchemaDeclBase.Use.Fixed;
def.DefaultValueRaw = def.DefaultValueExpanded = xa.FixedValue;
}
//.........这里部分代码省略.........
示例2: BuildXsiAttributes
private static void BuildXsiAttributes()
{
if (xsiTypeSO == null)
{
XmlSchemaAttribute attribute = new XmlSchemaAttribute {
Name = "type"
};
attribute.SetQualifiedName(new XmlQualifiedName("type", "http://www.w3.org/2001/XMLSchema-instance"));
attribute.SetAttributeType(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.QName));
Interlocked.CompareExchange<XmlSchemaAttribute>(ref xsiTypeSO, attribute, null);
}
if (xsiNilSO == null)
{
XmlSchemaAttribute attribute2 = new XmlSchemaAttribute {
Name = "nil"
};
attribute2.SetQualifiedName(new XmlQualifiedName("nil", "http://www.w3.org/2001/XMLSchema-instance"));
attribute2.SetAttributeType(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Boolean));
Interlocked.CompareExchange<XmlSchemaAttribute>(ref xsiNilSO, attribute2, null);
}
if (xsiSLSO == null)
{
XmlSchemaSimpleType builtInSimpleType = XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String);
XmlSchemaAttribute attribute3 = new XmlSchemaAttribute {
Name = "schemaLocation"
};
attribute3.SetQualifiedName(new XmlQualifiedName("schemaLocation", "http://www.w3.org/2001/XMLSchema-instance"));
attribute3.SetAttributeType(builtInSimpleType);
Interlocked.CompareExchange<XmlSchemaAttribute>(ref xsiSLSO, attribute3, null);
}
if (xsiNoNsSLSO == null)
{
XmlSchemaSimpleType type2 = XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String);
XmlSchemaAttribute attribute4 = new XmlSchemaAttribute {
Name = "noNamespaceSchemaLocation"
};
attribute4.SetQualifiedName(new XmlQualifiedName("noNamespaceSchemaLocation", "http://www.w3.org/2001/XMLSchema-instance"));
attribute4.SetAttributeType(type2);
Interlocked.CompareExchange<XmlSchemaAttribute>(ref xsiNoNsSLSO, attribute4, null);
}
}
示例3: CompileAttribute
private void CompileAttribute(XmlSchemaAttribute xa) {
if (xa.IsProcessing) {
SendValidationEvent(Res.Sch_AttributeCircularRef, xa);
return;
}
if (xa.AttDef != null) { //already compiled?
return;
}
xa.IsProcessing = true;
SchemaAttDef decl = null;
try {
if (!xa.RefName.IsEmpty) {
XmlSchemaAttribute a = (XmlSchemaAttribute)attributes[xa.RefName];
if (a == null) {
throw new XmlSchemaException(Res.Sch_UndeclaredAttribute, xa.RefName.ToString(), xa);
}
CompileAttribute(a);
if (a.AttDef == null) {
throw new XmlSchemaException(Res.Sch_RefInvalidAttribute, xa.RefName.ToString(), xa);
}
decl = a.AttDef.Clone();
XmlSchemaDatatype datatype = decl.Datatype;
if (datatype != null) {
if (a.FixedValue == null && a.DefaultValue == null) {
SetDefaultFixed(xa, decl);
}
else if (a.FixedValue != null) {
if (xa.DefaultValue != null) {
throw new XmlSchemaException(Res.Sch_FixedDefaultInRef, xa.RefName.ToString(), xa);
}
else if (xa.FixedValue != null ) {
object refFixedValue = datatype.ParseValue(xa.FixedValue, NameTable, new SchemaNamespaceManager(xa), true);
if ( !datatype.IsEqual(decl.DefaultValueTyped, refFixedValue)) {
throw new XmlSchemaException(Res.Sch_FixedInRef, xa.RefName.ToString(), xa);
}
}
}
}
xa.SetAttributeType(a.AttributeSchemaType);
}
else {
decl = new SchemaAttDef(xa.QualifiedName);
if (xa.SchemaType != null) {
CompileSimpleType(xa.SchemaType);
xa.SetAttributeType(xa.SchemaType);
decl.SchemaType = xa.SchemaType;
decl.Datatype = xa.SchemaType.Datatype;
}
else if (!xa.SchemaTypeName.IsEmpty) {
XmlSchemaSimpleType simpleType = GetSimpleType(xa.SchemaTypeName);
if (simpleType != null) {
xa.SetAttributeType(simpleType);
decl.Datatype = simpleType.Datatype;
decl.SchemaType = simpleType;
}
else {
throw new XmlSchemaException(Res.Sch_UndeclaredSimpleType, xa.SchemaTypeName.ToString(), xa);
}
}
else {
decl.SchemaType = DatatypeImplementation.AnySimpleType;
decl.Datatype = DatatypeImplementation.AnySimpleType.Datatype;
xa.SetAttributeType(DatatypeImplementation.AnySimpleType);
}
//} //Removed this here since the following should be done only if RefName is Empty
if (decl.Datatype != null) {
decl.Datatype.VerifySchemaValid(notations, xa);
}
SetDefaultFixed(xa, decl);
} //End of Else for !RefName.IsEmpty
decl.SchemaAttribute = xa; //So this is available for PSVI
xa.AttDef = decl;
}
catch (XmlSchemaException e) {
if (e.SourceSchemaObject == null) {
e.SetSource(xa);
}
SendValidationEvent(e);
xa.AttDef = SchemaAttDef.Empty;
}
finally {
xa.IsProcessing = false;
}
}
示例4: BuildXsiAttributes
} //End of method
private static void BuildXsiAttributes() {
if (xsiTypeSO == null) { //xsi:type attribute
XmlSchemaAttribute tempXsiTypeSO = new XmlSchemaAttribute();
tempXsiTypeSO.Name = "type";
tempXsiTypeSO.SetQualifiedName(new XmlQualifiedName("type", XmlReservedNs.NsXsi));
tempXsiTypeSO.SetAttributeType(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.QName));
Interlocked.CompareExchange<XmlSchemaAttribute>(ref xsiTypeSO, tempXsiTypeSO, null);
}
if (xsiNilSO == null) { //xsi:nil
XmlSchemaAttribute tempxsiNilSO = new XmlSchemaAttribute();
tempxsiNilSO.Name = "nil";
tempxsiNilSO.SetQualifiedName(new XmlQualifiedName("nil", XmlReservedNs.NsXsi));
tempxsiNilSO.SetAttributeType(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Boolean));
Interlocked.CompareExchange<XmlSchemaAttribute>(ref xsiNilSO, tempxsiNilSO, null);
}
if (xsiSLSO == null) { //xsi:schemaLocation
XmlSchemaSimpleType stringType = XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String);
XmlSchemaAttribute tempxsiSLSO = new XmlSchemaAttribute();
tempxsiSLSO.Name = "schemaLocation";
tempxsiSLSO.SetQualifiedName(new XmlQualifiedName("schemaLocation", XmlReservedNs.NsXsi));
tempxsiSLSO.SetAttributeType(stringType);
Interlocked.CompareExchange<XmlSchemaAttribute>(ref xsiSLSO, tempxsiSLSO, null);
}
if (xsiNoNsSLSO == null) {
XmlSchemaSimpleType stringType = XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String);
XmlSchemaAttribute tempxsiNoNsSLSO = new XmlSchemaAttribute();
tempxsiNoNsSLSO.Name = "noNamespaceSchemaLocation";
tempxsiNoNsSLSO.SetQualifiedName(new XmlQualifiedName("noNamespaceSchemaLocation", XmlReservedNs.NsXsi));
tempxsiNoNsSLSO.SetAttributeType(stringType);
Interlocked.CompareExchange<XmlSchemaAttribute>(ref xsiNoNsSLSO, tempxsiNoNsSLSO, null);
}
}
示例5: CompileAttribute
private void CompileAttribute(XmlSchemaAttribute xa)
{
if (xa.IsProcessing)
{
base.SendValidationEvent("Sch_AttributeCircularRef", xa);
}
else if (xa.AttDef == null)
{
xa.IsProcessing = true;
SchemaAttDef decl = null;
try
{
if (!xa.RefName.IsEmpty)
{
XmlSchemaAttribute attribute = (XmlSchemaAttribute) this.attributes[xa.RefName];
if (attribute == null)
{
throw new XmlSchemaException("Sch_UndeclaredAttribute", xa.RefName.ToString(), xa);
}
this.CompileAttribute(attribute);
if (attribute.AttDef == null)
{
throw new XmlSchemaException("Sch_RefInvalidAttribute", xa.RefName.ToString(), xa);
}
decl = attribute.AttDef.Clone();
XmlSchemaDatatype datatype = decl.Datatype;
if (datatype != null)
{
if ((attribute.FixedValue == null) && (attribute.DefaultValue == null))
{
this.SetDefaultFixed(xa, decl);
}
else if (attribute.FixedValue != null)
{
if (xa.DefaultValue != null)
{
throw new XmlSchemaException("Sch_FixedDefaultInRef", xa.RefName.ToString(), xa);
}
if (xa.FixedValue != null)
{
object obj2 = datatype.ParseValue(xa.FixedValue, base.NameTable, new SchemaNamespaceManager(xa), true);
if (!datatype.IsEqual(decl.DefaultValueTyped, obj2))
{
throw new XmlSchemaException("Sch_FixedInRef", xa.RefName.ToString(), xa);
}
}
}
}
xa.SetAttributeType(attribute.AttributeSchemaType);
}
else
{
decl = new SchemaAttDef(xa.QualifiedName);
if (xa.SchemaType != null)
{
this.CompileSimpleType(xa.SchemaType);
xa.SetAttributeType(xa.SchemaType);
decl.SchemaType = xa.SchemaType;
decl.Datatype = xa.SchemaType.Datatype;
}
else if (!xa.SchemaTypeName.IsEmpty)
{
XmlSchemaSimpleType simpleType = this.GetSimpleType(xa.SchemaTypeName);
if (simpleType == null)
{
throw new XmlSchemaException("Sch_UndeclaredSimpleType", xa.SchemaTypeName.ToString(), xa);
}
xa.SetAttributeType(simpleType);
decl.Datatype = simpleType.Datatype;
decl.SchemaType = simpleType;
}
else
{
decl.SchemaType = DatatypeImplementation.AnySimpleType;
decl.Datatype = DatatypeImplementation.AnySimpleType.Datatype;
xa.SetAttributeType(DatatypeImplementation.AnySimpleType);
}
if (decl.Datatype != null)
{
decl.Datatype.VerifySchemaValid(this.notations, xa);
}
this.SetDefaultFixed(xa, decl);
}
decl.SchemaAttribute = xa;
xa.AttDef = decl;
}
catch (XmlSchemaException exception)
{
if (exception.SourceSchemaObject == null)
{
exception.SetSource(xa);
}
base.SendValidationEvent(exception);
xa.AttDef = SchemaAttDef.Empty;
}
finally
{
xa.IsProcessing = false;
}
}
//.........这里部分代码省略.........
示例6: CompileAttribute
private void CompileAttribute(XmlSchemaAttribute xa) {
if (xa.IsProcessing) {
SendValidationEvent(Res.Sch_AttributeCircularRef, xa);
return;
}
if (xa.AttDef != null) { //already compiled?
return;
}
xa.IsProcessing = true;
SchemaAttDef decl = null;
try {
if (!xa.RefName.IsEmpty) {
XmlSchemaAttribute a = (XmlSchemaAttribute)this.schema.Attributes[xa.RefName];
if (a == null) {
throw new XmlSchemaException(Res.Sch_UndeclaredAttribute, xa.RefName.ToString(), xa);
}
CompileAttribute(a);
if (a.AttDef == null) {
throw new XmlSchemaException(Res.Sch_RefInvalidAttribute, xa.RefName.ToString(), xa);
}
decl = a.AttDef.Clone();
if(decl.Datatype != null) {
if(a.FixedValue != null) {
if(xa.DefaultValue != null) {
throw new XmlSchemaException(Res.Sch_FixedDefaultInRef, xa.RefName.ToString(), xa);
}
else if(xa.FixedValue != null ) {
if (xa.FixedValue != a.FixedValue) {
throw new XmlSchemaException(Res.Sch_FixedInRef, xa.RefName.ToString(), xa);
}
}
else {
decl.Presence = SchemaDeclBase.Use.Fixed;
decl.DefaultValueRaw = decl.DefaultValueExpanded = a.FixedValue;
decl.DefaultValueTyped = decl.Datatype.ParseValue(decl.DefaultValueRaw, NameTable, new SchemaNamespaceManager(xa), true);
}
}
else if (a.DefaultValue != null) {
if(xa.DefaultValue == null && xa.FixedValue == null) {
decl.Presence = SchemaDeclBase.Use.Default;
decl.DefaultValueRaw = decl.DefaultValueExpanded = a.DefaultValue;
decl.DefaultValueTyped = decl.Datatype.ParseValue(decl.DefaultValueRaw, NameTable, new SchemaNamespaceManager(xa), true);
}
}
}
xa.SetAttributeType(a.AttributeSchemaType);
}
else {
decl = new SchemaAttDef(xa.QualifiedName);
if (xa.SchemaType != null) {
CompileSimpleType(xa.SchemaType);
xa.SetAttributeType(xa.SchemaType);
decl.SchemaType = xa.SchemaType;
decl.Datatype = xa.SchemaType.Datatype;
}
else if (!xa.SchemaTypeName.IsEmpty) {
XmlSchemaSimpleType simpleType = GetSimpleType(xa.SchemaTypeName);
if (simpleType != null) {
xa.SetAttributeType(simpleType);
decl.Datatype = simpleType.Datatype;
decl.SchemaType = simpleType;
}
else {
throw new XmlSchemaException(Res.Sch_UndeclaredSimpleType, xa.SchemaTypeName.ToString(), xa);
}
}
else {
decl.SchemaType = DatatypeImplementation.AnySimpleType;
decl.Datatype = DatatypeImplementation.AnySimpleType.Datatype;
xa.SetAttributeType(DatatypeImplementation.AnySimpleType);
}
}
if (decl.Datatype != null) {
decl.Datatype.VerifySchemaValid(this.schema.Notations, xa);
}
if (xa.DefaultValue != null || xa.FixedValue != null) {
if (xa.DefaultValue != null) {
decl.Presence = SchemaDeclBase.Use.Default;
decl.DefaultValueRaw = decl.DefaultValueExpanded = xa.DefaultValue;
}
else {
decl.Presence = SchemaDeclBase.Use.Fixed;
decl.DefaultValueRaw = decl.DefaultValueExpanded = xa.FixedValue;
}
if(decl.Datatype != null) {
decl.DefaultValueTyped = decl.Datatype.ParseValue(decl.DefaultValueRaw, NameTable, new SchemaNamespaceManager(xa), true);
}
}
else {
switch (xa.Use) {
case XmlSchemaUse.None:
case XmlSchemaUse.Optional:
decl.Presence = SchemaDeclBase.Use.Implied;
break;
case XmlSchemaUse.Required:
decl.Presence = SchemaDeclBase.Use.Required;
break;
case XmlSchemaUse.Prohibited:
break;
}
//.........这里部分代码省略.........