The ClosedScheme class provides an extened implementation of CachedScheme that implements the IEnumerable and IMatchable interfaces.
Inheritance: CachedScheme, IEnumerable, IMatchable
Beispiel #1
0
        /// <summary>
        /// Parses the XML data file indicated by the URI to extract default sets
        /// of closed schemes.
        /// </summary>
        /// <param name="uri">The URI of the source XML document.</param>
        public void Parse(string uri)
        {
            CachedScheme scheme      = null;
            string       code        = null;
            string       source      = null;
            string       description = null;
            string       text        = null;
            XmlReader    reader      = new XmlTextReader(uri);

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                {
                    if (reader.LocalName.Equals("scheme"))
                    {
                        if (reader ["uri"] != null)
                        {
                            if (reader ["canonicalUri"] != null)
                            {
                                Add(scheme = new ClosedScheme(reader ["uri"], reader ["canonicalUri"]));
                            }
                            else
                            {
                                Add(scheme = new ClosedScheme(reader ["uri"]));
                            }

                            log.Debug("Added scheme " + reader ["uri"]);
                        }
                        else
                        {
                            log.Warn("uri attribute missing from scheme in bootstrap definitions");
                            scheme = null;
                        }
                    }
                    else if (reader.LocalName.Equals("schemeValue"))
                    {
                        if (reader ["name"] != null)
                        {
                            code = reader ["name"];
                        }
                        else
                        {
                            log.Warn("name attribute missing from schemeValue in bootstrap definitions");
                            code = null;
                        }

                        source      = reader ["schemeValueSource"];
                        description = null;

                        if (reader.IsEmptyElement)
                        {
                            if ((scheme != null) && (code != null))
                            {
                                scheme.Add(new Value(code, source, description));
                            }
                        }
                    }
                    else if (reader.LocalName.Equals("paragraph"))
                    {
                        text = null;
                    }
                    break;
                }

                case XmlNodeType.EndElement:
                {
                    if (reader.LocalName.Equals("schemeValue"))
                    {
                        if ((scheme != null) && (code != null))
                        {
                            scheme.Add(new Value(code, source, description));
                        }
                    }
                    else if (reader.LocalName.Equals("paragraph"))
                    {
                        if (description == null)
                        {
                            description = text.Trim();
                        }
                    }

                    break;
                }

                case XmlNodeType.Text:
                {
                    text = reader.Value;
                    break;
                }
                }
            }
            reader.Close();
        }
        /// <summary>
        /// Parses the XML data file indicated by the URI to extract default sets
        /// of closed schemes.
        /// </summary>
        /// <param name="uri">The URI of the source XML document.</param>
        public void Parse(string uri)
        {
            CachedScheme	scheme		= null;
            string			code		= null;
            string			source		= null;
            string			description	= null;
            string			text		= null;
            XmlReader		reader		= new XmlTextReader (uri);

            while (reader.Read ()) {
                switch (reader.NodeType) {
                case XmlNodeType.Element:
                    {
                        if (reader.LocalName.Equals ("scheme")) {
                            if (reader ["uri"] != null) {
                                if (reader ["canonicalUri"] != null)
                                    Add (scheme = new ClosedScheme (reader ["uri"], reader ["canonicalUri"]));
                                else
                                    Add (scheme = new ClosedScheme (reader ["uri"]));

                                log.Debug ("Added scheme " + reader ["uri"]);
                            }
                            else {
                                log.Warn ("uri attribute missing from scheme in bootstrap definitions");
                                scheme = null;
                            }
                        }
                        else if (reader.LocalName.Equals ("schemeValue")) {
                            if (reader ["name"] != null)
                                code = reader ["name"];
                            else {
                                log.Warn ("name attribute missing from schemeValue in bootstrap definitions");
                                code = null;
                            }

                            source = reader ["schemeValueSource"];
                            description = null;

                            if (reader.IsEmptyElement) {
                                if ((scheme != null) && (code != null)) {
                                    scheme.Add (new Value (code, source, description));
                                }
                            }
                        }
                        else if (reader.LocalName.Equals ("paragraph"))
                            text = null;
                        break;
                    }

                case XmlNodeType.EndElement:
                    {
                        if (reader.LocalName.Equals ("schemeValue")) {
                            if ((scheme != null) && (code != null)) {
                                scheme.Add (new Value (code, source, description));
                            }
                        }
                        else if (reader.LocalName.Equals ("paragraph")) {
                            if (description == null)
                                description = text.Trim ();
                        }

                        break;
                    }

                case XmlNodeType.Text:
                    {
                        text = reader.Value;
                        break;
                    }
                }
            }
            reader.Close ();
        }