提交 2e0e15d7 编写于 作者: A Atsushi Eno

Adjust namespace prefix indexes as it is repeatedly used. (It could result in duplicate prefix.)

上级 fc73d187
......@@ -36,16 +36,13 @@ namespace System.Xml
{
static readonly Encoding utf8_unmarked = new UTF8Encoding (false);
int depth;
protected XmlDictionaryWriter ()
{
}
internal int Depth {
get { return depth; }
set { depth = value; }
}
internal int Depth { get; set; }
internal int NSIndex { get; set; }
public virtual bool CanCanonicalize {
get { return false; }
......@@ -138,6 +135,8 @@ namespace System.Xml
return CreateDictionaryWriter (XmlWriter.Create (stream, s));
}
public virtual void EndCanonicalization ()
{
throw new NotSupportedException ();
......@@ -388,8 +387,10 @@ namespace System.Xml
// writer how it is determined in the output. (When
// there is a duplicate, then it will be further
// modified.)
if (prefix == null)
prefix = "d" + Depth + "p1";
if (prefix == null && String.IsNullOrEmpty (namespaceUri))
prefix = String.Empty;
else if (prefix == null)
prefix = "d" + Depth + "p" + (++NSIndex);
if (prefix == String.Empty)
WriteAttributeString ("xmlns", namespaceUri);
......
......@@ -105,6 +105,7 @@ namespace System.Xml
public override void WriteEndElement ()
{
Depth--;
NSIndex = 0;
writer.WriteEndElement ();
}
......@@ -171,6 +172,7 @@ namespace System.Xml
public override void WriteStartElement (string prefix, string localName, string ns)
{
Depth++;
NSIndex = 0;
writer.WriteStartElement (prefix, localName, ns);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册