Example #1
0
        private QuickFix[] GetChangeFixes(XmlElement e)
        {
            if (e == null)
            {
                return new QuickFix[] {}
            }
            ;

            XmlElement parent = e.ParentNode as XmlElement;

            // TODO: E: entities!
            if (parent == null)
            {
                return new QuickFix[] {}
            }
            ;

            // TODO: M: refactor - shouldn't need to pass null here
            //			(some of the ve methods have no callback - new class?)
            ValidationEngine ve = new ValidationEngine(documentType, null);

            // get candidate replacements
            ElementListItem[] possibles = ve.GetValidElements(parent, e, true);

            ArrayList children = new ArrayList();

            foreach (XmlNode n in e.ChildNodes)
            {
                children.Add(n);
            }

            ArrayList ret = new ArrayList();

            foreach (ElementListItem eli in possibles)
            {
                // TODO: M: error checking (should never be null though)
                ElementType et = documentType[eli.Name];
                if (ve.IsValid(et, children))
                {
                    QuickFixChange qfc = new QuickFixChange(e, eli.Name);
                    ret.Add(qfc);
                }
            }
            return(ret.ToArray(typeof(QuickFix)) as QuickFix[]);
        }
Example #2
0
        private QuickFix[] GetChangeFixes(XmlElement e)
        {
            if ( e == null )
                return new QuickFix[] {};

            XmlElement parent=e.ParentNode as XmlElement;
            // TODO: E: entities!
            if ( parent == null )
                return new QuickFix[] {};

            // TODO: M: refactor - shouldn't need to pass null here
            //			(some of the ve methods have no callback - new class?)
            ValidationEngine ve=new ValidationEngine(documentType, null);
            // get candidate replacements
            ElementListItem[] possibles=ve.GetValidElements(parent, e, true);

            ArrayList children=new ArrayList();
            foreach ( XmlNode n in e.ChildNodes )
                children.Add(n);

            ArrayList ret=new ArrayList();
            foreach ( ElementListItem eli in possibles )
            {
                // TODO: M: error checking (should never be null though)
                ElementType et=documentType[eli.Name];
                if ( ve.IsValid(et, children) )
                {
                    QuickFixChange qfc=new QuickFixChange(e, eli.Name);
                    ret.Add(qfc);
                }
            }
            return ret.ToArray(typeof(QuickFix)) as QuickFix[];
        }