本文整理汇总了C#中System.Xml.Schema.XmlSchemaAttribute类的典型用法代码示例。如果您正苦于以下问题:C# XmlSchemaAttribute类的具体用法?C# XmlSchemaAttribute怎么用?C# XmlSchemaAttribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlSchemaAttribute类属于System.Xml.Schema命名空间,在下文中一共展示了XmlSchemaAttribute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildAttribute
protected void BuildAttribute( XmlSchemaAttribute attribute,
ObjectDef objectDef )
{
FieldDef def = null;
bool isEnum;
string dataType =
GetClassTypeFromDataType
( attribute.AttributeSchemaType, attribute.QualifiedName.Name, objectDef.Name,
out isEnum );
if ( isEnum ) {
def = objectDef.DefineAttr( attribute.QualifiedName.Name, null );
def.SetEnum( dataType );
}
else {
def = objectDef.DefineAttr( attribute.QualifiedName.Name, dataType );
}
if ( attribute.Use == XmlSchemaUse.Required ) {
def.SetFlags( "R" );
}
else {
def.SetFlags( "O" );
}
setAnnotation( def, attribute.Annotation );
// TODO: See if the data type is an enumeration
//System.Diagnostics.Debug.Assert( ! ( attribute.AttributeType is xmlschemdata
}
示例2: AttributeForm
private XmlSchemaForm AttributeForm(string ns, XmlSchemaAttribute attribute)
{
if (attribute.Form != XmlSchemaForm.None)
{
return attribute.Form;
}
XmlSchemaObject parent = attribute;
while (parent.Parent != null)
{
parent = parent.Parent;
}
XmlSchema schema = parent as XmlSchema;
if (schema != null)
{
if ((ns == null) || (ns.Length == 0))
{
if (schema.AttributeFormDefault != XmlSchemaForm.None)
{
return schema.AttributeFormDefault;
}
return XmlSchemaForm.Unqualified;
}
XmlSchemas.Preprocess(schema);
if ((attribute.QualifiedName.Namespace != null) && (attribute.QualifiedName.Namespace.Length != 0))
{
return XmlSchemaForm.Qualified;
}
}
return XmlSchemaForm.Unqualified;
}
示例3: AndSchema
public static XmlSchemaElement AndSchema()
{
var type = new XmlSchemaComplexType();
var any = new XmlSchemaAny();
any.MinOccurs = 1;
any.MaxOccursString = "unbounded";
any.ProcessContents = XmlSchemaContentProcessing.Strict;
any.Namespace = "##local";
var sequence = new XmlSchemaSequence();
type.Particle = sequence;
sequence.Items.Add(any);
var attrib = new XmlSchemaAttribute();
attrib.Name = "expressionLanguage";
attrib.Use = XmlSchemaUse.Optional;
attrib.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");
type.Attributes.Add(attrib);
attrib = new XmlSchemaAttribute();
attrib.Name = "failMessage";
attrib.Use = XmlSchemaUse.Optional;
attrib.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");
type.Attributes.Add(attrib);
var element = new XmlSchemaElement();
element.Name = "and";
element.SchemaType = type;
return element;
}
示例4: ReplaceThisWith
public static void ReplaceThisWith(this XmlSchemaAttribute that, XmlSchemaAttribute with)
{
var gr = that.Parent as XmlSchemaComplexType;
int idx = gr.Attributes.IndexOf(that);
gr.Attributes.Insert(idx, with);
gr.Attributes.Remove(that);
}
示例5: FixtureInit
public override void FixtureInit()
{
XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();
schemas.Add(SchemaCompletionData);
XmlCompletionDataProvider provider = new XmlCompletionDataProvider(schemas, SchemaCompletionData, String.Empty);
string xml = "<note xmlns='http://www.w3schools.com' name=''></note>";
schemaAttribute = (XmlSchemaAttribute)XmlView.GetSchemaObjectSelected(xml, xml.IndexOf("name"), provider);
}
示例6: Visit
protected override void Visit(XmlSchemaAttribute attribute)
{
if (!attribute.RefName.IsEmpty ||
attribute.Use == XmlSchemaUse.Prohibited)
return;
AddTopic(TopicType.Attribute, attribute.QualifiedName.Namespace, attribute, attribute.Name);
}
示例7: FixtureInit
public override void FixtureInit()
{
XmlSchemaCompletionCollection schemas = new XmlSchemaCompletionCollection();
schemas.Add(SchemaCompletion);
string xml = "<note xmlns='http://www.w3schools.com' name=''></note>";
XmlSchemaDefinition schemaDefinition = new XmlSchemaDefinition(schemas, null);
schemaAttribute = (XmlSchemaAttribute)schemaDefinition.GetSelectedSchemaObject(xml, xml.IndexOf("name"));
}
示例8: Visit
protected override void Visit(XmlSchemaAttribute attribute)
{
if (!attribute.RefName.IsEmpty)
return;
PushNamedObject(attribute);
base.Visit(attribute);
PopNamedObject();
}
示例9: FixtureInit
public override void FixtureInit()
{
XmlSchemaCompletionCollection schemas = new XmlSchemaCompletionCollection();
schemas.Add(SchemaCompletion);
XmlSchemaCompletion xsdSchemaCompletionData = new XmlSchemaCompletion(ResourceManager.ReadXsdSchema());
schemas.Add(xsdSchemaCompletionData);
string xml = GetSchema();
int index = xml.IndexOf("ref=\"dir\"");
index = xml.IndexOf("dir", index);
XmlSchemaDefinition schemaDefinition = new XmlSchemaDefinition(schemas, SchemaCompletion);
schemaAttribute = (XmlSchemaAttribute)schemaDefinition.GetSelectedSchemaObject(xml, index);
}
示例10: FixtureInit
public override void FixtureInit()
{
XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();
schemas.Add(SchemaCompletionData);
XmlSchemaCompletionData xsdSchemaCompletionData = new XmlSchemaCompletionData(ResourceManager.GetXsdSchema());
schemas.Add(xsdSchemaCompletionData);
XmlCompletionDataProvider provider = new XmlCompletionDataProvider(schemas, xsdSchemaCompletionData, String.Empty);
string xml = GetSchema();
int index = xml.IndexOf("ref=\"dir\"");
index = xml.IndexOf("dir", index);
schemaAttribute = (XmlSchemaAttribute)XmlView.GetSchemaObjectSelected(xml, index, provider, SchemaCompletionData);
}
示例11: FixtureInit
public override void FixtureInit()
{
XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();
schemas.Add(SchemaCompletionData);
XmlSchemaCompletionData xsdSchemaCompletionData = new XmlSchemaCompletionData(ResourceManager.GetXsdSchema());
schemas.Add(xsdSchemaCompletionData);
XmlCompletionDataProvider provider = new XmlCompletionDataProvider(schemas, xsdSchemaCompletionData, String.Empty, null);
string xml = GetSchema();
schemaAttribute = (XmlSchemaAttribute)XmlEditorView.GetSchemaObjectSelected(xml, xml.IndexOf("ref=\"name"), provider, SchemaCompletionData);
int index = xml.IndexOf("ref=\"name");
index = xml.IndexOf('n', index);
referencedSchemaElement = (XmlSchemaElement)XmlEditorView.GetSchemaObjectSelected(xml, index, provider, SchemaCompletionData);
}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:15,代码来源:ElementReferenceSelectedTestFixture.cs
示例12: GetDataSchemas
public XmlSchema GetDataSchemas(XmlSchema querySchema,IEnumerable<Registration> registrations)
{
var schema = new XmlSchema { TargetNamespace = RegistrationStorage.Dataspace };
schema.Namespaces.Add("", RegistrationStorage.Dataspace);
var guid = CreateGuidType();
schema.Items.Add(guid);
schema.Includes.Add(new XmlSchemaImport { Schema = querySchema, Namespace = querySchema.TargetNamespace });
foreach (var registration in registrations)
{
var etype = new XmlSchemaComplexType
{
Name = registration.ResourceName,
Annotation = new XmlSchemaAnnotation()
};
var doc = new XmlSchemaDocumentation { Markup = TextToNode(registration.ResourceType.FullName) };
etype.Annotation.Items.Add(doc);
etype.Block = XmlSchemaDerivationMethod.Extension;
var idAttr = new XmlSchemaAttribute
{
Name = "Id",
SchemaTypeName = new XmlQualifiedName(guid.Name, RegistrationStorage.Dataspace),
Use = XmlSchemaUse.Required
};
etype.Attributes.Add(idAttr);
var noChildrenAttr = new XmlSchemaAttribute
{
Name = RegistrationStorage.DefinitlyNoChildren,
SchemaType = XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Boolean),
Use = XmlSchemaUse.Optional
};
etype.Attributes.Add(noChildrenAttr);
if (querySchema.Items.OfType<XmlSchemaAttributeGroup>().Any(k => k.Name == etype.Name))
{
var group = new XmlSchemaAttributeGroupRef();
group.RefName = new XmlQualifiedName(etype.Name.Replace(" ", "_"), querySchema.TargetNamespace);
etype.Attributes.Add(group);
}
schema.Items.Add(etype);
}
return schema;
}
示例13: AddAttribute
public void AddAttribute (XmlSchemaAttribute attribute)
{
string name = attribute.Name;
if (name == null) {
var ns = attribute.RefName.Namespace;
if (string.IsNullOrEmpty (ns))
return;
var prefix = nsMap.GetPrefix (ns);
if (prefix == null) {
if (ns == "http://www.w3.org/XML/1998/namespace")
prefix = "xml";
else
return;
}
name = attribute.RefName.Name;
if (prefix.Length > 0)
name = prefix + ":" + name;
}
if (!names.Add (name))
return;
string documentation = GetDocumentation (attribute.Annotation);
Add (new XmlCompletionData (name, documentation, XmlCompletionData.DataType.XmlAttribute));
}
示例14: VisitXmlSchemaAttribute
public virtual void VisitXmlSchemaAttribute(XmlSchemaAttribute attribute)
{
Dispatch(attribute.AttributeSchemaType);
// why there is no pattern mathing in C# ???
if(attribute.Parent is XmlSchemaComplexType)
{
XmlSchemaComplexType complexType = (XmlSchemaComplexType) attribute.Parent;
VisitXmlSchemaAttribute(complexType, attribute);
}
else if (attribute.Parent is XmlSchemaAttributeGroup)
{
XmlSchemaAttributeGroup attributeGroup = (XmlSchemaAttributeGroup)attribute.Parent;
VisitXmlSchemaAttribute(attributeGroup, attribute);
}
else
{
Assert.Fail(attribute.Parent.GetType().ToString());
}
}
示例15: GetBuildInSchema
internal static XmlSchema GetBuildInSchema()
{
if (builtInSchemaForXmlNS == null)
{
XmlSchema schema = new XmlSchema {
TargetNamespace = "http://www.w3.org/XML/1998/namespace"
};
schema.Namespaces.Add("xml", "http://www.w3.org/XML/1998/namespace");
XmlSchemaAttribute item = new XmlSchemaAttribute {
Name = "lang",
SchemaTypeName = new XmlQualifiedName("language", "http://www.w3.org/2001/XMLSchema")
};
schema.Items.Add(item);
XmlSchemaAttribute attribute2 = new XmlSchemaAttribute {
Name = "base",
SchemaTypeName = new XmlQualifiedName("anyURI", "http://www.w3.org/2001/XMLSchema")
};
schema.Items.Add(attribute2);
XmlSchemaAttribute attribute3 = new XmlSchemaAttribute {
Name = "space"
};
XmlSchemaSimpleType type = new XmlSchemaSimpleType();
XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction {
BaseTypeName = new XmlQualifiedName("NCName", "http://www.w3.org/2001/XMLSchema")
};
XmlSchemaEnumerationFacet facet = new XmlSchemaEnumerationFacet {
Value = "default"
};
restriction.Facets.Add(facet);
XmlSchemaEnumerationFacet facet2 = new XmlSchemaEnumerationFacet {
Value = "preserve"
};
restriction.Facets.Add(facet2);
type.Content = restriction;
attribute3.SchemaType = type;
attribute3.DefaultValue = "preserve";
schema.Items.Add(attribute3);
XmlSchemaAttributeGroup group = new XmlSchemaAttributeGroup {
Name = "specialAttrs"
};
XmlSchemaAttribute attribute4 = new XmlSchemaAttribute {
RefName = new XmlQualifiedName("lang", "http://www.w3.org/XML/1998/namespace")
};
group.Attributes.Add(attribute4);
XmlSchemaAttribute attribute5 = new XmlSchemaAttribute {
RefName = new XmlQualifiedName("space", "http://www.w3.org/XML/1998/namespace")
};
group.Attributes.Add(attribute5);
XmlSchemaAttribute attribute6 = new XmlSchemaAttribute {
RefName = new XmlQualifiedName("base", "http://www.w3.org/XML/1998/namespace")
};
group.Attributes.Add(attribute6);
schema.Items.Add(group);
schema.IsPreprocessed = true;
schema.CompileSchemaInSet(new NameTable(), null, null);
Interlocked.CompareExchange<XmlSchema>(ref builtInSchemaForXmlNS, schema, null);
}
return builtInSchemaForXmlNS;
}