コード例 #1
0
        private QuickFix[] GetInsertFixes(XmlElement e)
        {
            if (e == null)
            {
                return new QuickFix[] {}
            }
            ;

            XmlElement parent = e.ParentNode as XmlElement;

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

            ValidationEngine ve = new ValidationEngine(documentType, null);

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

            ArrayList ret = new ArrayList();

            foreach (ElementListItem eli in possibles)
            {
                if (eli.IsRequired)
                {
                    QuickFixInsert qfi = new QuickFixInsert(e, eli.Name);
                    ret.Add(qfi);
                }
            }
            return(ret.ToArray(typeof(QuickFix)) as QuickFix[]);
        }
コード例 #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[]);
        }
コード例 #3
0
ファイル: QuickFix.cs プロジェクト: jugglingcats/XEditNet
        private QuickFix[] GetInsertFixes(XmlElement e)
        {
            if ( e == null )
                return new QuickFix[] {};

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

            ValidationEngine ve=new ValidationEngine(documentType, null);
            // get candidate replacements
            ElementListItem[] possibles=ve.GetValidElements(parent, e, false);

            ArrayList ret=new ArrayList();
            foreach ( ElementListItem eli in possibles )
            {
                if ( eli.IsRequired )
                {
                    QuickFixInsert qfi=new QuickFixInsert(e, eli.Name);
                    ret.Add(qfi);
                }
            }
            return ret.ToArray(typeof(QuickFix)) as QuickFix[];
        }
コード例 #4
0
ファイル: QuickFix.cs プロジェクト: jugglingcats/XEditNet
        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[];
        }