本文整理汇总了C#中System.Xml.Schema.XmlSchemaAnyAttribute类的典型用法代码示例。如果您正苦于以下问题:C# XmlSchemaAnyAttribute类的具体用法?C# XmlSchemaAnyAttribute怎么用?C# XmlSchemaAnyAttribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlSchemaAnyAttribute类属于System.Xml.Schema命名空间,在下文中一共展示了XmlSchemaAnyAttribute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Intersection
internal static XmlSchemaAnyAttribute Intersection(XmlSchemaAnyAttribute o1, XmlSchemaAnyAttribute o2) {
NamespaceList nsl = NamespaceList.Intersection(o1.NamespaceList, o2.NamespaceList);
if (nsl != null) {
XmlSchemaAnyAttribute anyAttribute = new XmlSchemaAnyAttribute();
anyAttribute.namespaceList = nsl;
if (o1.processContents == XmlSchemaContentProcessing.Strict ||
o1.processContents == XmlSchemaContentProcessing.None ||
o2.processContents == XmlSchemaContentProcessing.Strict ||
o2.processContents == XmlSchemaContentProcessing.None) {
anyAttribute.processContents = XmlSchemaContentProcessing.Strict;
}
else if (o1.processContents == XmlSchemaContentProcessing.Lax ||
o2.processContents == XmlSchemaContentProcessing.Lax) {
anyAttribute.processContents = XmlSchemaContentProcessing.Lax;
}
else {
anyAttribute.processContents = XmlSchemaContentProcessing.Skip;
}
anyAttribute.Annotation = o1.Annotation;
return anyAttribute;
}
else {
// not expressible
return null;
}
}
示例2: GetExtensionAttributes
public IEnumerable<XmlSchemaObject> GetExtensionAttributes(XmlSchemaAnyAttribute parent)
{
List<XmlSchemaObject> attributes;
if (!_extensionAttributes.TryGetValue(parent, out attributes))
return _emptyObjectList;
return attributes;
}
示例3: Union
internal static XmlSchemaAnyAttribute Union(XmlSchemaAnyAttribute o1, XmlSchemaAnyAttribute o2, bool v1Compat)
{
System.Xml.Schema.NamespaceList list = System.Xml.Schema.NamespaceList.Union(o1.NamespaceList, o2.NamespaceList, v1Compat);
if (list != null)
{
return new XmlSchemaAnyAttribute { namespaceList = list, processContents = o1.processContents, Annotation = o1.Annotation };
}
return null;
}
示例4: XmlSchemaComplexType
static XmlSchemaComplexType() {
anyType = new XmlSchemaComplexType();
anyType.SetContentType(XmlSchemaContentType.Mixed);
anyType.ElementDecl = SchemaElementDecl.CreateAnyTypeElementDecl();
XmlSchemaAnyAttribute anyAttribute = new XmlSchemaAnyAttribute();
anyAttribute.BuildNamespaceList(null);
anyType.SetAttributeWildcard(anyAttribute);
anyType.ElementDecl.AnyAttribute = anyAttribute;
}
示例5: SDataSchemaResourceType
public SDataSchemaResourceType(string elementName)
: base(elementName)
{
ListName = elementName + "--list";
ListItemName = elementName;
CanGet = true;
AnyAttribute = new XmlSchemaAnyAttribute();
ListAnyAttribute = new XmlSchemaAnyAttribute();
}
示例6: Intersection
internal static XmlSchemaAnyAttribute Intersection(XmlSchemaAnyAttribute o1, XmlSchemaAnyAttribute o2, bool v1Compat) {
NamespaceList nsl = NamespaceList.Intersection(o1.NamespaceList, o2.NamespaceList, v1Compat);
if (nsl != null) {
XmlSchemaAnyAttribute anyAttribute = new XmlSchemaAnyAttribute();
anyAttribute.namespaceList = nsl;
anyAttribute.ProcessContents = o1.ProcessContents;
anyAttribute.Annotation = o1.Annotation;
return anyAttribute;
}
else {
// not expressible
return null;
}
}
示例7: BuildSchema
internal static XmlSchema BuildSchema (DiscoveryVersion version)
{
var schema = new XmlSchema () { TargetNamespace = version.Namespace };
var anyAttr = new XmlSchemaAnyAttribute () { Namespace = "##other", ProcessContents = XmlSchemaContentProcessing.Lax };
var probePart = new XmlSchemaSequence ();
probePart.Items.Add (new XmlSchemaElement () { RefName = new XmlQualifiedName ("Types", version.Namespace), MinOccurs = 0 });
probePart.Items.Add (new XmlSchemaElement () { RefName = new XmlQualifiedName ("Scopes", version.Namespace), MinOccurs = 0 });
probePart.Items.Add (new XmlSchemaAny () { MinOccurs = 0, MaxOccursString = "unbounded", Namespace = "##other", ProcessContents = XmlSchemaContentProcessing.Lax });
var ct = new XmlSchemaComplexType () { Name = "ProbeType", Particle = probePart, AnyAttribute = anyAttr };
schema.Items.Add (ct);
schema.Items.Add (new XmlSchemaSimpleType () { Name = "QNameListType", Content = new XmlSchemaSimpleTypeList () { ItemTypeName = new XmlQualifiedName ("QName", XmlSchema.Namespace) } });
var scr = new XmlSchemaSimpleContentRestriction () { BaseTypeName = new XmlQualifiedName ("UriListType", version.Namespace), AnyAttribute = anyAttr };
scr.Attributes.Add (new XmlSchemaAttribute () { Name = "matchBy", SchemaTypeName = new XmlQualifiedName ("anyURI", XmlSchema.Namespace) });
schema.Items.Add (new XmlSchemaComplexType () { Name = "ScopesType", ContentModel = new XmlSchemaSimpleContent () { Content = scr } });
schema.Items.Add (new XmlSchemaSimpleType () { Name = "UriListType", Content = new XmlSchemaSimpleTypeList () { ItemTypeName = new XmlQualifiedName ("anyURI", XmlSchema.Namespace) } });
schema.Items.Add (new XmlSchemaElement () { Name = "Types", SchemaTypeName = new XmlQualifiedName ("QNameListType", version.Namespace) });
schema.Items.Add (new XmlSchemaElement () { Name = "Scopes", SchemaTypeName = new XmlQualifiedName ("ScopesType", version.Namespace) });
return schema;
}
示例8: CompileLocalAttributes
private void CompileLocalAttributes(XmlSchemaComplexType baseType, XmlSchemaComplexType derivedType, XmlSchemaObjectCollection attributes, XmlSchemaAnyAttribute anyAttribute, XmlSchemaDerivationMethod derivedBy)
{
XmlSchemaAnyAttribute b = (baseType != null) ? baseType.AttributeWildcard : null;
for (int i = 0; i < attributes.Count; i++)
{
XmlSchemaAttribute xa = attributes[i] as XmlSchemaAttribute;
if (xa != null)
{
if (xa.Use != XmlSchemaUse.Prohibited)
{
this.CompileAttribute(xa);
}
if ((xa.Use != XmlSchemaUse.Prohibited) || (((xa.Use == XmlSchemaUse.Prohibited) && (derivedBy == XmlSchemaDerivationMethod.Restriction)) && (baseType != XmlSchemaComplexType.AnyType)))
{
if (derivedType.AttributeUses[xa.QualifiedName] == null)
{
derivedType.AttributeUses.Add(xa.QualifiedName, xa);
}
else
{
base.SendValidationEvent("Sch_DupAttributeUse", xa.QualifiedName.ToString(), xa);
}
}
else
{
base.SendValidationEvent("Sch_AttributeIgnored", xa.QualifiedName.ToString(), xa, XmlSeverityType.Warning);
}
}
else
{
XmlSchemaAttributeGroupRef source = (XmlSchemaAttributeGroupRef) attributes[i];
XmlSchemaAttributeGroup attributeGroup = (XmlSchemaAttributeGroup) this.schema.AttributeGroups[source.RefName];
if (attributeGroup != null)
{
this.CompileAttributeGroup(attributeGroup);
foreach (XmlSchemaAttribute attribute3 in attributeGroup.AttributeUses.Values)
{
if ((attribute3.Use != XmlSchemaUse.Prohibited) || (((attribute3.Use == XmlSchemaUse.Prohibited) && (derivedBy == XmlSchemaDerivationMethod.Restriction)) && (baseType != XmlSchemaComplexType.AnyType)))
{
if (derivedType.AttributeUses[attribute3.QualifiedName] == null)
{
derivedType.AttributeUses.Add(attribute3.QualifiedName, attribute3);
}
else
{
base.SendValidationEvent("Sch_DupAttributeUse", attribute3.QualifiedName.ToString(), source);
}
}
else
{
base.SendValidationEvent("Sch_AttributeIgnored", attribute3.QualifiedName.ToString(), attribute3, XmlSeverityType.Warning);
}
}
anyAttribute = this.CompileAnyAttributeIntersection(anyAttribute, attributeGroup.AttributeWildcard);
}
else
{
base.SendValidationEvent("Sch_UndefAttributeGroupRef", source.RefName.ToString(), source);
}
}
}
if (baseType != null)
{
if (derivedBy == XmlSchemaDerivationMethod.Extension)
{
derivedType.SetAttributeWildcard(this.CompileAnyAttributeUnion(anyAttribute, b));
foreach (XmlSchemaAttribute attribute4 in baseType.AttributeUses.Values)
{
XmlSchemaAttribute attribute5 = (XmlSchemaAttribute) derivedType.AttributeUses[attribute4.QualifiedName];
if (attribute5 != null)
{
if ((attribute5.AttributeSchemaType != attribute4.AttributeSchemaType) || (attribute4.Use == XmlSchemaUse.Prohibited))
{
base.SendValidationEvent("Sch_InvalidAttributeExtension", attribute5);
}
}
else
{
derivedType.AttributeUses.Add(attribute4.QualifiedName, attribute4);
}
}
}
else
{
if ((anyAttribute != null) && ((b == null) || !XmlSchemaAnyAttribute.IsSubset(anyAttribute, b)))
{
base.SendValidationEvent("Sch_InvalidAnyAttributeRestriction", derivedType);
}
else
{
derivedType.SetAttributeWildcard(anyAttribute);
}
foreach (XmlSchemaAttribute attribute6 in baseType.AttributeUses.Values)
{
XmlSchemaAttribute attribute7 = (XmlSchemaAttribute) derivedType.AttributeUses[attribute6.QualifiedName];
if (attribute7 == null)
{
derivedType.AttributeUses.Add(attribute6.QualifiedName, attribute6);
}
else if ((attribute6.Use == XmlSchemaUse.Prohibited) && (attribute7.Use != XmlSchemaUse.Prohibited))
//.........这里部分代码省略.........
示例9: IsProcessContentsRestricted
private bool IsProcessContentsRestricted(XmlSchemaComplexType baseType, XmlSchemaAnyAttribute derivedAttributeWildcard, XmlSchemaAnyAttribute baseAttributeWildcard) {
if (baseType == XmlSchemaComplexType.AnyType) {
return true;
}
if ((int)derivedAttributeWildcard.ProcessContentsCorrect >= (int)baseAttributeWildcard.ProcessContentsCorrect) {
return true;
}
return false;
}
示例10: CompileAnyAttributeIntersection
private XmlSchemaAnyAttribute CompileAnyAttributeIntersection(XmlSchemaAnyAttribute a, XmlSchemaAnyAttribute b) {
if (a == null) {
return b;
}
else if (b == null) {
return a;
}
else {
XmlSchemaAnyAttribute attribute = XmlSchemaAnyAttribute.Intersection(a, b, false); //false is for v1Compat
if (attribute == null) {
SendValidationEvent(Res.Sch_UnexpressibleAnyAttribute, a);
}
return attribute;
}
}
示例11: CompileLocalAttributes
private void CompileLocalAttributes(XmlSchemaComplexType baseType, XmlSchemaComplexType derivedType, XmlSchemaObjectCollection attributes, XmlSchemaAnyAttribute anyAttribute, XmlSchemaDerivationMethod derivedBy) {
XmlSchemaAnyAttribute baseAttributeWildcard = baseType != null ? baseType.AttributeWildcard : null;
for (int i = 0; i < attributes.Count; ++i) {
XmlSchemaAttribute attr = attributes[i] as XmlSchemaAttribute;
if (attr != null) {
if (attr.Use != XmlSchemaUse.Prohibited) {
CompileAttribute(attr);
}
if (attr.Use != XmlSchemaUse.Prohibited ||
(attr.Use == XmlSchemaUse.Prohibited && derivedBy == XmlSchemaDerivationMethod.Restriction && baseType != XmlSchemaComplexType.AnyType)) {
if (derivedType.AttributeUses[attr.QualifiedName] == null) {
derivedType.AttributeUses.Add(attr.QualifiedName, attr);
}
else {
SendValidationEvent(Res.Sch_DupAttributeUse, attr.QualifiedName.ToString(), attr);
}
}
else {
SendValidationEvent(Res.Sch_AttributeIgnored, attr.QualifiedName.ToString(), attr, XmlSeverityType.Warning);
}
}
else { // is XmlSchemaAttributeGroupRef
XmlSchemaAttributeGroupRef attributeGroupRef = (XmlSchemaAttributeGroupRef) attributes[i];
XmlSchemaAttributeGroup attributeGroup = (XmlSchemaAttributeGroup)attributeGroups[attributeGroupRef.RefName];
if (attributeGroup != null) {
CompileAttributeGroup(attributeGroup);
foreach (XmlSchemaAttribute attribute in attributeGroup.AttributeUses.Values) {
if (attribute.Use != XmlSchemaUse.Prohibited ||
(attribute.Use == XmlSchemaUse.Prohibited && derivedBy == XmlSchemaDerivationMethod.Restriction && baseType != XmlSchemaComplexType.AnyType)) {
if (derivedType.AttributeUses[attribute.QualifiedName] == null) {
derivedType.AttributeUses.Add(attribute.QualifiedName, attribute);
}
else {
SendValidationEvent(Res.Sch_DupAttributeUse, attribute.QualifiedName.ToString(), attributeGroupRef);
}
}
else {
SendValidationEvent(Res.Sch_AttributeIgnored, attribute.QualifiedName.ToString(), attribute, XmlSeverityType.Warning);
}
}
anyAttribute = CompileAnyAttributeIntersection(anyAttribute, attributeGroup.AttributeWildcard);
}
else {
SendValidationEvent(Res.Sch_UndefAttributeGroupRef, attributeGroupRef.RefName.ToString(), attributeGroupRef);
}
}
}
// check derivation rules
if (baseType != null) {
if (derivedBy == XmlSchemaDerivationMethod.Extension) {
derivedType.SetAttributeWildcard(CompileAnyAttributeUnion(anyAttribute, baseAttributeWildcard));
foreach(XmlSchemaAttribute attributeBase in baseType.AttributeUses.Values) {
XmlSchemaAttribute attribute = (XmlSchemaAttribute)derivedType.AttributeUses[attributeBase.QualifiedName];
if (attribute == null) {
derivedType.AttributeUses.Add(attributeBase.QualifiedName, attributeBase);
}
else {
Debug.Assert(attribute.Use != XmlSchemaUse.Prohibited);
if (attributeBase.Use != XmlSchemaUse.Prohibited && attribute.AttributeSchemaType != attributeBase.AttributeSchemaType) { //Extension allows previously prohibited attributes to be re-added,
SendValidationEvent(Res.Sch_InvalidAttributeExtension, attribute);
}
}
}
}
else { // derivedBy == XmlSchemaDerivationMethod.Restriction
// Schema Component Constraint: Derivation Valid (Restriction, Complex)
if ((anyAttribute != null) && (baseAttributeWildcard == null || !XmlSchemaAnyAttribute.IsSubset(anyAttribute, baseAttributeWildcard) || !IsProcessContentsRestricted(baseType, anyAttribute, baseAttributeWildcard)) ) {
SendValidationEvent(Res.Sch_InvalidAnyAttributeRestriction, derivedType);
}
else {
derivedType.SetAttributeWildcard(anyAttribute); //complete wildcard
}
// Add form the base
foreach(XmlSchemaAttribute attributeBase in baseType.AttributeUses.Values) {
XmlSchemaAttribute attribute = (XmlSchemaAttribute)derivedType.AttributeUses[attributeBase.QualifiedName];
if (attribute == null) {
derivedType.AttributeUses.Add(attributeBase.QualifiedName, attributeBase);
}
else {
if (attributeBase.Use == XmlSchemaUse.Prohibited && attribute.Use != XmlSchemaUse.Prohibited) {
#if DEBUG
string position = string.Empty;
if (derivedType.SourceUri != null) {
position = " in " + derivedType.SourceUri + "(" + derivedType.LineNumber + ", " + derivedType.LinePosition + ")";
}
Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceError, "Invalid complexType attributes restriction" + position);
Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceError, " Base " + DumpAttributes(baseType.AttributeUses, baseType.AttributeWildcard));
Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceError, " Derived " + DumpAttributes(derivedType.AttributeUses, derivedType.AttributeWildcard));
#endif
SendValidationEvent(Res.Sch_AttributeRestrictionProhibited, attribute);
}
else if (attributeBase.Use == XmlSchemaUse.Required && (attribute.Use != XmlSchemaUse.Required)) { //If base is required, derived should also be required
SendValidationEvent(Res.Sch_AttributeUseInvalid, attribute);
}
else if (attribute.Use == XmlSchemaUse.Prohibited) {
//.........这里部分代码省略.........
示例12: DumpAttributes
private string DumpAttributes(XmlSchemaObjectTable attributeUses, XmlSchemaAnyAttribute attributeWildcard) {
StringBuilder sb = new StringBuilder();
sb.Append("[");
bool first = true;
foreach (XmlSchemaAttribute attribute in attributeUses.Values) {
if (attribute.Use != XmlSchemaUse.Prohibited) {
if (first) {
first = false;
}
else {
sb.Append(" ");
}
sb.Append(attribute.QualifiedName.Name);
if (attribute.Use == XmlSchemaUse.Optional || attribute.Use == XmlSchemaUse.None) {
sb.Append("?");
}
}
}
if (attributeWildcard != null) {
if (attributeUses.Count != 0) {
sb.Append(" ");
}
sb.Append("<");
sb.Append(attributeWildcard.NamespaceList.ToString());
sb.Append(">");
}
sb.Append("] - [");
first = true;
foreach (XmlSchemaAttribute attribute in attributeUses.Values) {
if (attribute.Use == XmlSchemaUse.Prohibited) {
if (first) {
first = false;
}
else {
sb.Append(" ");
}
sb.Append(attribute.QualifiedName.Name);
}
}
sb.Append("]");
return sb.ToString();
}
示例13: Write33_XmlSchemaAnyAttribute
void Write33_XmlSchemaAnyAttribute(XmlSchemaAnyAttribute o) {
if ((object)o == null) return;
WriteStartElement("anyAttribute");
WriteAttribute(@"id", @"", ((System.String)[email protected]));
WriteAttribute("namespace", "", ToString(o.NamespaceList));
XmlSchemaContentProcessing process = [email protected] == [email protected] ? XmlSchemaContentProcessing.Strict : [email protected];
WriteAttribute(@"processContents", @"", Write34_XmlSchemaContentProcessing(process));
WriteAttributes((XmlAttribute[])[email protected], o);
Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)[email protected]);
WriteEndElement();
}
示例14: AddAppSequenceType
static void AddAppSequenceType(DiscoveryVersion discoveryVersion, XmlSchema schema)
{
//<xs:complexType name="AppSequenceType" >
XmlSchemaComplexType appSequenceType = new XmlSchemaComplexType();
appSequenceType.Name = ProtocolStrings.SchemaNames.AppSequenceType;
// <xs:complexContent>
XmlSchemaComplexContent complexContent = new XmlSchemaComplexContent();
appSequenceType.ContentModel = complexContent;
// <xs:restriction base="xs:anyType" >
XmlSchemaComplexContentRestriction contentRestriction = new XmlSchemaComplexContentRestriction();
complexContent.Content = contentRestriction;
contentRestriction.BaseTypeName = discoveryVersion.Implementation.QualifiedNames.AnyType;
// <xs:attribute name="InstanceId" type="xs:unsignedInt" use="required" />
XmlSchemaAttribute instanceId = new XmlSchemaAttribute();
instanceId.Name = ProtocolStrings.SchemaNames.AppSequenceInstanceId;
instanceId.SchemaTypeName = discoveryVersion.Implementation.QualifiedNames.UnsignedIntType;
instanceId.Use = XmlSchemaUse.Required;
// <xs:attribute name="SequenceId" type="xs:anyURI" />
XmlSchemaAttribute sequenceId = new XmlSchemaAttribute();
sequenceId.Name = ProtocolStrings.SchemaNames.AppSequenceSequenceId;
sequenceId.SchemaTypeName = discoveryVersion.Implementation.QualifiedNames.AnyUriType;
// <xs:attribute name="MessageNumber" type="xs:unsignedInt" use="required" />
XmlSchemaAttribute messageNumber = new XmlSchemaAttribute();
messageNumber.Name = ProtocolStrings.SchemaNames.AppSequenceMessageNumber;
messageNumber.SchemaTypeName = discoveryVersion.Implementation.QualifiedNames.UnsignedIntType;
messageNumber.Use = XmlSchemaUse.Required;
// <xs:anyAttribute namespace="##other" processContents="lax" />
XmlSchemaAnyAttribute anyAttribue = new XmlSchemaAnyAttribute();
anyAttribue.Namespace = "##other";
anyAttribue.ProcessContents = XmlSchemaContentProcessing.Lax;
contentRestriction.Attributes.Add(instanceId);
contentRestriction.Attributes.Add(sequenceId);
contentRestriction.Attributes.Add(messageNumber);
contentRestriction.AnyAttribute = anyAttribue;
schema.Items.Add(appSequenceType);
}
示例15: SetAttributeWildcard
internal void SetAttributeWildcard(XmlSchemaAnyAttribute value) {
attributeWildcard = value;
}