--- /opt/cvs/dotgnu/pnetlib/System.Xml/XmlTextReader.cs Sun Jan 12 16:40:08 2003 +++ System.Xml/XmlTextReader.cs Mon Jan 13 00:36:01 2003 @@ -53,7 +53,7 @@ private String localName; private String namespaceURI; private String value; - internal XmlAttribute attr; + private XmlAttribute attr; private XmlAttributeCollection attributes; private int attributeIndex; private int depth; @@ -94,7 +94,7 @@ localName = String.Empty; namespaceURI = String.Empty; value = String.Empty; - attr = null; + attr = new XmlAttributeToken(nameTable,null,null); attributes = new XmlAttributeCollection(attr); attributeIndex = -1; depth = 1; @@ -460,7 +460,8 @@ localName = String.Empty; namespaceURI = String.Empty; value = String.Empty; - attributes = null; + attr = new XmlAttributeToken(nameTable,null,null); + attributes = new XmlAttributeCollection(attr); attributeIndex = -1; isEmpty = false; } @@ -737,6 +738,7 @@ name = builder.ToString(); SetName(name); nodeType = XmlNodeType.Attribute; + attr=new XmlAttributeToken(nameTable,name,null); attributeIndex++; // reset buffer builder = new StringBuilder(); @@ -753,6 +755,8 @@ if((char)ch == '"') { value = builder.ToString(); + attr.Value=value; + attributes.Append(attr); nodeType = XmlNodeType.Text; // go to next char @@ -1501,6 +1505,70 @@ } } + // Note: this is a hack to implement XmlTextReader without + // building an XmlDocument along with it. + // Do *not* use this elsewhere as a substitute for XmlAttribute + // Also, the use is restricted to a minimum here as well + internal class XmlAttributeToken : XmlAttribute + { + private String value=null; + public XmlAttributeToken(XmlNameTable nt,String name,String ns): + base(null,GetNameInfo(nt,name,null,null)) + { + } + private static NameCache.NameInfo GetNameInfo(XmlNameTable nt, + String localName, + String prefix, + String ns) + { + String name; + if(localName == null) + { + localName = String.Empty; + } + else + { + localName = nt.Add(localName); + } + if(prefix == null) + { + prefix = String.Empty; + } + else + { + prefix = nt.Add(prefix); + } + if(ns == null) + { + prefix = String.Empty; + } + else + { + ns=nt.Add(ns); + } + if(prefix.Length > 0) + { + name = nt.Add(prefix + ":" + localName); + } + else + { + name = localName; + } + return new + NameCache.NameInfo(localName, prefix, name, ns, null); + } + public override String Value + { + get + { + return this.value; + } + set + { + this.value=value; + } + } + } }; // class XmlTextReader }; // namespace System.Xml