public static void chopParent(XmlNode chilz)
        {
            XmlNode p = chilz.ParentNode;

            if (p == null)
            {
                return;
            }
            LineInfoElementImpl lie = p as LineInfoElementImpl;

            if (!p.IsReadOnly || lie == null)
            {
                p.RemoveChild(chilz);
                return;
            }
            bool liewas = lie.ReadOnly;

            try
            {
                lie.ReadOnly = false;
                lie.RemoveChild(chilz);
            }
            finally
            {
                lie.ReadOnly = liewas;
            }
        }
 public static void unsetReadonly(LineInfoElementImpl node)
 {
     if (node.ReadOnly)
     {
         node.ReadOnly = false;
     }
 }
        public override XmlElement CreateElement(string prefix, string localName, string namespaceURI)
        {
            prefix       = Intern(prefix);
            localName    = Intern(localName);
            namespaceURI = Intern(namespaceURI);

            LineInfoElementImpl elem;
            string nodeTypeString = "Element";
            string name           = null;

            TransformElement(ref nodeTypeString, ref prefix, ref localName, ref name, ref namespaceURI);
            bool prev = MustSpaceWildcards;
            bool mustPReserveWhitespace = PreserveWhitespace;

            try
            {
                if (MustFormat.Contains(localName))
                {
                    MustSpaceWildcards = true;
                }
                if (MustNotReFormat.Contains(localName))
                {
                    MustSpaceWildcards = false;
                }
                if (MustPreserveWhitespace.Contains(localName))
                {
                    PreserveWhitespace = true;
                }
                else
                {
                    if (PreserveWhitespace)
                    {
                        //  PreserveWhitespace = false;
                    }
                }
                // prevNodeType = currentNodeType;
                currentNodeType = localName;
                elem            = new LineInfoElementImpl(prefix, localName, namespaceURI, this);
                IsFakingEmpty   = false;
            }
            finally
            {
                // currentNodeType = prev;
            }
            setLineInfo(elem);
            return(elem);
        }
        public void SetParentFromNode(XmlNode xmlNode)
        {
            XmlNode pn = xmlNode.ParentNode;

            if (pn is LineInfoElementImpl)
            {
                lParent = (LineInfoElementImpl)pn;
            }
            if (!(xmlNode is LineInfoElementImpl))
            {
                xmlNode = lParent as XmlNode;
            }
            if (xmlNode is LineInfoElementImpl)
            {
                LineInfoElementImpl lie = (LineInfoElementImpl)xmlNode;
            }
        }
        public void SetParentFromNode(XmlNode xmlNode)
        {
            XmlNode pn = xmlNode.ParentNode;

            if (pn is LineInfoElementImpl)
            {
                lParent = (LineInfoElementImpl)pn;
                XmlDocumentLineInfo.SuggestLineNo(lParent, this);
            }
            if (!(xmlNode is IXmlLineInfo))
            {
                xmlNode = (XmlNode)lParent;
            }
            if (xmlNode is LineInfoElementImpl)
            {
                LineInfoElementImpl lie = (LineInfoElementImpl)xmlNode;
                lineNumData = lie;
                XmlDocumentLineInfo.SuggestLineNo(lie, this);
            }
        }
        public override XmlNode CloneNode(bool deep)
        {
            XmlNode highestClone = CloneOf ?? this;;
            var     od           = highestClone.OwnerDocument as XmlDocumentLineInfo;
            //od.Normalize();
            LineInfoElementImpl newnode = new LineInfoElementImpl(Prefix, LocalName, NamespaceURI, od);

            newnode.CloneOf = highestClone;
#if OUTXML_CACHE
            newnode.outerXMLCache = outerXMLCache;
#endif
            newnode.SetLineInfo(LineNumber, LinePosition, Filename);
            if (deep)
            {
                bool newnodeWas = newnode.protect;
                newnode.protect = false;
                if (HasChildNodes)
                {
                    foreach (XmlNode a in ChildNodes)
                    {
                        try
                        {
                            XmlNode       a2   = a.CloneNode(deep);
                            bool          a2ro = a2.IsReadOnly;
                            XmlSourceInfo a22  = a2 as XmlSourceInfo;
                            if (a22 != null)
                            {
                                a22.ReadOnly = false;
                            }
                            newnode.AppendChild(a2);
                            if (a22 != null)
                            {
                                a22.ReadOnly = a2ro;
                            }
                        }
                        catch (Exception e)
                        {
                            writeToLog("ERROR: newnode.AppendChild " + e);
                        }
                    }
                }
                XmlAttributeCollection ats = Attributes;
                if (ats != null)
                {
                    foreach (XmlAttribute a in ats)
                    {
                        try
                        {
                            if (XmlDocumentLineInfo.SkipXmlns && a.Name == "xmlns")
                            {
                                continue;
                            }
                            XmlAttribute  a2   = (XmlAttribute)newnode.docLineInfo.CreateAttribute(a.Name);// a.CloneNode(deep);
                            bool          a2ro = a2.IsReadOnly;
                            XmlSourceInfo a22  = a2 as XmlSourceInfo;
                            if (a22 != null)
                            {
                                a22.ReadOnly = false;
                            }
                            a2.Value = a.Value;
                            newnode.Attributes.Append(a2);
                            if (a22 != null)
                            {
                                a22.ReadOnly = a2ro;
                            }
                        }
                        catch (Exception e)
                        {
                            newnode.writeToLog("ERROR: newnode.AppendChild " + e);
                        }
                    }
                }
                newnode.protect = newnodeWas;
            }
            else
            {
                XmlAttributeCollection ats = Attributes;
                if (ats != null)
                {
                    foreach (XmlAttribute a in ats)
                    {
                        try
                        {
                            if (XmlDocumentLineInfo.SkipXmlns && a.Name == "xmlns")
                            {
                                continue;
                            }
                            XmlAttribute  a2   = (XmlAttribute)a.CloneNode(deep);
                            bool          a2ro = a2.IsReadOnly && false;
                            XmlSourceInfo a22  = a2 as XmlSourceInfo;
                            if (a22 != null)
                            {
                                a22.ReadOnly = false;
                            }
                            newnode.Attributes.Append(a2);
                            if (a22 != null)
                            {
                                a22.ReadOnly = a2ro;
                            }
                        }
                        catch (Exception e)
                        {
                            newnode.writeToLog("ERROR: newnode.AppendChild " + e);
                        }
                    }
                }
                newnode.protect = false;
            }
            return(newnode);
        }
 internal void SetParent(LineInfoElementImpl pn)
 {
     lParent = pn;
 }
