diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2004-04-05 13:32:48 +0400 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2004-04-05 13:32:48 +0400 |
commit | b123e6f7c5e8adf6f31cabeb11a2ccf372f19798 (patch) | |
tree | d4d55ba3d5b447abff702da64262d8b00e3a2c15 /mcs | |
parent | f9602f964e85cb13e1af01accb8121e0e89a9e70 (diff) |
2004-04-05 Atsushi Enomoto <atsushi@ximian.com>
* DTDObjectModel.cs : (DTDAttributeDefinition) create ArrayList
only when they are required.
* DTDReader.cs,
XmlParserInput.cs : raw tag string now don't have to be kept, while
it cost so much. Removed unused code. 20% to 30% memory got saved.
* XmlNotation.cs : removed unused code.
* XmlTextReader.cs : Removed unused code. ReadString() now uses
XmlReader's internal method. Fixed BaseURI to be conformant with
W3C XML InfoSet and (subsequently) xml:base specification (i.e.
reflect xml:base attribute correctly).
svn path=/trunk/mcs/; revision=25026
Diffstat (limited to 'mcs')
-rw-r--r-- | mcs/class/System.XML/System.Xml/ChangeLog | 13 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml/DTDObjectModel.cs | 16 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml/DTDReader.cs | 82 | ||||
-rwxr-xr-x | mcs/class/System.XML/System.Xml/XmlNotation.cs | 8 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml/XmlParserInput.cs | 16 | ||||
-rw-r--r-- | mcs/class/System.XML/System.Xml/XmlTextReader.cs | 103 |
6 files changed, 39 insertions, 199 deletions
diff --git a/mcs/class/System.XML/System.Xml/ChangeLog b/mcs/class/System.XML/System.Xml/ChangeLog index 4b52775d53e..aaa4f07b8c5 100644 --- a/mcs/class/System.XML/System.Xml/ChangeLog +++ b/mcs/class/System.XML/System.Xml/ChangeLog @@ -1,5 +1,18 @@ 2004-04-05 Atsushi Enomoto <atsushi@ximian.com> + * DTDObjectModel.cs : (DTDAttributeDefinition) create ArrayList + only when they are required. + * DTDReader.cs, + XmlParserInput.cs : raw tag string now don't have to be kept, while + it cost so much. Removed unused code. 20% to 30% memory got saved. + * XmlNotation.cs : removed unused code. + * XmlTextReader.cs : Removed unused code. ReadString() now uses + XmlReader's internal method. Fixed BaseURI to be conformant with + W3C XML InfoSet and (subsequently) xml:base specification (i.e. + reflect xml:base attribute correctly). + +2004-04-05 Atsushi Enomoto <atsushi@ximian.com> + * XmlAttribute.cs : get_Value should return all children's value. * XmlCharacterData.cs : DOM's substring does not raise an error when startIndex + count exceeds the length of Data. diff --git a/mcs/class/System.XML/System.Xml/DTDObjectModel.cs b/mcs/class/System.XML/System.Xml/DTDObjectModel.cs index 7ccf3239600..38ee35656d6 100644 --- a/mcs/class/System.XML/System.Xml/DTDObjectModel.cs +++ b/mcs/class/System.XML/System.Xml/DTDObjectModel.cs @@ -563,9 +563,9 @@ namespace Mono.Xml { string name; XmlSchemaDatatype datatype; - ArrayList enumeratedLiterals = new ArrayList (); + ArrayList enumeratedLiterals; string unresolvedDefault; - ArrayList enumeratedNotations = new ArrayList (); + ArrayList enumeratedNotations; DTDAttributeOccurenceType occurenceType = DTDAttributeOccurenceType.None; string resolvedDefaultValue; string resolvedNormalizedDefaultValue; @@ -595,11 +595,19 @@ namespace Mono.Xml // Then I decided to use string ArrayList for enumerated values, // and unresolved string value for DefaultValue. public ArrayList EnumeratedAttributeDeclaration { - get { return this.enumeratedLiterals; } + get { + if (enumeratedLiterals == null) + enumeratedLiterals = new ArrayList (); + return this.enumeratedLiterals; + } } public ArrayList EnumeratedNotations { - get { return this.enumeratedNotations; } + get { + if (enumeratedNotations == null) + enumeratedNotations = new ArrayList (); + return this.enumeratedNotations; + } } public string DefaultValue { diff --git a/mcs/class/System.XML/System.Xml/DTDReader.cs b/mcs/class/System.XML/System.Xml/DTDReader.cs index 08e59bc3b29..4063237c20d 100644 --- a/mcs/class/System.XML/System.Xml/DTDReader.cs +++ b/mcs/class/System.XML/System.Xml/DTDReader.cs @@ -10,6 +10,9 @@ // When a parameter entity contains cp section, it should be closed // within that declaration. // +// Resolution to external entities from different BaseURI fails (it is +// the same as MS.NET 1.1, but should be fixed in the future). +// using System; using System.Collections; @@ -78,13 +81,6 @@ namespace System.Xml set { normalization = value; } } - // A buffer for ReadContent for ReadOuterXml -// private StringBuilder CurrentTag { -// get { -// return currentInput.CurrentMarkup; -// } -// } - public int LineNumber { get { return currentInput.LineNumber; } } @@ -779,7 +775,6 @@ namespace System.Xml return; // do nothing } currentInput.InsertParameterEntityBuffer (" " + peDecl.ReplacementText + " "); - } // The reader is positioned on the head of the name. @@ -1312,63 +1307,6 @@ namespace System.Xml return skipped; } - /* - private string Dereference (string unresolved, bool expandPredefined) - { - StringBuilder resolved = new StringBuilder(); - int pos = 0; - int next = unresolved.IndexOf ('&'); - if(next < 0) - return unresolved; - - while (next >= 0) { - if(pos < next) - resolved.Append (unresolved.Substring (pos, next - pos));// - 1); - int endPos = unresolved.IndexOf (';', next+1); - if (endPos < 0) - throw new XmlException (this as IXmlLineInfo, "Could not resolve entity reference since it did not end with character ';'."); - string entityName = - unresolved.Substring (next + 1, endPos - next - 1); - if(entityName [0] == '#') { - try { - int c; - // character entity - if(entityName [1] == 'x') { - // hexadecimal - c = int.Parse (entityName.Substring (2), - System.Globalization.NumberStyles.HexNumber); - } else { - // decimal - c = int.Parse (entityName.Substring (1)); - } - if (c < Char.MaxValue) - resolved.Append ((char) c); - else - resolved.Append (ExpandSurrogateChar (c)); - } catch (FormatException) { - throw new XmlException (this as IXmlLineInfo, "Invalid character entity reference was found."); - } - } else { - int predefined = XmlChar.GetPredefinedEntity (entityName); - if (expandPredefined && predefined >= 0) - resolved.Append (predefined); - else - // With respect to "Value", MS document is helpless - // and the implemention returns inconsistent value - // (e.g. XML: "&ent; &ent;" ---> Value: "&ent; &ent;".) - resolved.Append ("&" + entityName + ";"); - } - pos = endPos + 1; - if(pos > unresolved.Length) - break; - next = unresolved.IndexOf('&', pos); - } - resolved.Append (unresolved.Substring(pos)); - - return resolved.ToString(); - } - */ - private int PeekChar () { return currentInput.PeekChar (); @@ -1435,8 +1373,6 @@ namespace System.Xml throw new XmlException (this as IXmlLineInfo, "Invalid processing instruction name was found."); -// ClearValueBuffer (); - while (PeekChar () != -1) { int ch = ReadChar (); @@ -1444,19 +1380,7 @@ namespace System.Xml ReadChar (); break; } - -// AppendValueChar ((char)ch); } - - /* - SetProperties ( - XmlNodeType.ProcessingInstruction, // nodeType - target, // name - false, // isEmptyElement - true, // clearAttributes - valueBuffer // value - ); - */ } // The reader is positioned after "<?xml " diff --git a/mcs/class/System.XML/System.Xml/XmlNotation.cs b/mcs/class/System.XML/System.Xml/XmlNotation.cs index 167322529ff..5aee751309b 100755 --- a/mcs/class/System.XML/System.Xml/XmlNotation.cs +++ b/mcs/class/System.XML/System.Xml/XmlNotation.cs @@ -20,7 +20,6 @@ namespace System.Xml string publicId; string systemId; string prefix; - XmlLinkedNode lastChild; #endregion @@ -49,13 +48,6 @@ namespace System.Xml get { return true; } // Notation nodes are always read-only } -/* - internal override XmlLinkedNode LastLinkedChild { - get { return lastChild; } - - set { lastChild = value; } - } -*/ public override string LocalName { get { return localName; } } diff --git a/mcs/class/System.XML/System.Xml/XmlParserInput.cs b/mcs/class/System.XML/System.Xml/XmlParserInput.cs index cd95fc0bd30..3e45bad3bf2 100644 --- a/mcs/class/System.XML/System.Xml/XmlParserInput.cs +++ b/mcs/class/System.XML/System.Xml/XmlParserInput.cs @@ -77,9 +77,6 @@ namespace Mono.Xml.Native if (peStored)
return peBuffer [0];
-// if (can_seek)
-// return reader.Peek ();
-
if (has_peek)
return peek_char;
@@ -88,8 +85,6 @@ namespace Mono.Xml.Native int i = reader.Read (); if (i >= 0xDC00 && i <= 0xDFFF) peek_char += i; -// else -// peek_char = -1; } has_peek = true;
return peek_char;
@@ -116,8 +111,6 @@ namespace Mono.Xml.Native int i = reader.Read (); if (i > 0xDC00 && i <= 0xDFFF) ch += i; -// else -// ch = -1; } }
@@ -127,9 +120,9 @@ namespace Mono.Xml.Native } else {
column++;
}
- currentMarkup.Append ((char) ch);
return ch;
}
+ #endregion
#region Public Properties
@@ -137,10 +130,6 @@ namespace Mono.Xml.Native get { return baseURI; }
}
- public StringBuilder CurrentMarkup {
- get { return this.currentMarkup; }
- }
-
public bool HasPEBuffer {
get {
if (!peStored)
@@ -151,7 +140,7 @@ namespace Mono.Xml.Native return true;
}
}
-
+
public int LineNumber {
get { return line; }
}
@@ -174,7 +163,6 @@ namespace Mono.Xml.Native int peek_char;
int line;
int column;
- StringBuilder currentMarkup = new StringBuilder ();
StringBuilder peBuffer = new StringBuilder ();
string baseURI;
bool peStored = false;
diff --git a/mcs/class/System.XML/System.Xml/XmlTextReader.cs b/mcs/class/System.XML/System.Xml/XmlTextReader.cs index ebb2b09fc8a..6f0ee272e26 100644 --- a/mcs/class/System.XML/System.Xml/XmlTextReader.cs +++ b/mcs/class/System.XML/System.Xml/XmlTextReader.cs @@ -11,8 +11,7 @@ // FIXME: // -// Some thought needs to be given to performance. There's too many -// strings being allocated. +// Some thought needs to be given to performance. // // If current node is on an Attribute, Prefix might be null, and // in several fields which uses XmlReader, it should be considered. @@ -20,7 +19,6 @@ using System; using System.Collections; -using System.Collections.Specialized; using System.IO; using System.Security.Policy; using System.Text; @@ -627,7 +625,6 @@ namespace System.Xml } #if NET_1_0 -#if true public override string ReadInnerXml () { return ReadInnerXmlInternal (); @@ -637,82 +634,12 @@ namespace System.Xml { return ReadOuterXmlInternal (); } -#else - StringBuilder innerXmlBuilder; - public override string ReadInnerXml () - { - if (readState != ReadState.Interactive) - return String.Empty; - - switch (NodeType) { - case XmlNodeType.Attribute: - return Value; - case XmlNodeType.Element: - if (IsEmptyElement) - return String.Empty; - - int startDepth = depth; - - if (innerXmlBuilder == null) - innerXmlBuilder = new StringBuilder (); - innerXmlBuilder.Length = 0; - bool loop = true; - do { - Read (); - if (NodeType ==XmlNodeType.None) - throw new XmlException ("unexpected end of xml."); - else if (NodeType == XmlNodeType.EndElement && depth == startDepth) { - loop = false; - Read (); - } - else - innerXmlBuilder.Append (CreateCurrentTagString ()); - } while (loop); - string xml = innerXmlBuilder.ToString (); - innerXmlBuilder.Length = 0; - return xml; - case XmlNodeType.None: - // MS document is incorrect. Seems not to progress. - return String.Empty; - default: - Read (); - return String.Empty; - } - } - - public override string ReadOuterXml () - { - if (readState != ReadState.Interactive) - return String.Empty; - - switch (NodeType) { - case XmlNodeType.Attribute: - // strictly incompatible with MS... (it holds spaces attribute between name, value and "=" char (very trivial). - return String.Format ("{0}={1}{2}{1}", Name, QuoteChar, ReadInnerXml ()); - case XmlNodeType.Element: - bool isEmpty = IsEmptyElement; - string startTag = CreateCurrentTagString (); - string name = Name; - - if (NodeType == XmlNodeType.Element && !isEmpty) - return String.Format ("{0}{1}</{2}>", startTag, ReadInnerXml (), name); - else - return CreateCurrentTagString (); - case XmlNodeType.None: - // MS document is incorrect. Seems not to progress. - return String.Empty; - default: - Read (); - return String.Empty; - } - } -#endif -#endif public override string ReadString () { return ReadStringInternal (); } +#endif public void ResetState () { @@ -1166,7 +1093,6 @@ namespace System.Xml private int PeekChar () { -#if true if (peekCharsLength == peekCharsIndex) { if (!ReadTextReader ()) return -1; @@ -1174,21 +1100,6 @@ namespace System.Xml } else return peekChars [peekCharsIndex]; -#else - if (hasPeekChars) - return peekChars [peekCharsIndex]; - - if (has_peek) - return peek_char; - peek_char = reader.Read (); - if (peek_char >= 0xD800 && peek_char <= 0xDBFF) { - int i = reader.Read (); - if (i >= 0xDC00 && i <= 0xDFFF) - peek_char += i; - } - has_peek = true; - return peek_char; -#endif } private int ReadChar () @@ -1369,8 +1280,12 @@ namespace System.Xml "Attribute name and qualified name must be identical."); string baseUri = GetAttribute ("xml:base"); - if (baseUri != null) - parserContext.BaseURI = baseUri; + if (baseUri != null) { + if (this.resolver != null) + parserContext.BaseURI = resolver.ResolveUri (new Uri (BaseURI), baseUri).ToString (); + else + parserContext.BaseURI = baseUri; + } string xmlLang = GetAttribute ("xml:lang"); if (xmlLang != null) parserContext.XmlLang = xmlLang; @@ -1395,7 +1310,6 @@ namespace System.Xml } Expect ('>'); - SetProperties ( XmlNodeType.Element, // nodeType name, // name @@ -1768,6 +1682,7 @@ namespace System.Xml currentAttributeValueToken.Clear (); } + // FIXME: normalize here private void ReadAttributeValueTokens (int dummyQuoteChar) { int quoteChar = (dummyQuoteChar < 0) ? ReadChar () : dummyQuoteChar; |