public static void unsetReadonly(XmlSourceInfo node)
 {
     if (node.ReadOnly)
     {
         node.ReadOnly = false;
     }
 }
 public static void DropDocument(XmlSourceInfo firstChild, XmlDocumentLineInfo replaceMent)
 {
     if (firstChild == null)
     {
         return;
     }
     firstChild.SetOwnerDocument(replaceMent);
 }
        public void CheckNode(XmlNode node)
        {
            if (SetNodesReadOnly)
            {
                XmlSourceInfo xmlSourceInfo = node as XmlSourceInfo;
                if (xmlSourceInfo != null)
                {
                    if (!node.IsReadOnly || !xmlSourceInfo.ReadOnly)
                    {
                        xmlSourceInfo.ReadOnly = true;
                    }
                }
            }
            return;

            if (node.NodeType == XmlNodeType.Text)
            {
                return;
            }
            if (node.NodeType == XmlNodeType.Comment)
            {
                return;
            }
            if (node.NodeType == XmlNodeType.Element)
            {
                return;
            }
            if (node.NodeType == XmlNodeType.Attribute)
            {
                return;
            }
            if (node.NodeType == XmlNodeType.XmlDeclaration)
            {
                return;
            }
            string s = node.OuterXml;

            writeToLog("checknode: " + s);
            //if (node.NodeType == XmlNodeType.XmlDeclaration) return;
            if (s.Contains("l:") || s.Contains("nls"))
            {
                return;
            }
        }
        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);
        }
示例#5
0
 public static void unsetReadonly(XmlSourceInfo node)
 {
     if (node.ReadOnly)
     {
         node.ReadOnly = false;
     }
 }