Beispiel #1
0
        //private NodePath( int level, Entry[] entries ) {
        //    Level = level;
        //    _entries = entries;
        //}



        public static LdmlAttributeValue[] ParseAttrs(string attrText, List <LdmlAttributeValue> attrList)
        {
            int idx = attrText.IndexOf('=');

            if (idx > 0)
            {
                string        name     = attrText.Substring(1, idx - 1);
                LdmlAttribute attrName = LdmlUtil.GetAttribute(name);
                string        value    = attrText.Substring(idx + 1);
                if (value.Length > 2)
                {
                    if (value[0] == '\'' && value[value.Length - 1] == '\'')
                    {
                        value = value.Substring(1, value.Length - 2);
                        attrList.Add(new LdmlAttributeValue(attrName, value));
                    }
                    else
                    {
                        Debug.WriteLine(value);
                    }
                }
            }
            return(attrList.ToArray());
        }
Beispiel #2
0
        public void Load(string nodeName, LdmlDocument document, XmlReader reader, LdmlNode parent)
        {
            _document = document;
            _parent   = parent;
            _code     = nodeName;

            if (reader.MoveToFirstAttribute())
            {
                List <LdmlAttributeValue> list = null;
                while (true)
                {
                    string        name  = reader.Name;
                    string        value = reader.Value;
                    LdmlAttribute attr  = LdmlUtil.GetAttribute(name);
                    if (attr == LdmlAttribute.Draft)
                    {
                        _draftStatus = CldrUtil.GetDraftStatus(value);
                    }
                    else if (!HandleAttribute(attr, value))
                    {
                        if (list == null)
                        {
                            list = new List <LdmlAttributeValue>();
                        }
                        list.Add(new LdmlAttributeValue(attr, value));
                    }



                    if (!reader.MoveToNextAttribute())
                    {
                        break;
                    }
                }
                reader.MoveToElement();
                if (list != null)
                {
                    Attributes = list.ToArray();
                }
            }
            //ReadChildren( reader );

            if (reader.IsEmptyElement)
            {
                return;
            }
            while (reader.Read())
            {
                var type = reader.NodeType;
                if (type == XmlNodeType.Element)
                {
                    if (reader.Name == "alias")
                    {
                        _document.ReadAlias(reader, this);
                    }
                    else
                    {
                        _document.ReadNode(reader, this);
                        //_nodes.Add( node );
                    }
                }
                else if (type == XmlNodeType.Text)
                {
                    _value = reader.Value;
                }
                else if (type == XmlNodeType.EndElement)
                {
                    break;
                }
            }
        }