[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/System.Xml XmlTextReader.cs,1.22,1.23
From: |
adam ballai <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/System.Xml XmlTextReader.cs,1.22,1.23 XmlTextWriter.cs,1.12,1.13 |
Date: |
Wed, 15 Jan 2003 15:30:02 -0500 |
Update of /cvsroot/dotgnu-pnet/pnetlib/System.Xml
In directory subversions:/tmp/cvs-serv7199/System.Xml
Modified Files:
XmlTextReader.cs XmlTextWriter.cs
Log Message:
Index: XmlTextReader.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Xml/XmlTextReader.cs,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -r1.22 -r1.23
*** XmlTextReader.cs 14 Jan 2003 17:32:12 -0000 1.22
--- XmlTextReader.cs 15 Jan 2003 20:30:00 -0000 1.23
***************
*** 54,62 ****
private String namespaceURI;
private String value;
! internal XmlAttribute attr;
private XmlAttributeCollection attributes;
private int attributeIndex;
private int depth;
private bool isEmpty;
internal bool contextSupport;
internal StringBuilder builder;
--- 54,63 ----
private String namespaceURI;
private String value;
! private XmlAttribute attr;
private XmlAttributeCollection attributes;
private int attributeIndex;
private int depth;
private bool isEmpty;
+ internal bool readAttribute;
internal bool contextSupport;
internal StringBuilder builder;
***************
*** 95,99 ****
namespaceURI = String.Empty;
value = String.Empty;
! attr = null;
attributes = new XmlAttributeCollection(attr);
attributeIndex = -1;
--- 96,100 ----
namespaceURI = String.Empty;
value = String.Empty;
! attr = new
XmlAttributeToken(nameTable,null,null);
attributes = new XmlAttributeCollection(attr);
attributeIndex = -1;
***************
*** 102,105 ****
--- 103,107 ----
contextSupport = false;
name = String.Empty;
+ readAttribute = false;
}
public XmlTextReader(Stream input)
***************
*** 461,465 ****
namespaceURI = String.Empty;
value = String.Empty;
! attributes = null;
attributeIndex = -1;
isEmpty = false;
--- 463,468 ----
namespaceURI = String.Empty;
value = String.Empty;
! attr = new
XmlAttributeToken(nameTable,null,null);
! attributes = new XmlAttributeCollection(attr);
attributeIndex = -1;
isEmpty = false;
***************
*** 492,496 ****
{
builder.Append((char)ch);
- linePosition++;
if((char)ch == '/')
{
--- 495,498 ----
***************
*** 499,502 ****
--- 501,505 ----
nodeType =
XmlNodeType.EndElement;
isEmpty = true;
+ readAttribute = false;
return builder.ToString(0,
builder.Length -1);
}
***************
*** 504,513 ****
{
nodeType = XmlNodeType.Element;
return builder.ToString(0,
builder.Length -1);
}
! else if(Char.IsWhiteSpace((char)ch))
{
! nodeType = XmlNodeType.Element;
! return builder.ToString(0,
builder.Length -1);
}
--- 507,539 ----
{
nodeType = XmlNodeType.Element;
+ readAttribute = false;
return builder.ToString(0,
builder.Length -1);
}
! else if (Char.IsWhiteSpace((char)ch))
{
! SkipWhite();
! // more error checking
! if((char)ch != '>' && (char)ch
!= '/')
! {
! nodeType =
XmlNodeType.Element;
! readAttribute = true;
!
! return
builder.ToString(0, builder.Length -1);
! }
! else if((char)ch == '>')
! {
! nodeType =
XmlNodeType.Element;
! readAttribute = false;
! return
builder.ToString(0, builder.Length -1);
! }
! else if((char)ch == '/')
! {
! SkipWhite();
! Expect('>');
! nodeType =
XmlNodeType.EndElement;
! isEmpty = true;
! readAttribute = false;
! return
builder.ToString(0, builder.Length -1);
! }
}
***************
*** 828,834 ****
case '=':
ClearNodeInfo();
! name = builder.ToString();
! SetName(name);
nodeType =
XmlNodeType.Attribute;
attributeIndex++;
// reset buffer
--- 854,861 ----
case '=':
ClearNodeInfo();
! //name = builder.ToString();
! //SetName(name);
nodeType =
XmlNodeType.Attribute;
+ attr = new
XmlAttributeToken(nameTable,builder.ToString(),null);
attributeIndex++;
// reset buffer
***************
*** 837,844 ****
case '\'':
case '"':
-
// get quote
quoteChar = (char)ch;
-
if(nodeType !=
XmlNodeType.Attribute)
{
--- 864,869 ----
***************
*** 851,855 ****
if((char)ch ==
QuoteChar)
{
! value =
builder.ToString();
nodeType =
XmlNodeType.Text;
--- 876,881 ----
if((char)ch ==
QuoteChar)
{
! attr.Value =
builder.ToString();
!
attributes.Append(attr);
nodeType =
XmlNodeType.Text;
***************
*** 862,865 ****
--- 888,892 ----
if((char)ch ==
'/')
{
+
readAttribute = false;
Expect('>');
break;
***************
*** 867,870 ****
--- 894,898 ----
else if
((char)ch == '>')
{
+
readAttribute = false;
break;
}
***************
*** 913,917 ****
! // Read the next node in the input stream.
public override bool Read()
{
--- 941,945 ----
! // Read the next node in the input stream. -- This should mimic mono's
interpretation of Read()
public override bool Read()
{
***************
*** 933,938 ****
}
! // Skip white space in the input stream. TODO:
collect
! // up significant white space.
SkipWhite();
--- 961,1041 ----
}
! // Skip white space in the input stream.
! SkipWhite();
!
! ch = ReadChar();
!
! if(ch == -1)
! {
! // We've reached the end of the stream.
Throw
! // an error if we haven't closed all
elements.
! if(linePosition > 1)
! {
! --linePosition;
! }
! readState = ReadState.EndOfFile;
! ClearNodeInfo();
! return false;
! }
!
! readState = ReadState.Interactive;
! // Determine what to do based on the next
character.
!
!
!
! switch (nodeType)
! {
! case XmlNodeType.Attribute:
! // Set structFlag to true so
quoteChar will
! // know it is the first quote
! AnalyzeChar(ch,true);
! return true;
! default:
! // Handling, set flag to true
if first char is <
! if ((char)ch == '<')
! {
! AnalyzeChar(ch, true);
! while(readAttribute ==
true)
! {
! ch = ReadChar();
! AnalyzeChar(ch,
false);
! }
! }
! else
! {
! AnalyzeChar(ch, false);
! while(readAttribute ==
true)
! {
! ch = ReadChar();
! AnalyzeChar(ch,
false);
! }
! }
! return true;
! }
! return false;
!
! }
!
! // Reads A Document Object Node at a time.
! internal bool ReadNode()
! {
! int ch;
! builder = new StringBuilder();
!
! // Validate the current state of the stream.
! if(readState == ReadState.EndOfFile)
! {
! return false;
! }
! else if(reader == null)
! {
! throw new
XmlException(S._("Xml_ReaderClosed"));
! }
! else if(readState == ReadState.Error)
! {
! throw new
XmlException(S._("Xml_ReaderError"));
! }
!
! // Skip white space in the input stream.
SkipWhite();
***************
*** 1615,1618 ****
--- 1718,1790 ----
}
}
+
+
+ // 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
Index: XmlTextWriter.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Xml/XmlTextWriter.cs,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** XmlTextWriter.cs 13 Jan 2003 14:17:28 -0000 1.12
--- XmlTextWriter.cs 15 Jan 2003 20:30:00 -0000 1.13
***************
*** 976,981 ****
else
{
! char[] buffer = data.ToCharArray();
! WriteChars(buffer, 0 , buffer.Length);
}
}
--- 976,980 ----
else
{
! writer.Write(data);
}
}
***************
*** 1006,1010 ****
else
{
! WriteChars(buffer, index, count);
}
}
--- 1005,1009 ----
else
{
! writer.Write(buffer, index, count);
}
}
***************
*** 1578,1582 ****
// Quote the string and output it.
! WriteQuotedString(text);
}
--- 1577,1581 ----
// Quote the string and output it.
! WriteChars(text.ToCharArray(), 0, text.Length);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/System.Xml XmlTextReader.cs,1.22,1.23 XmlTextWriter.cs,1.12,1.13,
adam ballai <address@hidden> <=