public void Write( StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc) { docPos = DocPosition.BeforeRootElement; foreach (XmlNode childNode in this.ChildNodes) { if (childNode.NodeType == XmlNodeType.Element) { CanonicalizationDispatcher.Write(childNode, strBuilder, DocPosition.InRootElement, anc); docPos = DocPosition.AfterRootElement; } else { CanonicalizationDispatcher.Write(childNode, strBuilder, docPos, anc); } } }
public void Write( StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc) { Hashtable nsLocallyDeclared = new Hashtable(); SortedList sortedList = new SortedList((IComparer) new NamespaceSortOrder()); SortedList attrListToRender = new SortedList((IComparer) new AttributeSortOrder()); XmlAttributeCollection attributes = this.Attributes; if (attributes != null) { foreach (XmlAttribute attr in (XmlNamedNodeMap)attributes) { if (((CanonicalXmlAttribute)attr).IsInNodeSet || Exml.IsNamespaceNode((XmlNode)attr) || Exml.IsXmlNamespaceNode((XmlNode)attr)) { if (Exml.IsNamespaceNode((XmlNode)attr)) { anc.TrackNamespaceNode(attr, sortedList, nsLocallyDeclared); } else if (Exml.IsXmlNamespaceNode((XmlNode)attr)) { anc.TrackXmlNamespaceNode(attr, sortedList, attrListToRender, nsLocallyDeclared); } else if (this.IsInNodeSet) { attrListToRender.Add((object)attr, (object)null); } } } } if (!CanonicalXmlNodeList.IsCommittedNamespace((XmlElement)this, this.Prefix, this.NamespaceURI)) { XmlAttribute attribute = this.OwnerDocument.CreateAttribute(this.Prefix.Length > 0 ? "xmlns:" + this.Prefix : "xmlns"); attribute.Value = this.NamespaceURI; anc.TrackNamespaceNode(attribute, sortedList, nsLocallyDeclared); } if (this.IsInNodeSet) { anc.GetNamespacesToRender((XmlElement)this, attrListToRender, sortedList, nsLocallyDeclared); strBuilder.Append("<" + this.Name); foreach (object key in (IEnumerable)sortedList.GetKeyList()) { (key as CanonicalXmlAttribute).Write(strBuilder, docPos, anc); } foreach (object key in (IEnumerable)attrListToRender.GetKeyList()) { (key as CanonicalXmlAttribute).Write(strBuilder, docPos, anc); } strBuilder.Append(">"); } anc.EnterElementContext(); anc.LoadUnrenderedNamespaces(nsLocallyDeclared); anc.LoadRenderedNamespaces(sortedList); foreach (XmlNode childNode in this.ChildNodes) { CanonicalizationDispatcher.Write(childNode, strBuilder, docPos, anc); } anc.ExitElementContext(); if (!this.IsInNodeSet) { return; } strBuilder.Append("</" + this.Name + ">"); }