Ejemplo n.º 8
0
 public static void unsetReadonly(LineInfoElementImpl node)
 {
     if (node.ReadOnly)
     {
         node.ReadOnly = false;
     }
 }
Ejemplo n.º 9
0
        public override XmlNode CloneNode(bool deep)
        {
            XmlNode highestClone = CloneOf ?? this; ;
            var od = highestClone.OwnerDocument as XmlDocumentLineInfo;
            //od.Normalize();
            LineInfoElementImpl newnode = new LineInfoElementImpl(Prefix, LocalName, NamespaceURI, od);
            newnode.CloneOf = highestClone;
#if OUTXML_CACHE      
            newnode.outerXMLCache = outerXMLCache;
#endif
            newnode.SetLineInfo(LineNumber, LinePosition, Filename);
            if (deep)
            {
                bool newnodeWas = newnode.protect;
                newnode.protect = false;
                if (HasChildNodes)
                    foreach (XmlNode a in ChildNodes)
                    {
                        try
                        {
                            XmlNode a2 = a.CloneNode(deep);
                            bool a2ro = a2.IsReadOnly;
                            XmlSourceInfo a22 = a2 as XmlSourceInfo;
                            if (a22 != null) a22.ReadOnly = false;
                            newnode.AppendChild(a2);
                            if (a22 != null) a22.ReadOnly = a2ro;
                        }
                        catch (Exception e)
                        {
                            writeToLog("ERROR: newnode.AppendChild " + e);
                        }
                    }
                XmlAttributeCollection ats = Attributes;
                if (ats != null)
                    foreach (XmlAttribute a in ats)
                    {
                        try
                        {
                            if (XmlDocumentLineInfo.SkipXmlns && a.Name == "xmlns") continue;
                            XmlAttribute a2 = (XmlAttribute) newnode.docLineInfo.CreateAttribute(a.Name);// a.CloneNode(deep);
                            bool a2ro = a2.IsReadOnly;
                            XmlSourceInfo a22 = a2 as XmlSourceInfo;
                            if (a22 != null) a22.ReadOnly = false;
                            a2.Value = a.Value;
                            newnode.Attributes.Append(a2);
                            if (a22 != null) a22.ReadOnly = a2ro;
                        }
                        catch (Exception e)
                        {
                            newnode.writeToLog("ERROR: newnode.AppendChild " + e);
                        }
                    }
                newnode.protect = newnodeWas;
            }
            else
            {
                XmlAttributeCollection ats = Attributes;
                if (ats != null)
                    foreach (XmlAttribute a in ats)
                    {
                        try
                        {
                            if (XmlDocumentLineInfo.SkipXmlns && a.Name == "xmlns") continue;
                            XmlAttribute a2 = (XmlAttribute)a.CloneNode(deep);
                            bool a2ro = a2.IsReadOnly && false;
                            XmlSourceInfo a22 = a2 as XmlSourceInfo;
                            if (a22 != null) a22.ReadOnly = false;
                            newnode.Attributes.Append(a2);
                            if (a22 != null) a22.ReadOnly = a2ro;
                        }
                        catch (Exception e)
                        {
                            newnode.writeToLog("ERROR: newnode.AppendChild " + e);
                        }
                    }
                newnode.protect = false;
            }
            return newnode;
        }
Ejemplo n.º 10
0
 internal void SetParent(LineInfoElementImpl pn)
 {
     lParent = pn;
 }