diff options
Diffstat (limited to 'mcs/class/System.XML')
17 files changed, 199 insertions, 61 deletions
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog b/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog index ece4b875d31..bb78351e9de 100644 --- a/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog +++ b/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog @@ -1,3 +1,12 @@ +2004-10-04 Atsushi Enomoto <atsushi@ximian.com> + + * HtmlEmitter.cs : TH tag is not regarded as HTML tag. + This fixes bug #67390. + +Thu Sep 9 07:09:11 PDT 2004 Paolo Molaro <lupus@ximian.com> + + * ScriptCompilerInfo.cs: avoid using a .cctor and fix precomp. + 2004-06-18 Atsushi Enomoto <atsushi@ximian.com> * Debug.cs, HtmlEmitter.cs, MSXslScriptManager.cs, diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/HtmlEmitter.cs b/mcs/class/System.XML/Mono.Xml.Xsl/HtmlEmitter.cs index 39839561219..ad5872c3c9a 100644 --- a/mcs/class/System.XML/Mono.Xml.Xsl/HtmlEmitter.cs +++ b/mcs/class/System.XML/Mono.Xml.Xsl/HtmlEmitter.cs @@ -226,9 +226,8 @@ namespace Mono.Xml.Xsl case "SMALL": case "SPAN": case "STRIKE": case "STRONG": case "STYLE": case "SUB": case "SUP": case "TABLE": case "TBODY": case "TD": case "TEXTAREA": - case "TFOOT": case "THEAD": case "TITLE": case "TR": case "TT": - case "U": case "UL": - case "VAR": + case "TFOOT": case "TH": case "THEAD": case "TITLE": + case "TR": case "TT": case "U": case "UL": case "VAR": return true; } return false; diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/ScriptCompilerInfo.cs b/mcs/class/System.XML/Mono.Xml.Xsl/ScriptCompilerInfo.cs index 0a5d72ed4cb..87438fa2bb0 100755 --- a/mcs/class/System.XML/Mono.Xml.Xsl/ScriptCompilerInfo.cs +++ b/mcs/class/System.XML/Mono.Xml.Xsl/ScriptCompilerInfo.cs @@ -216,12 +216,6 @@ end namespace { static Type providerType; - static JScriptCompilerInfo () - { - Assembly jsasm = Assembly.LoadWithPartialName ("Microsoft.JScript", null); - providerType = jsasm.GetType ("Microsoft.JScript.JScriptCodeProvider"); - } - public JScriptCompilerInfo () { this.CompilerCommand = "mjs"; @@ -231,9 +225,17 @@ end namespace this.DefaultCompilerOptions = "/t:library /r:Microsoft.VisualBasic.dll"; } - public override CodeDomProvider CodeDomProvider {
- get { return (CodeDomProvider) Activator.CreateInstance (providerType); }
- }
+ public override CodeDomProvider CodeDomProvider { + get { + // no need for locking + if (providerType == null) { + Assembly jsasm = Assembly.LoadWithPartialName ("Microsoft.JScript", null); + if (jsasm != null) + providerType = jsasm.GetType ("Microsoft.JScript.JScriptCodeProvider"); + } + return (CodeDomProvider) Activator.CreateInstance (providerType); + } + } public override string Extension { get { return ".js"; } diff --git a/mcs/class/System.XML/System.Xml.Schema/BuiltInDatatype.cs b/mcs/class/System.XML/System.Xml.Schema/BuiltInDatatype.cs index 8402f2d8004..4587f204179 100644 --- a/mcs/class/System.XML/System.Xml.Schema/BuiltInDatatype.cs +++ b/mcs/class/System.XML/System.Xml.Schema/BuiltInDatatype.cs @@ -1370,15 +1370,61 @@ namespace Mono.Xml.Schema public override object ParseValue (string s,
XmlNameTable nameTable, XmlNamespaceManager nsmgr)
{
- return ParseValueType (s, nameTable, nsmgr);
+ return new XmlSchemaUri (Normalize (s));
}
internal override ValueType ParseValueType (string s, XmlNameTable nameTable, XmlNamespaceManager nsmgr)
{
- return new UriValueType (Normalize (s));
+ return new UriValueType ((XmlSchemaUri) ParseValue (s, nameTable, nsmgr));
}
}
-
+
+ internal class XmlSchemaUri : Uri
+ {
+ public string value;
+
+ // LAMESPEC: In this way, some strings that contain ':' might
+ // result in exception (MS.NET looks implemented as such).
+ public XmlSchemaUri (string src)
+ : this (src, src.IndexOf (':') > 0)
+ {
+ }
+
+ private XmlSchemaUri (string src, bool formal)
+ : base (formal ? src : "anyuri:" + src, !formal)
+ {
+ value = src;
+ }
+
+ public static bool operator == (XmlSchemaUri v1, XmlSchemaUri v2)
+ {
+ return v1.value == v2.value;
+ }
+
+ public static bool operator != (XmlSchemaUri v1, XmlSchemaUri v2)
+ {
+ return v1.value != v2.value;
+ }
+
+ public override bool Equals (object obj)
+ {
+ if (obj is XmlSchemaUri)
+ return (XmlSchemaUri) obj == this;
+ else
+ return false;
+ }
+
+ public override int GetHashCode ()
+ {
+ return value.GetHashCode ();
+ }
+
+ public override string ToString ()
+ {
+ return value;
+ }
+ }
+
// xs:duration
internal class XsdDuration : XsdAnySimpleType
{
diff --git a/mcs/class/System.XML/System.Xml.Schema/ChangeLog b/mcs/class/System.XML/System.Xml.Schema/ChangeLog index 14dd692e892..e3dc9a5679f 100755 --- a/mcs/class/System.XML/System.Xml.Schema/ChangeLog +++ b/mcs/class/System.XML/System.Xml.Schema/ChangeLog @@ -1,3 +1,14 @@ +2004-09-16 Atsushi Enomoto <atsushi@ximian.com> + + * BuiltInDatatype.cs, SchemaDataValueType.cs : + ParseValue() for xs:AnyURI should return System.Uri. MS.NET returns + XmlSchemaUri, but it is derived from System.Uri, while ours was not. + +2004-09-03 Atsushi Enomoto <atsushi@ximian.com> + + * XmlSchema.cs : When schema inclusion results in a recursion, just + skip recursed schema. + 2004-06-18 Atsushi Enomoto <atsushi@ximian.com> * CustomSerializer.cs, XmlSchemaException.cs, diff --git a/mcs/class/System.XML/System.Xml.Schema/SchemaDataValueType.cs b/mcs/class/System.XML/System.Xml.Schema/SchemaDataValueType.cs index c2b9305fcad..ff4031f2806 100755 --- a/mcs/class/System.XML/System.Xml.Schema/SchemaDataValueType.cs +++ b/mcs/class/System.XML/System.Xml.Schema/SchemaDataValueType.cs @@ -19,6 +19,8 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using Mono.Xml.Schema;
+
namespace System.Xml.Schema
{
internal struct QNameValueType
@@ -97,14 +99,14 @@ namespace System.Xml.Schema internal struct UriValueType
{
- string value;
+ XmlSchemaUri value;
- public UriValueType (string value)
+ public UriValueType (XmlSchemaUri value)
{
this.value = value;
}
- public string Value {
+ public XmlSchemaUri Value {
get { return value; }
}
@@ -133,7 +135,7 @@ namespace System.Xml.Schema public override string ToString ()
{
- return value;
+ return value.ToString ();
}
}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs index 59e28520089..6e37d9f3be6 100755 --- a/mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs +++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs @@ -369,7 +369,10 @@ namespace System.Xml.Schema if (resolver != null) {
url = GetResolvedUri (resolver, ext.SchemaLocation);
if (schemaLocationStack.Contains (url)) {
- error(handler, "Nested inclusion was found: " + url);
+ // Just skip nested inclusion.
+ // The spec is "carefully written"
+ // not to handle it as an error.
+ // error (handler, "Nested inclusion was found: " + url);
// must skip this inclusion
continue;
}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/ChangeLog b/mcs/class/System.XML/System.Xml.Serialization/ChangeLog index e542d6a843d..0586af82013 100755 --- a/mcs/class/System.XML/System.Xml.Serialization/ChangeLog +++ b/mcs/class/System.XML/System.Xml.Serialization/ChangeLog @@ -1,3 +1,13 @@ +2004-09-28 Lluis Sanchez Gual <lluis@novell.com> + + * CodeIdentifier.cs: MakeValid now returns "Item" for an empty string. + This fixes bug #66877. + +2004-09-03 Lluis Sanchez Gual <lluis@novell.com> + + * XmlSerializer.cs: When the XmlReader is created by XmlSerializer, use + Normalization==true by default. + 2004-07-15 Lluis Sanchez Gual <lluis@novell.com> * TypeTranslator.cs, XmlCustomFormatter.cs: Added support for base64. This diff --git a/mcs/class/System.XML/System.Xml.Serialization/CodeIdentifier.cs b/mcs/class/System.XML/System.Xml.Serialization/CodeIdentifier.cs index 93d78b2f69f..54c0b6bee87 100644 --- a/mcs/class/System.XML/System.Xml.Serialization/CodeIdentifier.cs +++ b/mcs/class/System.XML/System.Xml.Serialization/CodeIdentifier.cs @@ -55,7 +55,7 @@ namespace System.Xml.Serialization { if (identifier == null) throw new NullReferenceException (); if (identifier.Length == 0) - return identifier; + return "Item"; string output = ""; diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs index d5efa65c1d3..aa57189fb34 100644 --- a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs +++ b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs @@ -251,12 +251,14 @@ namespace System.Xml.Serialization public object Deserialize (Stream stream) { XmlTextReader xmlReader = new XmlTextReader(stream); + xmlReader.Normalization = true; return Deserialize(xmlReader); } public object Deserialize (TextReader textReader) { XmlTextReader xmlReader = new XmlTextReader(textReader); + xmlReader.Normalization = true; return Deserialize(xmlReader); } diff --git a/mcs/class/System.XML/System.Xml/ChangeLog b/mcs/class/System.XML/System.Xml/ChangeLog index d0f99f7305e..6da24f7f434 100644 --- a/mcs/class/System.XML/System.Xml/ChangeLog +++ b/mcs/class/System.XML/System.Xml/ChangeLog @@ -1,3 +1,41 @@ +2004-09-06 Atsushi Enomoto <atsushi@ximian.com> + + * XmlWriter.cs : on reader.NodeType is None, WriteNode() still tries + to read more (and might result in an error). + +2004-09-03 Atsushi Enomoto <atsushi@ximian.com> + + * XmlTextReader.cs : When Normalization is true, CRLF and CR should + be converted to single LF. This should fix part of bug #62076. + +2004-08-27 Atsushi Enomoto <atsushi@ximian.com> + + * XmlAttribute.cs : some property getters threw NullReferenceException + when the attribute is not added to an element. + * XmlNode.cs : When a node is not appended to another node, BaseURI + is empty. Bug #64120 is fixed. + +2004-08-26 Atsushi Enomoto <atsushi@ximian.com> + + * XmlTextWriter.cs : In CheckState(), don't create indentation string + at every time. WriteIndent() now handles the indentation without + recomputation. + +2004-08-21 Atsushi Enomoto <atsushi@ximian.com> + + * XmlElement.cs : set_InnerText was removing children incompletely. + This fixes bug #63574. + +2004-08-20 Atsushi Enomoto <atsushi@ximian.com> + + ResetState() now throws InvalidOperationException() as MS.NET does. + +2004-08-20 Atsushi Enomoto <atsushi@ximian.com> + + * XmlTextReader.cs : Fixed EOF not to return true when it is just + closed. Element and EndElement location is now adjusted to be the + same as MS.NET does. This fixes bug #63505 and #63507. + 2004-07-28 Lluis Sanchez Gual <lluis@novell.com> * XmlTextReader.cs: Stop parsing when a null character is found. diff --git a/mcs/class/System.XML/System.Xml/XmlAttribute.cs b/mcs/class/System.XML/System.Xml/XmlAttribute.cs index f5bfcc958a0..d02dee88e5c 100644 --- a/mcs/class/System.XML/System.Xml/XmlAttribute.cs +++ b/mcs/class/System.XML/System.Xml/XmlAttribute.cs @@ -104,9 +104,7 @@ namespace System.Xml #region Properties public override string BaseURI { - get { - return OwnerElement.BaseURI; - } + get { return OwnerElement != null ? OwnerElement.BaseURI : String.Empty; } } public override string InnerText { @@ -175,9 +173,7 @@ namespace System.Xml } public virtual XmlElement OwnerElement { - get { - return ownerElement; - } + get { return ownerElement; } } public override XmlNode ParentNode { @@ -248,11 +244,11 @@ namespace System.Xml } internal override string XmlLang { - get { return OwnerElement.XmlLang; } + get { return OwnerElement != null ? OwnerElement.XmlLang : String.Empty; } } internal override XmlSpace XmlSpace { - get { return OwnerElement.XmlSpace; } + get { return OwnerElement != null ? OwnerElement.XmlSpace : XmlSpace.None; } } #endregion @@ -298,6 +294,9 @@ namespace System.Xml internal DTDAttributeDefinition GetAttributeDefinition () { + if (OwnerElement == null) + return null; + // If it is default, then directly create new attribute. DTDAttListDeclaration attList = OwnerDocument.DocumentType != null ? OwnerDocument.DocumentType.DTD.AttListDecls [OwnerElement.Name] : null; return attList != null ? attList [Name] : null; diff --git a/mcs/class/System.XML/System.Xml/XmlElement.cs b/mcs/class/System.XML/System.Xml/XmlElement.cs index a74d801671c..f506853124d 100644 --- a/mcs/class/System.XML/System.Xml/XmlElement.cs +++ b/mcs/class/System.XML/System.Xml/XmlElement.cs @@ -115,13 +115,11 @@ namespace System.Xml } set { // Why its behavior (of MS FCL) is different from InnerXml...? - if (FirstChild != null && FirstChild.NodeType == XmlNodeType.Text) + if (ChildNodes != null && ChildNodes.Count == 1 && FirstChild.NodeType == XmlNodeType.Text) FirstChild.Value = value; else { - if (FirstChild != null) { - for (int i = 0; i < ChildNodes.Count; i++) - this.RemoveChild (ChildNodes [i]); - } + while (FirstChild != null) + this.RemoveChild (FirstChild); // creates new Text node AppendChild (OwnerDocument.CreateTextNode (value)); } diff --git a/mcs/class/System.XML/System.Xml/XmlNode.cs b/mcs/class/System.XML/System.Xml/XmlNode.cs index 7eaa7285c8e..ef1ec861a31 100644 --- a/mcs/class/System.XML/System.Xml/XmlNode.cs +++ b/mcs/class/System.XML/System.Xml/XmlNode.cs @@ -71,7 +71,7 @@ namespace System.Xml get { // Isn't it conformant to W3C XML Base Recommendation? // As far as I tested, there are not... - return (ParentNode != null) ? ParentNode.BaseURI : OwnerDocument.BaseURI; + return (ParentNode != null) ? ParentNode.BaseURI : String.Empty; } } diff --git a/mcs/class/System.XML/System.Xml/XmlTextReader.cs b/mcs/class/System.XML/System.Xml/XmlTextReader.cs index d37332a0508..221541167bf 100644 --- a/mcs/class/System.XML/System.Xml/XmlTextReader.cs +++ b/mcs/class/System.XML/System.Xml/XmlTextReader.cs @@ -176,14 +176,8 @@ namespace System.Xml } #endif - public override bool EOF - { - get - { - return - readState == ReadState.EndOfFile || - readState == ReadState.Closed; - } + public override bool EOF { + get { return readState == ReadState.EndOfFile; } } #if NET_2_0 @@ -688,7 +682,7 @@ namespace System.Xml public void ResetState () { - Init (); + throw new InvalidOperationException ("Cannot call ResetState when parsing an XML fragment."); } public override void ResolveEntity () @@ -1304,6 +1298,9 @@ namespace System.Xml "Multiple document element was detected."); currentState = XmlNodeType.Element; + currentLinkedNodeLineNumber = line; + currentLinkedNodeLinePosition = column; + parserContext.NamespaceManager.PushScope (); string name = ReadName (); @@ -1406,6 +1403,9 @@ namespace System.Xml throw new XmlException (this as IXmlLineInfo, "End tag cannot appear in this state."); + currentLinkedNodeLineNumber = line; + currentLinkedNodeLinePosition = column; + string name = ReadName (); if (elementNameStackPos == 0) throw new XmlException (this as IXmlLineInfo,"closing element without matching opening element"); @@ -1548,8 +1548,14 @@ namespace System.Xml ch = ReadReference (false); if (returnEntityReference) // Returns -1 if char validation should not be done break; - } - else { + } else if (normalization && ch == '\r') { + ReadChar (); + ch = ReadChar (); + if (ch != '\n') + // append '\n' instead of '\r'. + AppendValueChar ('\n'); + // and in case of "\r\n", discard '\r'. + } else { if (XmlChar.IsInvalid (ch)) throw new XmlException (this, "Not allowed character was found."); ch = ReadChar (); @@ -2142,8 +2148,18 @@ namespace System.Xml skip = true; } } - if (normalization && XmlChar.IsInvalid (ch)) - throw new XmlException (this, "Invalid character was found."); + if (normalization) { + if (ch == '\r') { + ch = PeekChar (); + if (ch != '\n') + // append '\n' instead of '\r'. + AppendValueChar ('\n'); + // otherwise, discard '\r'. + continue; + } + else if (XmlChar.IsInvalid (ch)) + throw new XmlException (this, "Invalid character was found."); + } AppendValueChar (ch); } diff --git a/mcs/class/System.XML/System.Xml/XmlTextWriter.cs b/mcs/class/System.XML/System.Xml/XmlTextWriter.cs index af19e18dc6b..8e10329bf68 100644 --- a/mcs/class/System.XML/System.Xml/XmlTextWriter.cs +++ b/mcs/class/System.XML/System.Xml/XmlTextWriter.cs @@ -277,13 +277,9 @@ openElements [openElementCount - 1]).IndentingOverriden; } if ((documentStarted == true) && (formatting == Formatting.Indented) && (!IndentingOverriden)) { indentFormatting = w.NewLine; - if (indentLevel > 0) { - for (int i = 0; i < indentLevel; i++) - indentFormatting += indentChars; - } } else - indentFormatting = ""; + indentFormatting = null; documentStarted = true; } @@ -341,9 +337,7 @@ openElements [openElementCount - 1]).IndentingOverriden; private void UpdateIndentChars () { - indentChars = ""; - for (int i = 0; i < indentation; i++) - indentChars += indentChar; + indentChars = new string (indentChar, indentation); } public override void WriteBase64 (byte[] buffer, int index, int count) @@ -535,6 +529,15 @@ openElements [openElementCount - 1]).IndentingOverriden; WriteEndElementInternal (false); } + private void WriteIndent () + { + if (indentFormatting == null) + return; + w.Write (w.NewLine); + for (int i = 0; i < indentLevel; i++) + w.Write (indentChars); + } + private void WriteEndElementInternal (bool fullEndElement) { if (openElementCount == 0) @@ -553,7 +556,7 @@ openElements [openElementCount - 1]).IndentingOverriden; if (fullEndElement) { w.Write ('>'); if (!ParentIndentingOverriden) - w.Write (indentFormatting); + WriteIndent (); w.Write ("</"); XmlTextWriterOpenElement el = (XmlTextWriterOpenElement) openElements [openElementCount - 1]; if (el.Prefix != String.Empty) { @@ -568,7 +571,7 @@ openElements [openElementCount - 1]).IndentingOverriden; openElementCount--; openStartElement = false; } else { - w.Write (indentFormatting); + WriteIndent (); w.Write ("</"); XmlTextWriterOpenElement el = (XmlTextWriterOpenElement) openElements [openElementCount - 1]; openElementCount--; @@ -626,7 +629,7 @@ openElements [openElementCount - 1]).IndentingOverriden; CheckState (); CloseStartElement (); - w.Write (indentFormatting); + WriteIndent (); w.Write ("<?"); w.Write (name); w.Write (' '); @@ -834,7 +837,7 @@ openElements [openElementCount - 1]).IndentingOverriden; if (prefix == null) prefix = String.Empty; - w.Write (indentFormatting); + WriteIndent (); w.Write ('<'); if (prefix != String.Empty) { w.Write (prefix); diff --git a/mcs/class/System.XML/System.Xml/XmlWriter.cs b/mcs/class/System.XML/System.Xml/XmlWriter.cs index 4f69abaf378..7e4fb8d6b28 100644 --- a/mcs/class/System.XML/System.Xml/XmlWriter.cs +++ b/mcs/class/System.XML/System.Xml/XmlWriter.cs @@ -273,7 +273,7 @@ namespace System.Xml case XmlNodeType.EndEntity: break; case XmlNodeType.None: - return; // Do nothing, nor reporting errors. + break; // Do nothing, nor reporting errors. default: throw new XmlException ("Unexpected node " + reader.Name + " of type " + reader.NodeType); } |