Example #1
0
        //public LdmlNode[] XRef {
        //    get;
        //    set;
        //}


        internal LdmlNode Clone(LdmlDocument doc)
        {
            LdmlNode cloned = (LdmlNode)MemberwiseClone();

            cloned._document = doc;
            cloned._children = null;
            cloned._nodes    = EmptyArray;
            //if ( Name == "dayPeriodWidth" ) {
            //    Debug.WriteLine( Value );
            //}
            if (_parent != null)
            {
                LdmlNode myNode = _parent.FindCousin(doc);
                if (myNode == null)
                {
                    myNode = _parent.Clone(doc);
                }
                cloned._parent = myNode;
                doc.SetParent(cloned, myNode);
                //myNode.Nodes.Add( cloned );
            }
            else
            {
                doc.SetRootNode(cloned);
            }
            return(cloned);
        }
Example #2
0
 protected LdmlDocument(CldrLoader loader, LdmlDocument parent, string name)
 {
     _nodes[""]    = _nodes["/"] = null;
     _parent       = parent;
     Loader        = loader;
     Name          = name;
     _parencyNodes = new Dictionary <LdmlNode, List <LdmlNode> >(this);
 }
Example #3
0
        internal LdmlNode SelectNode(LdmlDocument document)
        {
            if (Level != 0 || _entries.Length == 0 || _entries[0].Attributes.Length != 0)
            {
                return(null);
            }
            LdmlNode root = document.ResolveRootNode(_entries[0].Name);

            for (int i = 1; root != null && i < _entries.Length; i++)
            {
                root = root.SelectNode(_entries[i].Name, _entries[i].Attributes);
            }
            return(root);
        }
Example #4
0
        internal LdmlNode FindCousin(LdmlDocument doc)
        {
            if (Parent == null)
            {
                return(doc.GetRootNode(Name));
            }
            var parent = Parent.FindCousin(doc);

            if (parent != null)
            {
                foreach (var node in parent._nodes)
                {
                    if (SameNode(node))
                    {
                        return(node);
                    }
                }
            }
            return(null);
        }
Example #5
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;
                }
            }
        }