From 97c08a345189de79332e75268f5ac806caa800f8 Mon Sep 17 00:00:00 2001 From: Atsushi Eno Date: Sun, 15 Jan 2006 03:24:19 +0000 Subject: revert r55476, incorrectly made changes to the tag, not the branch svn path=/tags/mono-1-1-13/mcs/; revision=55590 --- mcs/class/System.XML/ChangeLog | 9 -- mcs/class/System.XML/Mono.Xml.Schema/ChangeLog | 6 -- .../Mono.Xml.Schema/XmlSchemaValidatingReader.cs | 118 ++++++++++++++------- mcs/class/System.XML/System.Xml.Schema/ChangeLog | 15 --- .../System.XML/System.Xml.Schema/XmlAtomicValue.cs | 21 +++- .../System.Xml.Schema/XmlSchemaAttribute.cs | 10 +- .../System.Xml.Schema/XmlSchemaDatatype.cs | 6 +- .../System.Xml.Schema/XmlSchemaElement.cs | 10 +- .../System.XML/System.Xml.Schema/XmlSchemaSet.cs | 1 + .../System.XML/System.Xml.Schema/XmlSchemaType.cs | 1 + .../System.Xml.Schema/XmlSchemaValidator.cs | 21 ++-- mcs/class/System.XML/System.Xml/ChangeLog | 25 ----- mcs/class/System.XML/System.Xml/DTDObjectModel.cs | 2 - .../System.XML/System.Xml/XmlNamespaceManager.cs | 4 +- mcs/class/System.XML/System.Xml/XmlTextWriter.cs | 21 +--- mcs/class/System.XML/System.Xml/XmlWriter.cs | 9 +- mcs/class/System.XML/System.Xml_test.dll.sources | 8 +- .../System.XML/Test/System.Xml.Schema/ChangeLog | 14 --- .../System.Xml.Schema/XmlSchemaDatatypeTests.cs | 84 --------------- .../Test/System.Xml.Schema/XmlSchemaSetTests.cs | 27 +---- .../Test/System.Xml.Schema/XmlSchemaTypeTests.cs | 101 ------------------ mcs/class/System.XML/Test/System.Xml/ChangeLog | 14 --- .../Test/System.Xml/XmlTextWriterTests.cs | 40 ++++--- mcs/class/System.XML/Test/XmlFiles/xsd/ChangeLog | 4 - .../System.XML/Test/XmlFiles/xsd/datatypesTest.xsd | 11 -- 25 files changed, 161 insertions(+), 421 deletions(-) delete mode 100644 mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaTypeTests.cs delete mode 100644 mcs/class/System.XML/Test/XmlFiles/xsd/datatypesTest.xsd diff --git a/mcs/class/System.XML/ChangeLog b/mcs/class/System.XML/ChangeLog index 07e12744f95..3e5e8d19234 100644 --- a/mcs/class/System.XML/ChangeLog +++ b/mcs/class/System.XML/ChangeLog @@ -1,12 +1,3 @@ -2006-01-10 Atsushi Enomoto - - * System.Xml_test.dll.sources : added XmlSchemaTypeTests.cs. - -2006-01-10 Atsushi Enomoto - - * System.Xml_test.dll.sources : XmlSchemaDatatypeTests.cs was missing. - collected sys.xml.schema lines. - 2005-12-28 Gert Driesen * System.Xml_test.dll.sources: Added XmlSchemaExporterTests.cs. diff --git a/mcs/class/System.XML/Mono.Xml.Schema/ChangeLog b/mcs/class/System.XML/Mono.Xml.Schema/ChangeLog index a7074156a40..5bda8228106 100644 --- a/mcs/class/System.XML/Mono.Xml.Schema/ChangeLog +++ b/mcs/class/System.XML/Mono.Xml.Schema/ChangeLog @@ -1,9 +1,3 @@ -2006-01-11 Atsushi Enomoto - - * XmlSchemaValidatingReader.cs : removed unused constructors. - Now it implements IXmlSchemaInfo. Use XmlSchemaType instead of - Object to represent schema types. - 2006-01-06 Atsushi Enomoto * XsdValidatingReader.cs : diff --git a/mcs/class/System.XML/Mono.Xml.Schema/XmlSchemaValidatingReader.cs b/mcs/class/System.XML/Mono.Xml.Schema/XmlSchemaValidatingReader.cs index d887625f9ad..42d2c23cca5 100644 --- a/mcs/class/System.XML/Mono.Xml.Schema/XmlSchemaValidatingReader.cs +++ b/mcs/class/System.XML/Mono.Xml.Schema/XmlSchemaValidatingReader.cs @@ -76,8 +76,7 @@ using ValException = System.Xml.Schema.XmlSchemaValidationException; namespace Mono.Xml.Schema { - internal class XmlSchemaValidatingReader : XmlReader, IXmlLineInfo, - IXmlSchemaInfo + internal class XmlSchemaValidatingReader : XmlReader, IXmlLineInfo { static readonly XsAttr [] emptyAttributeArray = new XsAttr [0]; @@ -92,6 +91,7 @@ namespace Mono.Xml.Schema IXmlLineInfo readerLineInfo; ValidationType validationType; IXmlNamespaceResolver nsResolver; +// IHasXmlSchemaInfo sourceReaderSchemaInfo; int startDepth; StringBuilder tmpBuilder = new StringBuilder (); @@ -100,14 +100,48 @@ namespace Mono.Xml.Schema int currentDefaultAttribute = -1; ArrayList defaultAttributesCache = new ArrayList (); bool defaultAttributeConsumed; - XmlSchemaType currentAttrType; + object currentAttrType; // Extra for XmlSchemaValidtingReader // (not in XsdValidatingReader) XsElement element; // ... xsinfo.Element? + object xsiType; // ... xsinfo.SchemaType? #endregion + public XmlSchemaValidatingReader (XmlReader reader, XmlSchemaSet schemas) + { + nsResolver = reader as IXmlNamespaceResolver; + if (nsResolver == null) + throw new ArgumentException ("Argument XmlReader must implement IXmlNamespaceResolver."); + options = ValidationFlags.ReportValidationWarnings + | ValidationFlags.ProcessSchemaLocation + | ValidationFlags.ProcessInlineSchema; + + this.reader = reader; + if (schemas == null) + schemas = new XmlSchemaSet (); + v = new XmlSchemaValidator ( + reader.NameTable, + schemas, + nsResolver, + options); + + readerLineInfo = reader as IXmlLineInfo; + startDepth = reader.Depth; + getter = delegate () { return Value; }; + xsinfo = new XmlSchemaInfo (); // transition cache + v.LineInfoProvider = this; + v.ValidationEventSender = reader; +#if !NON_MONO + v.XmlResolver = schemas.XmlResolver; +#else + v.XmlResolver = new XmlUrlResolver (); +#endif + v.SourceUri = new Uri (null, reader.BaseURI); // FIXME: it is in fact not in MS.NET. + v.Initialize (); + } + public XmlSchemaValidatingReader (XmlReader reader, XmlReaderSettings settings) { @@ -130,7 +164,6 @@ namespace Mono.Xml.Schema readerLineInfo = reader as IXmlLineInfo; startDepth = reader.Depth; getter = delegate () { return Value; }; - xsinfo = new XmlSchemaInfo (); // transition cache v.LineInfoProvider = this; v.ValidationEventSender = reader; #if !NON_MONO @@ -144,11 +177,48 @@ namespace Mono.Xml.Schema v.Initialize (); } + public XmlSchemaValidatingReader ( + XPathNavigator navigator, + XmlSchemaSet schemas, + ValidationEventHandler handler) + { + this.reader = navigator.ReadSubtree (); + startDepth = reader.Depth; + IXmlSchemaInfo info = navigator.SchemaInfo; + SchemaType schemaType = info != null ? + info.SchemaType : null; + + if (schemas == null && schemaType == null) + throw new ArgumentException ("Neither of XmlSchemaSet is specified, nor XPathNavigator does not provide schema type information on current node."); + + if (schemas == null) + schemas = new XmlSchemaSet (reader.NameTable); + + v = new XmlSchemaValidator ( + navigator.NameTable, + schemas, + navigator, + ValidationFlags.ProcessIdentityConstraints); + + readerLineInfo = navigator as IXmlLineInfo; + getter = delegate () { return Value; }; + v.LineInfoProvider = this; + v.ValidationEventSender = navigator; +#if !NON_MONO + v.XmlResolver = schemas.XmlResolver; +#else + v.XmlResolver = new XmlUrlResolver (); +#endif + v.Initialize (schemaType); + } + public ValidationEventHandler ValidationEventHandler; - public XmlSchemaType ElementSchemaType { + public object ActualType { get { - return element != null ? element.ElementSchemaType : null; + return xsiType != null ? + xsiType : + element != null ? element.ElementType : null; } } @@ -172,24 +242,24 @@ namespace Mono.Xml.Schema get { return readerLineInfo != null ? readerLineInfo.LinePosition : 0; } } - public XmlSchemaType SchemaType { + public object SchemaType { get { if (ReadState != ReadState.Interactive) return null; switch (NodeType) { case XmlNodeType.Element: - if (ElementSchemaType != null) - return ElementSchemaType; + if (ActualType != null) + return ActualType; else return null;//SourceReaderSchemaType; case XmlNodeType.Attribute: if (currentAttrType == null) { - ComplexType ct = ElementSchemaType as ComplexType; + ComplexType ct = ActualType as ComplexType; if (ct != null) { XsAttr attdef = ct.AttributeUses [new XmlQualifiedName (LocalName, NamespaceURI)] as XsAttr; if (attdef != null) - currentAttrType = attdef.AttributeSchemaType; + currentAttrType = attdef.AttributeType; return currentAttrType; } // currentAttrType = SourceReaderSchemaType; @@ -380,7 +450,7 @@ namespace Mono.Xml.Schema } public override IXmlSchemaInfo SchemaInfo { - get { return this; } + get { return xsinfo; } } public override string Value { @@ -785,30 +855,6 @@ namespace Mono.Xml.Schema } #endregion - - #region IXmlSchemaInfo - - public bool IsNil { - get { return xsinfo.IsNil; } - } - - public XmlSchemaSimpleType MemberType { - get { return xsinfo.MemberType; } - } - - public XmlSchemaAttribute SchemaAttribute { - get { return xsinfo.SchemaAttribute; } - } - - public XmlSchemaElement SchemaElement { - get { return xsinfo.SchemaElement; } - } - - public XmlSchemaValidity Validity { - get { return xsinfo.Validity; } - } - - #endregion } } diff --git a/mcs/class/System.XML/System.Xml.Schema/ChangeLog b/mcs/class/System.XML/System.Xml.Schema/ChangeLog index 9a53330afbe..17cefced3de 100644 --- a/mcs/class/System.XML/System.Xml.Schema/ChangeLog +++ b/mcs/class/System.XML/System.Xml.Schema/ChangeLog @@ -1,18 +1,3 @@ -2006-01-11 Atsushi Enomoto - - * XmlSchemaAttribute.cs, XmlSchemaElement.cs : AttributeSchemaType - and ElementSchemaType were not working fine for anySimpleType. - * XmlSchemaValidator.cs : When actual schema type was complex, - schema types was not filled correctly. Modified some extra comments. - * XmlSchemaSet.cs, XmlSchemaType.cs : removed extra MonoTODOs. - -2006-01-10 Atsushi Enomoto - - * XmlAtomicValue.cs : it won't be implemented since there is no way - to test it inside sys.xml. Thus remarked MonoTODO. - * XmlSchemaDatatype.cs : implemented IsDerivedFrom(), which is however - mostly useless. - 2006-01-06 Atsushi Enomoto * XmlSchemaSet.cs : Add() rollbacks IsCompiled to false. diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlAtomicValue.cs b/mcs/class/System.XML/System.Xml.Schema/XmlAtomicValue.cs index a543e74db95..65616cf782f 100644 --- a/mcs/class/System.XML/System.Xml.Schema/XmlAtomicValue.cs +++ b/mcs/class/System.XML/System.Xml.Schema/XmlAtomicValue.cs @@ -36,7 +36,6 @@ using System.Xml.XPath; namespace System.Xml.Schema { - [MonoTODO ("This class is unused and thus won't be finished.")] public sealed class XmlAtomicValue : XPathItem, ICloneable { bool booleanValue; @@ -54,6 +53,7 @@ namespace System.Xml.Schema #region Constructors + [MonoTODO] internal XmlAtomicValue (bool value, XmlSchemaType xmlType) { Init (value, xmlType); @@ -68,6 +68,7 @@ namespace System.Xml.Schema schemaType = xmlType; } + [MonoTODO] internal XmlAtomicValue (DateTime value, XmlSchemaType xmlType) { Init (value, xmlType); @@ -82,6 +83,7 @@ namespace System.Xml.Schema schemaType = xmlType; } + [MonoTODO] internal XmlAtomicValue (decimal value, XmlSchemaType xmlType) { Init (value, xmlType); @@ -96,6 +98,7 @@ namespace System.Xml.Schema schemaType = xmlType; } + [MonoTODO] internal XmlAtomicValue (double value, XmlSchemaType xmlType) { Init (value, xmlType); @@ -110,6 +113,7 @@ namespace System.Xml.Schema schemaType = xmlType; } + [MonoTODO] internal XmlAtomicValue (int value, XmlSchemaType xmlType) { Init (value, xmlType); @@ -124,6 +128,7 @@ namespace System.Xml.Schema schemaType = xmlType; } + [MonoTODO] internal XmlAtomicValue (long value, XmlSchemaType xmlType) { Init (value, xmlType); @@ -138,6 +143,7 @@ namespace System.Xml.Schema schemaType = xmlType; } + [MonoTODO] internal XmlAtomicValue (float value, XmlSchemaType xmlType) { Init (value, xmlType); @@ -152,6 +158,7 @@ namespace System.Xml.Schema schemaType = xmlType; } + [MonoTODO] internal XmlAtomicValue (string value, XmlSchemaType xmlType) { Init (value, xmlType); @@ -168,6 +175,7 @@ namespace System.Xml.Schema schemaType = xmlType; } + [MonoTODO] internal XmlAtomicValue (object value, XmlSchemaType xmlType) { Init (value, xmlType); @@ -273,11 +281,13 @@ namespace System.Xml.Schema return this.Clone (); } + [MonoTODO] public XmlAtomicValue Clone () { return new XmlAtomicValue (this, schemaType); } + [MonoTODO] public override object ValueAs (Type type, IXmlNamespaceResolver nsResolver) { switch (XmlTypeCodeFromRuntimeType (type, false)) { @@ -328,6 +338,7 @@ namespace System.Xml.Schema } } + [MonoTODO] public override object TypedValue { get { switch (ResolvedTypeCode) { @@ -349,6 +360,7 @@ namespace System.Xml.Schema } } + [MonoTODO] // This method works like ValueAsString. public override string Value { get { @@ -413,6 +425,7 @@ namespace System.Xml.Schema } } + [MonoTODO] public override bool ValueAsBoolean { get { switch (xmlTypeCode) { @@ -444,6 +457,7 @@ namespace System.Xml.Schema } } + [MonoTODO] public override DateTime ValueAsDateTime { get { switch (xmlTypeCode) { @@ -464,6 +478,7 @@ namespace System.Xml.Schema } } + [MonoTODO] public override double ValueAsDouble { get { switch (xmlTypeCode) { @@ -494,6 +509,7 @@ namespace System.Xml.Schema } } + [MonoTODO] public override int ValueAsInt { get { switch (xmlTypeCode) { @@ -524,6 +540,7 @@ namespace System.Xml.Schema } } + [MonoTODO] public override long ValueAsLong { get { switch (xmlTypeCode) { @@ -554,10 +571,12 @@ namespace System.Xml.Schema } } + [MonoTODO] public override Type ValueType { get { return schemaType.Datatype.ValueType; } } + [MonoTODO] public override XmlSchemaType XmlType { get { return schemaType; } } diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttribute.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttribute.cs index b4b50820589..04ce21971ae 100644 --- a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttribute.cs +++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttribute.cs @@ -448,13 +448,9 @@ namespace System.Xml.Schema validatedUse = Use; #if NET_2_0 - if (attributeType != null) { - attributeSchemaType = attributeType as XmlSchemaSimpleType; - if (attributeType == XmlSchemaSimpleType.AnySimpleType) - attributeSchemaType = XmlSchemaSimpleType.XsAnySimpleType; - if (attributeSchemaType == null) - attributeSchemaType = XmlSchemaType.GetBuiltInSimpleType (SchemaTypeName); - } + attributeSchemaType = attributeType as XmlSchemaSimpleType; + if (attributeSchemaType == null) + attributeSchemaType = XmlSchemaType.GetBuiltInSimpleType (((XmlSchemaDatatype) attributeType).TypeCode); #endif ValidationId = schema.ValidationId; diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaDatatype.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaDatatype.cs index 751560d988b..ca7f8db7c2f 100644 --- a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaDatatype.cs +++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaDatatype.cs @@ -79,12 +79,10 @@ namespace System.Xml.Schema throw new NotImplementedException (); } + [MonoTODO] public virtual bool IsDerivedFrom (XmlSchemaDatatype datatype) { - // It is documented to return always false, but - // actually returns true when the argument is for - // the same type (and it does not check null argument). - return this == datatype; + throw new NotImplementedException (); } #endif diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaElement.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaElement.cs index 86283db4e24..1eaeb7bd400 100644 --- a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaElement.cs +++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaElement.cs @@ -743,13 +743,9 @@ namespace System.Xml.Schema ident.Validate (h, schema); #if NET_2_0 - if (elementType != null) { - elementSchemaType = elementType as XmlSchemaType; - if (elementType == XmlSchemaSimpleType.AnySimpleType) - elementSchemaType = XmlSchemaSimpleType.XsAnySimpleType; - if (elementSchemaType == null) - elementSchemaType = XmlSchemaType.GetBuiltInSimpleType (SchemaTypeName); - } + elementSchemaType = elementType as XmlSchemaType; + if (elementSchemaType == null && elementType != null) + elementSchemaType = XmlSchemaType.GetBuiltInType (((XmlSchemaDatatype) elementType).TypeCode); #endif ValidationId = schema.ValidationId; diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSet.cs index 6c9eca9bcc6..76561d2deec 100644 --- a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSet.cs +++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSet.cs @@ -181,6 +181,7 @@ namespace System.Xml.Schema Add (schema); } + [MonoTODO ("We need to research more about the expected behavior")] public XmlSchema Add (XmlSchema schema) { schemas.Add (schema); diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaType.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaType.cs index 0ce5b5f87ae..45b07fc3e1a 100644 --- a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaType.cs +++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaType.cs @@ -134,6 +134,7 @@ namespace System.Xml.Schema } #if NET_2_0 + [MonoTODO] // LAMESPEC: for IDREFS it returns Idref. for ENTITIES // it returns Entity. for NMTOKENS it returns NmToken. [XmlIgnore] diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaValidator.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaValidator.cs index 1790c478aa8..d5702d2445f 100644 --- a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaValidator.cs +++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaValidator.cs @@ -181,8 +181,11 @@ namespace System.Xml.Schema set { xmlResolver = value; } } + [MonoTODO] public Uri SourceUri { get { return sourceUri; } + // FIXME: actually there seems no setter, but then + // it will never make sense. set { sourceUri = value; } } #endregion @@ -788,7 +791,7 @@ namespace System.Xml.Schema object parsedValue = null; try { parsedValue = getter (); - } catch (Exception ex) { // It is inevitable and bad manner. + } catch (Exception ex) { // FIXME: (wishlist) It is bad manner ;-( HandleError ("Attribute value is invalid against its data type " + dt.TokenizedType, ex); } XmlSchemaType type = info != null ? info.SchemaType : null; @@ -934,8 +937,8 @@ namespace System.Xml.Schema if (info != null) { info.IsNil = xsiNilDepth >= 0; info.SchemaElement = null; - info.SchemaType = Context.ActualType as XmlSchemaType; - if (info.SchemaType == null) + info.SchemaType = st; + if (st == null) info.SchemaType = XmlSchemaType.GetBuiltInSimpleType (dt.TypeCode); info.SchemaAttribute = null; info.IsDefault = false; // FIXME: might be true @@ -978,7 +981,7 @@ namespace System.Xml.Schema if (itemDatatype != null) { try { retValues [vi] = itemDatatype.ParseValue (each, nameTable, nsResolver); - } catch (Exception ex) { // It is inevitable and bad manner. + } catch (Exception ex) { // FIXME: (wishlist) better exception handling ;-( HandleError ("List type value contains one or more invalid values.", ex); break; } @@ -1000,7 +1003,7 @@ namespace System.Xml.Schema if (itemDatatype != null) { try { ret = itemDatatype.ParseValue (each, nameTable, nsResolver); - } catch (Exception) { // It is inevitable and bad manner. + } catch (Exception) { // FIXME: (wishlist) better exception handling ;-( continue; } } @@ -1045,7 +1048,7 @@ namespace System.Xml.Schema if (validatedDatatype != null) { try { ret = validatedDatatype.ParseValue (value, nameTable, nsResolver); - } catch (Exception ex) { // It is inevitable and bad manner. + } catch (Exception ex) { // FIXME: (wishlist) It is bad manner ;-( HandleError (String.Format ("Invalidly typed data was specified."), ex); } } @@ -1229,7 +1232,7 @@ namespace System.Xml.Schema if (dt != null) { try { identity = dt.ParseValue (value, nameTable, nsResolver); - } catch (Exception ex) { // It is inevitable and bad manner. + } catch (Exception ex) { // FIXME: (wishlist) This is bad manner ;-( HandleError ("Identity value is invalid against its data type " + dt.TokenizedType, ex); } } @@ -1391,7 +1394,7 @@ namespace System.Xml.Schema for (int i = 0; i < tmp.Length; i += 2) { try { schema = ReadExternalSchema (tmp [i + 1]); - } catch (Exception ex) { // It is inevitable and bad manner. + } catch (Exception ex) { // FIXME: (wishlist) It is bad manner ;-( HandleError ("Could not resolve schema location URI: " + schemaLocation, ex, true); continue; } @@ -1420,7 +1423,7 @@ namespace System.Xml.Schema try { schema = ReadExternalSchema (noNsSchemaLocation); - } catch (Exception ex) { // It is inevitable and bad manner. + } catch (Exception ex) { // FIXME: (wishlist) It is bad manner ;-( HandleError ("Could not resolve schema location URI: " + noNsSchemaLocation, ex, true); } if (schema != null && schema.TargetNamespace != null) diff --git a/mcs/class/System.XML/System.Xml/ChangeLog b/mcs/class/System.XML/System.Xml/ChangeLog index a2498bf3d6c..c7d7c295879 100644 --- a/mcs/class/System.XML/System.Xml/ChangeLog +++ b/mcs/class/System.XML/System.Xml/ChangeLog @@ -1,28 +1,3 @@ -2006-01-12 Atsushi Enomoto - - * XmlTextWriter.cs : Do not local duplicate of automatically-created - prefixes (i.e. check local autocreated prefixes other than - namespaces from ancestors). Fixed bug #77086 and #77087. - -2006-01-12 Atsushi Enomoto - - * XmlWriter.cs : use XmlChar.IsNmToken() to check argument and throw - ArgumentException in WriteNmTokenInternal(). - -2006-01-12 Atsushi Enomoto - - * XmlTextWriter.cs : Fixed bug #77094. Only XmlTextWriter checks - such invalid "xml" prefix which is being mapped to different - namespace URI than the predefined one. - Removed comment that does not make sense. - * XmlNamespaceManager.cs : IsValidDeclaration() could be private. - Added some comments. - -2006-01-11 Atsushi Enomoto - - * DTDObjectModel.cs : dtd2xsd fix; set use="optional" when an - attribute is #IMPLIED. - 2006-01-06 Atsushi Enomoto * XmlWriter.cs : In WriteNode(XPathNavigator, bool), Avoid diff --git a/mcs/class/System.XML/System.Xml/DTDObjectModel.cs b/mcs/class/System.XML/System.Xml/DTDObjectModel.cs index bae72caa7ba..e411b8fa08d 100644 --- a/mcs/class/System.XML/System.Xml/DTDObjectModel.cs +++ b/mcs/class/System.XML/System.Xml/DTDObjectModel.cs @@ -833,8 +833,6 @@ namespace Mono.Xml SetLineInfo (a); a.Name = Name; a.DefaultValue = resolvedNormalizedDefaultValue; - if (OccurenceType != DTDAttributeOccurenceType.Required) - a.Use = XmlSchemaUse.Optional; XmlQualifiedName qname = XmlQualifiedName.Empty; ArrayList enumeration = null; diff --git a/mcs/class/System.XML/System.Xml/XmlNamespaceManager.cs b/mcs/class/System.XML/System.Xml/XmlNamespaceManager.cs index 29afff1e604..ea6a8b50523 100644 --- a/mcs/class/System.XML/System.Xml/XmlNamespaceManager.cs +++ b/mcs/class/System.XML/System.Xml/XmlNamespaceManager.cs @@ -170,11 +170,9 @@ namespace System.Xml decls [declPos].Uri = uri; } - static string IsValidDeclaration (string prefix, string uri, bool throwException) + internal static string IsValidDeclaration (string prefix, string uri, bool throwException) { string message = null; - // It is funky, but it does not check whether prefix - // is equivalent to "xml" in case-insensitive means. if (prefix == PrefixXml && uri != XmlnsXml) message = String.Format ("Prefix \"xml\" can only be bound to the fixed namespace URI \"{0}\". \"{1}\" is invalid.", XmlnsXml, uri); else if (message == null && prefix == "xmlns") diff --git a/mcs/class/System.XML/System.Xml/XmlTextWriter.cs b/mcs/class/System.XML/System.Xml/XmlTextWriter.cs index 061d259b364..cc86640a281 100644 --- a/mcs/class/System.XML/System.Xml/XmlTextWriter.cs +++ b/mcs/class/System.XML/System.Xml/XmlTextWriter.cs @@ -752,6 +752,8 @@ openElements [openElementCount - 1]).IndentingOverriden; public override void WriteStartAttribute (string prefix, string localName, string ns) { if (prefix == "xml") { + // MS.NET looks to allow other names than + // lang and space (e.g. xml:link, xml:hack). ns = XmlNamespaceManager.XmlnsXml; if (localName == "lang") openXmlLang = true; @@ -797,7 +799,7 @@ openElements [openElementCount - 1]).IndentingOverriden; string formatPrefix = ""; if (ns != String.Empty && prefix != "xmlns") { - string existingPrefix = GetExistingPrefix (ns); + string existingPrefix = namespaceManager.LookupPrefix (ns, false); if (existingPrefix == null || existingPrefix == "") { bool createPrefix = false; @@ -852,15 +854,6 @@ openElements [openElementCount - 1]).IndentingOverriden; } } - string GetExistingPrefix (string ns) - { - if (newAttributeNamespaces.ContainsValue (ns)) - foreach (DictionaryEntry de in newAttributeNamespaces) - if (de.Value as string == ns) - return (string) de.Key; - return namespaceManager.LookupPrefix (ns, false); - } - private string CheckNewPrefix (bool createPrefix, string prefix, string ns) { do { @@ -923,14 +916,6 @@ openElements [openElementCount - 1]).IndentingOverriden; if ((prefix != null && prefix.Length > 0) && ((ns == null))) throw ArgumentError ("Cannot use a prefix with an empty namespace."); - // Considering the fact that WriteStartAttribute() - // automatically changes argument namespaceURI, this - // is kind of silly implementation. See bug #77094. - if (Namespaces && - ns != XmlNamespaceManager.XmlnsXml && - String.Compare (prefix, "xml", true) == 0) - throw new ArgumentException ("A prefix cannot be equivalent to \"xml\" in case-insensitive match."); - // ignore non-namespaced node's prefix. if (ns == null || ns == String.Empty) prefix = String.Empty; diff --git a/mcs/class/System.XML/System.Xml/XmlWriter.cs b/mcs/class/System.XML/System.Xml/XmlWriter.cs index 0010ce4c0da..3870f7e7df6 100644 --- a/mcs/class/System.XML/System.Xml/XmlWriter.cs +++ b/mcs/class/System.XML/System.Xml/XmlWriter.cs @@ -360,19 +360,16 @@ namespace System.Xml internal virtual void WriteNmTokenInternal (string name) { - bool valid = true; #if NET_2_0 switch (Settings.ConformanceLevel) { case ConformanceLevel.Document: case ConformanceLevel.Fragment: - valid = XmlChar.IsNmToken (name); - break; + XmlConvert.VerifyNMTOKEN (name); + break; } #else - valid = XmlChar.IsNmToken (name); + XmlConvert.VerifyNMTOKEN (name); #endif - if (!valid) - throw new ArgumentException ("Argument name is not a valid NMTOKEN."); WriteString (name); } diff --git a/mcs/class/System.XML/System.Xml_test.dll.sources b/mcs/class/System.XML/System.Xml_test.dll.sources index 58842945d46..e1f968d3e0b 100644 --- a/mcs/class/System.XML/System.Xml_test.dll.sources +++ b/mcs/class/System.XML/System.Xml_test.dll.sources @@ -44,13 +44,9 @@ System.Xml/nist_dom/fundamental/Element/Element.cs System.Xml/nist_dom/fundamental/NamedNodeMap/NamedNodeMap.cs System.Xml/nist_dom/fundamental/NodeList/NodeList.cs System.Xml/nist_dom/fundamental/Text/Text.cs -System.Xml.Schema/XmlSchemaAssertion.cs -System.Xml.Schema/XmlSchemaBuiltInDatatypeTests.cs -System.Xml.Schema/XmlSchemaDatatypeTests.cs -System.Xml.Schema/XmlSchemaLengthFacetTests.cs System.Xml.Schema/XmlSchemaTests.cs -System.Xml.Schema/XmlSchemaTypeTests.cs System.Xml.Schema/XmlSchemaSetTests.cs +System.Xml.Schema/XmlSchemaLengthFacetTests.cs System.Xml.Serialization/ComplexDataStructure.cs System.Xml.Serialization/DeserializeTests.cs System.Xml.Serialization/SoapAttributeAttributeTests.cs @@ -74,6 +70,8 @@ System.Xml.Serialization/XmlSchemaExporterTests.cs System.Xml.Serialization/XmlSerializationWriterTests.cs System.Xml.Serialization/XmlTextAttributeTests.cs System.Xml.Serialization/XmlTypeAttributeTests.cs +System.Xml.Schema/XmlSchemaAssertion.cs +System.Xml.Schema/XmlSchemaBuiltInDatatypeTests.cs System.Xml.Serialization/XmlSerializerTests.cs System.Xml.Serialization/XmlSerializerTestClasses.cs System.Xml.XPath/SelectNodesTests.cs diff --git a/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog b/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog index 2f486b9cb16..b40a0c2b464 100644 --- a/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog +++ b/mcs/class/System.XML/Test/System.Xml.Schema/ChangeLog @@ -1,17 +1,3 @@ -2006-01-10 Atsushi Enomoto - - * XmlSchemaTypeTests.cs : new file. Test for TypeCode. - * XmlSchemaSetTests.cs : added more tests for Add() and marked one as - NotWorking (we need info on how consistent this method is). - -2006-01-10 Atsushi Enomoto - - * XmlSchemaDatatypeTests.cs : oops sys.col.generic is NET_2_0. - -2006-01-10 Atsushi Enomoto - - * XmlSchemaDatatypeTests.cs : added test for 2.0 IsDerivedFrom(). - 2006-01-06 Atsushi Enomoto * XmlSchemaSetTests.cs : added AddRollbackIsCompiled(); Add() changes diff --git a/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaDatatypeTests.cs b/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaDatatypeTests.cs index e7420bf4a67..a0d23a0ea61 100644 --- a/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaDatatypeTests.cs +++ b/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaDatatypeTests.cs @@ -11,16 +11,8 @@ using System; using System.IO; using System.Xml; using System.Xml.Schema; -#if NET_2_0 -using System.Collections.Generic; -#endif using NUnit.Framework; -using QName = System.Xml.XmlQualifiedName; -using SimpleType = System.Xml.Schema.XmlSchemaSimpleType; -using SimpleRest = System.Xml.Schema.XmlSchemaSimpleTypeRestriction; -using AssertType = NUnit.Framework.Assert; - namespace MonoTests.System.Xml { [TestFixture] @@ -47,7 +39,6 @@ namespace MonoTests.System.Xml } [Test] - [Category ("NotWorking")] // ContentTypeParticle impl. difference. public void TestAnyType () { XmlSchema schema = GetSchema ("Test/XmlFiles/xsd/datatypesTest.xsd"); @@ -80,80 +71,5 @@ namespace MonoTests.System.Xml // AssertDatatype (schema, 6, XmlTokenizedType.NMTOKEN, typeof (string []), "f o o", new string [] {"f", "o", "o"}); } -#if NET_2_0 - string [] allTypes = new string [] { - "string", "boolean", "float", "double", "decimal", - "duration", "dateTime", "time", "date", "gYearMonth", - "gYear", "gMonthDay", "gDay", "gMonth", "hexBinary", - "base64Binary", "anyURI", "QName", "NOTATION", - "normalizedString", "token", "language", "IDREFS", - "ENTITIES", "NMTOKEN", "NMTOKENS", "Name", "NCName", - "ID", "IDREF", "ENTITY", "integer", - "nonPositiveInteger", "negativeInteger", "long", - "int", "short", "byte", "nonNegativeInteger", - "unsignedLong", "unsignedInt", "unsignedShort", - "unsignedByte", "positiveInteger" - }; - - XmlSchemaSet allWrappers; - - void SetupSimpleTypeWrappers () - { - XmlSchema schema = new XmlSchema (); - List qnames = new List (); - foreach (string name in allTypes) { - SimpleType st = new SimpleType (); - st.Name = "x-" + name; - SimpleRest r = new SimpleRest (); - st.Content = r; - QName qname = new QName (name, XmlSchema.Namespace); - r.BaseTypeName = qname; - qnames.Add (qname); - schema.Items.Add (st); - } - XmlSchemaSet sset = new XmlSchemaSet (); - sset.Add (schema); - sset.Compile (); - allWrappers = sset; - } - - XmlSchemaDatatype GetDatatype (string name) - { - return (allWrappers.GlobalTypes [new QName ("x-" + name, - String.Empty)] as SimpleType).Datatype; - } - - string [] GetDerived (string target) - { - XmlSchemaDatatype strType = GetDatatype (target); - List results = new List (); - foreach (string name in allTypes) { - if (name == target) - continue; - XmlSchemaDatatype deriv = GetDatatype (name); - if (deriv.IsDerivedFrom (strType)) - results.Add (name); - else Console.Error.WriteLine (deriv.GetType () + " is not derived from " + strType.GetType ()); - } - return results.ToArray (); - } - - [Test] - public void IsDerivedFrom () - { - SetupSimpleTypeWrappers (); - - // Funky, but XmlSchemaDatatype.IsDerivedFrom() is - // documented to always return false, but actually - // matches the same type - which could be guessed that - // this method is used only to detect user-defined - // simpleType derivation. - foreach (string b in allTypes) - foreach (string d in allTypes) - AssertType.AreEqual (b == d, GetDatatype (d).IsDerivedFrom (GetDatatype (b)), b); - - AssertType.IsFalse (GetDatatype ("string").IsDerivedFrom (null), "null arg"); - } -#endif } } diff --git a/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaSetTests.cs b/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaSetTests.cs index 20ad97f68b2..56a066c6760 100644 --- a/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaSetTests.cs +++ b/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaSetTests.cs @@ -56,22 +56,9 @@ namespace MonoTests.System.Xml } [Test] - public void AddSchemaThenReader () - { - XmlSchemaSet ss = new XmlSchemaSet (); - XmlDocument doc = new XmlDocument (); - doc.LoadXml (""); - XmlSchema xs = new XmlSchema (); - xs.TargetNamespace = "ab"; - ss.Add (xs); - ss.Add ("ab", new XmlNodeReader (doc)); - } - - [Test] - [Category ("NotWorking")] // How can we differentiate this - // case and the testcase above? + [Ignore ("This behavior might be changed, since Add(XmlSchema) does not throw any exceptions, while this does.")] [ExpectedException (typeof (ArgumentException))] - public void AddReaderTwice () + public void AddTwice () { XmlSchemaSet ss = new XmlSchemaSet (); XmlDocument doc = new XmlDocument (); @@ -80,16 +67,6 @@ namespace MonoTests.System.Xml ss.Add ("ab", new XmlNodeReader (doc)); } - [Test] - public void AddSchemaTwice () - { - XmlSchemaSet ss = new XmlSchemaSet (); - XmlDocument doc = new XmlDocument (); - doc.LoadXml (""); - ss.Add (XmlSchema.Read (new XmlNodeReader (doc), null)); - ss.Add (XmlSchema.Read (new XmlNodeReader (doc), null)); - } - [Test] public void CompilationSettings () { diff --git a/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaTypeTests.cs b/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaTypeTests.cs deleted file mode 100644 index f97b6bddc44..00000000000 --- a/mcs/class/System.XML/Test/System.Xml.Schema/XmlSchemaTypeTests.cs +++ /dev/null @@ -1,101 +0,0 @@ -// -// System.Xml.XmlSchemaSetTests.cs -// -// Author: -// Atsushi Enomoto -// -// (C) 2004 Novell Inc. -// - -using System; -using System.Collections; -using System.IO; -using System.Xml; -using System.Xml.Schema; -using NUnit.Framework; - -using QName = System.Xml.XmlQualifiedName; -using SimpleType = System.Xml.Schema.XmlSchemaSimpleType; -using SimpleRest = System.Xml.Schema.XmlSchemaSimpleTypeRestriction; -using AssertType = NUnit.Framework.Assert; - -namespace MonoTests.System.Xml -{ - [TestFixture] - public class XmlSchemaTypeTests - { -#if NET_2_0 - string [] all_types = new string [] { - "string", "boolean", "float", "double", "decimal", - "duration", "dateTime", "time", "date", "gYearMonth", - "gYear", "gMonthDay", "gDay", "gMonth", "hexBinary", - "base64Binary", "anyURI", "QName", "NOTATION", - "normalizedString", "token", "language", "IDREFS", - "ENTITIES", "NMTOKEN", "NMTOKENS", "Name", "NCName", - "ID", "IDREF", "ENTITY", "integer", - "nonPositiveInteger", "negativeInteger", "long", - "int", "short", "byte", "nonNegativeInteger", - "unsignedLong", "unsignedInt", "unsignedShort", - "unsignedByte", "positiveInteger" - }; - - XmlTypeCode [] type_codes = new XmlTypeCode [] { - XmlTypeCode.String, - XmlTypeCode.Boolean, - XmlTypeCode.Float, - XmlTypeCode.Double, - XmlTypeCode.Decimal, - XmlTypeCode.Duration, - XmlTypeCode.DateTime, - XmlTypeCode.Time, - XmlTypeCode.Date, - XmlTypeCode.GYearMonth, - XmlTypeCode.GYear, - XmlTypeCode.GMonthDay, - XmlTypeCode.GDay, - XmlTypeCode.GMonth, - XmlTypeCode.HexBinary, - XmlTypeCode.Base64Binary, - XmlTypeCode.AnyUri, - XmlTypeCode.QName, - XmlTypeCode.Notation, - XmlTypeCode.NormalizedString, - XmlTypeCode.Token, - XmlTypeCode.Language, - XmlTypeCode.Idref, // IDREFS (LAMESPEC) - XmlTypeCode.Entity, // ENTITIES (LAMESPEC) - XmlTypeCode.NmToken, - XmlTypeCode.NmToken, // NMTOKENS (LAMESPEC) - XmlTypeCode.Name, - XmlTypeCode.NCName, - XmlTypeCode.Id, - XmlTypeCode.Idref, - XmlTypeCode.Entity, - XmlTypeCode.Integer, - XmlTypeCode.NonPositiveInteger, - XmlTypeCode.NegativeInteger, - XmlTypeCode.Long, - XmlTypeCode.Int, - XmlTypeCode.Short, - XmlTypeCode.Byte, - XmlTypeCode.NonNegativeInteger, - XmlTypeCode.UnsignedLong, - XmlTypeCode.UnsignedInt, - XmlTypeCode.UnsignedShort, - XmlTypeCode.UnsignedByte, - XmlTypeCode.PositiveInteger}; - - [Test] - public void TypeCode () - { - for (int i = 0; i < all_types.Length; i++) { - string name = all_types [i]; - QName qname = new QName (name, XmlSchema.Namespace); - Assert.AreEqual (type_codes [i], - XmlSchemaType.GetBuiltInSimpleType (qname).TypeCode, name); - } - } - -#endif - } -} diff --git a/mcs/class/System.XML/Test/System.Xml/ChangeLog b/mcs/class/System.XML/Test/System.Xml/ChangeLog index 2e69a65947e..441ca9c9bfa 100644 --- a/mcs/class/System.XML/Test/System.Xml/ChangeLog +++ b/mcs/class/System.XML/Test/System.Xml/ChangeLog @@ -1,17 +1,3 @@ -2006-01-12 Atsushi Enomoto - - * XmlTextWriterTests.cs : Split AutoCreatePrefixes() and marked as - Ignore rather than NotWorking. Also it is not for bug #77086 and - #77077 (they were fixed). See bug #77088. - -2006-01-12 Atsushi Enomoto - - * XmlTextWriterTests.cs : re-enabled WriteNmToken_InvalidChars(). - -2006-01-12 Atsushi Enomoto - - * XmlTextWriterTests.cs : re-enabled bug #77094 related tests. - 2006-01-06 Atsushi Enomoto * XmlWriterTests.cs : added tests for WriteNode(XPathNavigator, bool) diff --git a/mcs/class/System.XML/Test/System.Xml/XmlTextWriterTests.cs b/mcs/class/System.XML/Test/System.Xml/XmlTextWriterTests.cs index b70e2cce2a1..90661afd68c 100644 --- a/mcs/class/System.XML/Test/System.Xml/XmlTextWriterTests.cs +++ b/mcs/class/System.XML/Test/System.Xml/XmlTextWriterTests.cs @@ -205,26 +205,29 @@ namespace MonoTests.System.Xml } [Test] - [Ignore ("Due to the (silly) dependency on bug #77088, this test will not be fixed. The test could be rewritten but it depends on the original test author.")] + [Category ("NotWorking")] // bug #77086, #77087 and #77088 public void AutoCreatePrefixes () { - xtw.WriteStartElement ("root"); xtw.WriteAttributeString (null, "abc", "http://somenamespace.com", "http://abc.def"); xtw.WriteAttributeString (null, "def", "http://somenamespace.com", "http://def.ghi"); xtw.WriteAttributeString (null, "ghi", "http://othernamespace.com", "http://ghi.jkl"); - xtw.WriteEndElement (); - Assert.AreEqual ("", StringWriterText, "#1"); - } +#if NET_2_0 + Assert.AreEqual ("d0p1:abc='http://abc.def' d0p1:def='http://def.ghi'" + + " d0p2:ghi='http://ghi.jkl'", StringWriterText, "#1"); +#else + // on 1.x a new prefix is always created when level is 0 ? + Assert.AreEqual ("d0p1:abc='http://abc.def' d0p2:def='http://def.ghi'" + + " d0p3:ghi='http://ghi.jkl'", StringWriterText, "#1"); +#endif + + sw.GetStringBuilder ().Length = 0; + CreateXmlTextWriter (); - [Test] - [Ignore ("Due to the (silly) dependency on bug #77088, this test will not be fixed. The test could be rewritten but it depends on the original test author.")] - public void AutoCreatePrefixes2 () - { xtw.WriteStartElement ("person"); - xtw.WriteAttributeString (null, "name", "http://somenamespace.com", "Driesen"); - xtw.WriteAttributeString (null, "initials", "http://othernamespace.com", "GD"); - xtw.WriteAttributeString (null, "firstName", "http://somenamespace.com", "Gert"); + xtw.WriteAttributeString (null, "name", "http://somenamespace.com", "Gates"); + xtw.WriteAttributeString (null, "initials", "http://othernamespace.com", "BG"); + xtw.WriteAttributeString (null, "firstName", "http://somenamespace.com", "Bill"); xtw.WriteStartElement ("address"); xtw.WriteAttributeString (null, "street", "http://somenamespace.com", "Campus"); xtw.WriteAttributeString (null, "number", "http://othernamespace.com", "1"); @@ -235,9 +238,9 @@ namespace MonoTests.System.Xml Assert.AreEqual ( "" + " - - * datatypesTest.xsd : missing required file for xsd tests. - 2005-12-26 Atsushi Enomoto * multi-schemaLocation.xml, diff --git a/mcs/class/System.XML/Test/XmlFiles/xsd/datatypesTest.xsd b/mcs/class/System.XML/Test/XmlFiles/xsd/datatypesTest.xsd deleted file mode 100644 index 50fb15c3740..00000000000 --- a/mcs/class/System.XML/Test/XmlFiles/xsd/datatypesTest.xsd +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - -- cgit v1.2.3