AddParticle() 공개 메소드

public AddParticle ( XmlSchemaAttribute elem ) : void
elem System.Xml.Schema.XmlSchemaAttribute
리턴 void
예제 #1
0
        public Shape GenerateFromSchema(XmlSchemaAttribute xsa)
        {
            Shape s = new Shape(GenName(xsa.QualifiedName), BindingType.Attribute);

            s.AddParticle(xsa);
            return(s);
        }
예제 #2
0
        Shape ProcessParticleElement(XmlSchemaElement xse)
        {
            // watch out for recursive schema
            Shape s = (Shape)this.elementTypesProcessed[xse];

            if (null != s)
            {
                return(s);
            }

            bool complex = xse.ElementSchemaType is XmlSchemaComplexType;

            s = new Shape(GenName(xse.QualifiedName), complex ? BindingType.ElementNested : BindingType.Element);
            s.AddParticle(xse);

            if (complex)
            {
                this.elementTypesProcessed.Add(xse, s);
                s.NestedShape = GenerateFromSchema(xse);
                this.elementTypesProcessed.Remove(xse);
            }
            return(s);
        }
예제 #3
0
        public Shape GenerateFromSchema(XmlSchemaElement xse)
        {
            XmlQualifiedName     xseName     = xse.QualifiedName;
            XmlSchemaType        schemaType  = xse.ElementSchemaType;
            XmlSchemaComplexType complexType = schemaType as XmlSchemaComplexType;

            if (null != complexType)
            {
                XmlSchemaParticle particle  = null;
                Shape             rootShape = null;

                XmlSchemaContentType contentType = complexType.ElementDecl.ContentValidator.ContentType;
                switch (contentType)
                {
                case XmlSchemaContentType.Mixed:
                case XmlSchemaContentType.TextOnly:
                    rootShape = new Shape(GenName(xseName) + "_Text", BindingType.Text);
                    rootShape.AddParticle(xse);
                    break;

                case XmlSchemaContentType.Empty:
                    rootShape = new Shape(null, BindingType.Sequence);
                    break;

                case XmlSchemaContentType.ElementOnly:
                    particle  = complexType.ContentTypeParticle;
                    rootShape = ProcessParticle(particle, null);
                    break;
                }

                Debug.Assert(rootShape != null);
                if (complexType.AttributeUses.Values.Count > 0)
                {
                    if (rootShape.BindingType != BindingType.Sequence)
                    {
                        Shape s = new Shape(null, BindingType.Sequence);
                        s.AddSubShape(rootShape);
                        rootShape = s;
                    }
                    int      pos   = 0;
                    string[] names = rootShape.SubShapeNames();

                    ICollection          attributes = complexType.AttributeUses.Values;
                    XmlSchemaAttribute[] xsaArray   = new XmlSchemaAttribute[attributes.Count];
                    attributes.CopyTo(xsaArray, 0);
                    Array.Sort(xsaArray, new XmlSchemaAttributeComparer());
                    foreach (XmlSchemaAttribute xsa in xsaArray)
                    {
                        string name      = GenAttrName(xsa.QualifiedName, names);
                        Shape  attrShape = new Shape(name, BindingType.Attribute);
                        attrShape.AddParticle(xsa);
                        rootShape.AddAttrShapeAt(attrShape, pos++);
                    }
                }

                if (rootShape.BindingType != BindingType.Text)
                {
                    rootShape.Name          = GenName(xseName);
                    rootShape.ContainerDecl = xse;
                }
                return(rootShape);
            }
            else   // simple type
            {
                Shape s = new Shape(GenName(xseName), BindingType.Text);
                s.AddParticle(xse);
                return(s);
            }
        }
예제 #4
0
 public Shape GenerateFromSchema(XmlSchemaAttribute xsa) {
     Shape s = new Shape(GenName(xsa.QualifiedName), BindingType.Attribute);
     s.AddParticle(xsa);
     return s;
 }
예제 #5
0
        public Shape GenerateFromSchema(XmlSchemaElement xse) {
            XmlQualifiedName xseName = xse.QualifiedName;
            XmlSchemaType schemaType = xse.ElementSchemaType;
            XmlSchemaComplexType complexType = schemaType as XmlSchemaComplexType;
            if (null != complexType) {
                XmlSchemaParticle particle = null;
                Shape rootShape = null;
                
                XmlSchemaContentType contentType = complexType.ElementDecl.ContentValidator.ContentType;
                switch (contentType) {
                    case XmlSchemaContentType.Mixed:
                    case XmlSchemaContentType.TextOnly:
                        rootShape = new Shape(GenName(xseName) + "_Text", BindingType.Text);
                        rootShape.AddParticle(xse);
                    break;

                    case XmlSchemaContentType.Empty:
                        rootShape = new Shape(null, BindingType.Sequence);
                        break;

                    case XmlSchemaContentType.ElementOnly:
                        particle = complexType.ContentTypeParticle;
                        rootShape = ProcessParticle(particle, null);
                    break;

                }
            
                Debug.Assert(rootShape != null);
                if (complexType.AttributeUses.Values.Count > 0) {
                    if (rootShape.BindingType != BindingType.Sequence) {
                        Shape s = new Shape(null, BindingType.Sequence);
                        s.AddSubShape(rootShape);
                        rootShape = s;
                    }
                    int pos = 0;
                    string[] names = rootShape.SubShapeNames();

                    ICollection attributes = complexType.AttributeUses.Values;
                    XmlSchemaAttribute[] xsaArray = new XmlSchemaAttribute[attributes.Count];
                    attributes.CopyTo(xsaArray, 0);
                    Array.Sort(xsaArray, new XmlSchemaAttributeComparer());
                    foreach(XmlSchemaAttribute xsa in xsaArray) {
                        string name = GenAttrName(xsa.QualifiedName, names);
                        Shape attrShape = new Shape(name, BindingType.Attribute);
                        attrShape.AddParticle(xsa);
                        rootShape.AddAttrShapeAt(attrShape, pos++);
                    }
                }
                
                if (rootShape.BindingType != BindingType.Text) {
                    rootShape.Name = GenName(xseName);
                    rootShape.ContainerDecl = xse;
                }
                return rootShape;
            }
            else { // simple type
                Shape s = new Shape(GenName(xseName), BindingType.Text);
                s.AddParticle(xse);
                return s;
            }
        }
예제 #6
0
        Shape ProcessParticleElement(XmlSchemaElement xse) {
            // watch out for recursive schema
            Shape s = (Shape)this.elementTypesProcessed[xse];
            if (null != s)
                return s;

            bool complex = xse.ElementSchemaType is XmlSchemaComplexType; 
            s = new Shape(GenName(xse.QualifiedName), complex ? BindingType.ElementNested : BindingType.Element);
            s.AddParticle(xse);
            
            if (complex) {
                this.elementTypesProcessed.Add(xse, s);
                s.NestedShape = GenerateFromSchema(xse);
                this.elementTypesProcessed.Remove(xse);
            }
            return s;
        }