1using System.Collections.Generic;
11 private readonly StringBuilder output =
new StringBuilder();
12 private readonly Dictionary<string, string> namespceByPrefix =
new Dictionary<string, string>();
13 private readonly LinkedList<LinkedList<KeyValuePair<string, string>>> prefixStack =
new LinkedList<LinkedList<KeyValuePair<string, string>>>();
14 private LinkedList<KeyValuePair<string, string>> newPrefixes =
null;
29 this.output.Append(s);
38 this.output.Append(ch);
47 return this.output.ToString();
58 if (this.namespceByPrefix.TryGetValue(Prefix, out
string PrevNamespace))
60 if (PrevNamespace == Namespace)
66 if (this.newPrefixes is
null)
67 this.newPrefixes =
new LinkedList<KeyValuePair<string, string>>();
69 this.newPrefixes.AddLast(
new KeyValuePair<string, string>(Prefix, PrevNamespace));
70 this.namespceByPrefix[Prefix] = Namespace;
80 this.prefixStack.AddLast(this.newPrefixes);
81 this.newPrefixes =
null;
89 if (this.prefixStack.Last is
null)
92 LinkedList<KeyValuePair<string, string>> ToRemove = this.prefixStack.Last.Value;
93 this.prefixStack.RemoveLast();
95 if (!(ToRemove is
null))
97 foreach (KeyValuePair<string, string> P
in ToRemove)
100 this.namespceByPrefix.Remove(P.Key);
102 this.namespceByPrefix[P.Key] = P.Value;
Current state of XML normalization process.
void PushPrefixes()
Pushes current prefix state to the stack.
bool RegisterPrefix(string Prefix, string Namespace)
Registers prefix for element.
XmlNormalizationState()
Current state of XML normalization process.
void Append(char ch)
Appends a character to the output.
override string ToString()
XML output.
void PopPrefixes()
Pops previous prefix state from the stack.
void Append(string s)
Appends a string to the output.