Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mcs/class/System.XML')
-rw-r--r--mcs/class/System.XML/.cvsignore9
-rw-r--r--mcs/class/System.XML/ChangeLog56
-rw-r--r--mcs/class/System.XML/Mono.System.XML.csproj1265
-rw-r--r--mcs/class/System.XML/Mono.System.XML.sln27
-rwxr-xr-xmcs/class/System.XML/README8
-rw-r--r--mcs/class/System.XML/System.XML.build38
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/BUGS-MS.txt20
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/BUGS.txt5
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/ChangeLog69
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/ValidationEventArgs.cs38
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/ValidationHandler.cs48
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchema.cs711
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaAll.cs165
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaAnnotated.cs56
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaAnnotation.cs145
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaAny.cs192
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaAnyAttribute.cs169
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaAppInfo.cs91
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaAttribute.cs435
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaAttributeGroup.cs208
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaAttributeGroupRef.cs126
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaChoice.cs203
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaCollection.cs130
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaCollectionEnumerator.cs47
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContent.cs162
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContentExtension.cs254
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContentRestriction.cs256
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexType.cs463
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaContent.cs15
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaContentModel.cs19
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaContentProcessing.cs22
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaContentType.cs17
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaDatatype.cs30
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaDerivationMethod.cs31
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaDocumentation.cs104
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaElement.cs625
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaEnumerationFacet.cs87
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaException.cs94
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaExternal.cs62
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaFacet.cs37
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaForm.cs19
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaFractionDigitsFacet.cs98
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaGroup.cs195
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaGroupBase.cs20
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaGroupRef.cs156
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaIdentityConstraint.cs91
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaImport.cs109
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaInclude.cs97
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaInfo.cs25
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaKey.cs127
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaKeyref.cs151
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaLengthFacet.cs96
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxExclusiveFacet.cs96
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxInclusiveFacet.cs96
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxLengthFacet.cs97
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaMinExclusiveFacet.cs96
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaMinInclusiveFacet.cs95
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaMinLengthFacet.cs96
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaNotation.cs158
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaNumericFacet.cs16
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaObject.cs75
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaObjectCollection.cs88
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaObjectEnumerator.cs49
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaObjectTable.cs51
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaParticle.cs98
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaPatternFacet.cs87
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaReader.cs358
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaRedefine.cs151
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaSequence.cs202
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContent.cs146
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContentExtension.cs190
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContentRestriction.cs337
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleType.cs237
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeContent.cs17
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeList.cs152
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeRestriction.cs267
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeUnion.cs175
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaTotalDigitsFacet.cs96
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaType.cs81
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaUnique.cs126
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaUse.cs22
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaUtil.cs299
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaWhiteSpaceFacet.cs97
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSchemaXPath.cs104
-rwxr-xr-xmcs/class/System.XML/System.Xml.Schema/XmlSeverityType.cs15
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/AssemblyInfo.cs58
-rwxr-xr-xmcs/class/System.XML/System.Xml.Serialization/ChangeLog143
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/CodeIdentifier.cs50
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/CodeIdentifiers.cs110
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/IXmlSerializable.cs19
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/SchemaTypes.cs23
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/SoapAttributeAttribute.cs61
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/SoapAttributeOverrides.cs72
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/SoapAttributes.cs88
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/SoapCodeExporter.cs75
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/SoapElementAttribute.cs60
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/SoapEnumAttribute.cs40
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/SoapIgnoreAttribute.cs25
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/SoapIncludeAttribute.cs38
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/SoapReflectionImporter.cs90
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/SoapSchemaExporter.cs42
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/SoapSchemaImporter.cs71
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/SoapSchemaMember.cs44
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/SoapTypeAttribute.cs59
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/TypeData.cs82
-rwxr-xr-xmcs/class/System.XML/System.Xml.Serialization/TypeMember.cs54
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/TypeTranslator.cs53
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/UnreferencedObjectEventArgs.cs35
-rwxr-xr-xmcs/class/System.XML/System.Xml.Serialization/UnreferencedObjectEventHandler.cs16
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlAnyAttributeAttribute.cs28
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlAnyElementAttribute.cs66
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlAnyElementAttributes.cs66
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlArrayAttribute.cs90
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlArrayItemAttribute.cs85
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlArrayItemAttributes.cs61
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlAttributeAttribute.cs95
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlAttributeEventArgs.cs49
-rwxr-xr-xmcs/class/System.XML/System.Xml.Serialization/XmlAttributeEventHandler.cs16
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlAttributeOverrides.cs60
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlAttributes.cs439
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlChoiceIdentifierAttribute.cs51
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlCodeExporter.cs81
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlCustomFormatter.cs133
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlElementAttribute.cs104
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlElementAttributes.cs59
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlElementEventArgs.cs53
-rwxr-xr-xmcs/class/System.XML/System.Xml.Serialization/XmlElementEventHandler.cs16
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlEnumAttribute.cs41
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlIgnoreAttribute.cs26
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlIncludeAttribute.cs37
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlMapping.cs23
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlMemberMapping.cs56
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlMembersMapping.cs53
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlNamespaceDeclarationsAttribute.cs26
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlNodeEventArgs.cs82
-rwxr-xr-xmcs/class/System.XML/System.Xml.Serialization/XmlNodeEventHandler.cs16
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs128
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlReflectionMember.cs66
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlRootAttribute.cs73
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlSchemaExporter.cs58
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs91
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlSchemas.cs148
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlSerializationCollectionFixupCallback.cs17
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlSerializationFixupCallback.cs17
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlSerializationReadCallback.cs17
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlSerializationReader.cs634
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriteCallback.cs17
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriter.cs571
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs1012
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlSerializerNamespaces.cs76
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlTextAttribute.cs61
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlTypeAttribute.cs60
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlTypeMapping.cs50
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/ChangeLog183
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/DefaultContext.cs618
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/Expression.cs1009
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/IXPathNavigable.cs16
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/Iterator.cs607
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/Parser.cs1107
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/Parser.jay412
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/Tokenizer.cs334
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/XPathDocument.cs68
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/XPathException.cs27
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/XPathExpression.cs50
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/XPathNamespaceScope.cs18
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs261
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/XPathNodeIterator.cs63
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/XPathNodeType.cs25
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/XPathResultType.cs22
-rwxr-xr-xmcs/class/System.XML/System.Xml.XPath/XmlCaseOrder.cs33
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/XmlDataType.cs17
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/XmlSortOrder.cs17
-rw-r--r--mcs/class/System.XML/System.Xml.Xsl/ChangeLog25
-rw-r--r--mcs/class/System.XML/System.Xml.Xsl/IXsltContextFunction.cs28
-rw-r--r--mcs/class/System.XML/System.Xml.Xsl/IXsltContextVariable.cs27
-rw-r--r--mcs/class/System.XML/System.Xml.Xsl/XslTransform.cs314
-rw-r--r--mcs/class/System.XML/System.Xml.Xsl/XsltArgumentList.cs131
-rw-r--r--mcs/class/System.XML/System.Xml.Xsl/XsltCompileException.cs56
-rw-r--r--mcs/class/System.XML/System.Xml.Xsl/XsltContext.cs45
-rw-r--r--mcs/class/System.XML/System.Xml.Xsl/XsltException.cs72
-rw-r--r--mcs/class/System.XML/System.Xml/ChangeLog1293
-rw-r--r--mcs/class/System.XML/System.Xml/Driver.cs56
-rwxr-xr-xmcs/class/System.XML/System.Xml/EntityHandling.cs29
-rwxr-xr-xmcs/class/System.XML/System.Xml/Formatting.cs29
-rwxr-xr-xmcs/class/System.XML/System.Xml/IHasXmlNode.cs15
-rw-r--r--mcs/class/System.XML/System.Xml/IXmlLineInfo.cs19
-rwxr-xr-xmcs/class/System.XML/System.Xml/NameTable.cs74
-rw-r--r--mcs/class/System.XML/System.Xml/Profile.cs47
-rw-r--r--mcs/class/System.XML/System.Xml/ReadState.cs41
-rw-r--r--mcs/class/System.XML/System.Xml/TODOAttribute.cs32
-rwxr-xr-xmcs/class/System.XML/System.Xml/ValidationType.cs20
-rw-r--r--mcs/class/System.XML/System.Xml/WhitespaceHandling.cs33
-rwxr-xr-xmcs/class/System.XML/System.Xml/WriteState.cs53
-rw-r--r--mcs/class/System.XML/System.Xml/XmlAttribute.cs244
-rw-r--r--mcs/class/System.XML/System.Xml/XmlAttributeCollection.cs207
-rw-r--r--mcs/class/System.XML/System.Xml/XmlCDataSection.cs54
-rw-r--r--mcs/class/System.XML/System.Xml/XmlChar.cs205
-rw-r--r--mcs/class/System.XML/System.Xml/XmlCharacterData.cs134
-rw-r--r--mcs/class/System.XML/System.Xml/XmlComment.cs65
-rwxr-xr-xmcs/class/System.XML/System.Xml/XmlConstructs.cs545
-rwxr-xr-xmcs/class/System.XML/System.Xml/XmlConvert.cs329
-rw-r--r--mcs/class/System.XML/System.Xml/XmlDeclaration.cs136
-rw-r--r--mcs/class/System.XML/System.Xml/XmlDocument.cs891
-rw-r--r--mcs/class/System.XML/System.Xml/XmlDocumentFragment.cs125
-rw-r--r--mcs/class/System.XML/System.Xml/XmlDocumentNavigator.cs304
-rw-r--r--mcs/class/System.XML/System.Xml/XmlDocumentType.cs98
-rw-r--r--mcs/class/System.XML/System.Xml/XmlElement.cs383
-rwxr-xr-xmcs/class/System.XML/System.Xml/XmlEntity.cs123
-rw-r--r--mcs/class/System.XML/System.Xml/XmlEntityReference.cs75
-rwxr-xr-xmcs/class/System.XML/System.Xml/XmlException.cs93
-rw-r--r--mcs/class/System.XML/System.Xml/XmlImplementation.cs43
-rw-r--r--mcs/class/System.XML/System.Xml/XmlLinkedNode.cs77
-rw-r--r--mcs/class/System.XML/System.Xml/XmlNameTable.cs20
-rw-r--r--mcs/class/System.XML/System.Xml/XmlNamedNodeMap.cs114
-rw-r--r--mcs/class/System.XML/System.Xml/XmlNamespaceManager.cs182
-rw-r--r--mcs/class/System.XML/System.Xml/XmlNode.cs532
-rw-r--r--mcs/class/System.XML/System.Xml/XmlNodeArrayList.cs36
-rwxr-xr-xmcs/class/System.XML/System.Xml/XmlNodeChangedAction.cs27
-rw-r--r--mcs/class/System.XML/System.Xml/XmlNodeChangedEventArgs.cs67
-rwxr-xr-xmcs/class/System.XML/System.Xml/XmlNodeChangedEventHandler.cs14
-rw-r--r--mcs/class/System.XML/System.Xml/XmlNodeList.cs42
-rw-r--r--mcs/class/System.XML/System.Xml/XmlNodeListChildren.cs146
-rwxr-xr-xmcs/class/System.XML/System.Xml/XmlNodeOrder.cs19
-rwxr-xr-xmcs/class/System.XML/System.Xml/XmlNodeReader.cs420
-rw-r--r--mcs/class/System.XML/System.Xml/XmlNodeType.cs93
-rwxr-xr-xmcs/class/System.XML/System.Xml/XmlNotation.cs100
-rw-r--r--mcs/class/System.XML/System.Xml/XmlParserContext.cs186
-rw-r--r--mcs/class/System.XML/System.Xml/XmlProcessingInstruction.cs103
-rw-r--r--mcs/class/System.XML/System.Xml/XmlQualifiedName.cs116
-rw-r--r--mcs/class/System.XML/System.Xml/XmlReader.cs374
-rw-r--r--mcs/class/System.XML/System.Xml/XmlResolver.cs32
-rw-r--r--mcs/class/System.XML/System.Xml/XmlSignificantWhitespace.cs72
-rw-r--r--mcs/class/System.XML/System.Xml/XmlSpace.cs37
-rw-r--r--mcs/class/System.XML/System.Xml/XmlText.cs76
-rw-r--r--mcs/class/System.XML/System.Xml/XmlTextReader.cs1741
-rw-r--r--mcs/class/System.XML/System.Xml/XmlTextWriter.cs700
-rw-r--r--mcs/class/System.XML/System.Xml/XmlTextWriterOpenElement.cs72
-rwxr-xr-xmcs/class/System.XML/System.Xml/XmlTokenizedType.cs27
-rwxr-xr-xmcs/class/System.XML/System.Xml/XmlUrlResolver.cs41
-rw-r--r--mcs/class/System.XML/System.Xml/XmlValidatingReader.cs341
-rw-r--r--mcs/class/System.XML/System.Xml/XmlWhitespace.cs72
-rw-r--r--mcs/class/System.XML/System.Xml/XmlWriter.cs258
-rw-r--r--mcs/class/System.XML/Test/.cvsignore4
-rw-r--r--mcs/class/System.XML/Test/AllTests.cs52
-rw-r--r--mcs/class/System.XML/Test/ChangeLog598
-rw-r--r--mcs/class/System.XML/Test/Microsoft.Test.csproj162
-rw-r--r--mcs/class/System.XML/Test/Mono.Test.csproj167
-rw-r--r--mcs/class/System.XML/Test/MonoMicro.Test.csproj212
-rwxr-xr-xmcs/class/System.XML/Test/NameTableTests.cs91
-rw-r--r--mcs/class/System.XML/Test/SelectNodesTests.cs227
-rw-r--r--mcs/class/System.XML/Test/System.XML_linux_test.args32
-rw-r--r--mcs/class/System.XML/Test/System.XML_test.build37
-rw-r--r--mcs/class/System.XML/Test/TheTests.cs93
-rw-r--r--mcs/class/System.XML/Test/XPathNavigatorEvaluateTests.cs212
-rw-r--r--mcs/class/System.XML/Test/XPathNavigatorMatchesTests.cs116
-rw-r--r--mcs/class/System.XML/Test/XPathNavigatorTests.cs172
-rw-r--r--mcs/class/System.XML/Test/XmlAttributeCollectionTests.cs149
-rw-r--r--mcs/class/System.XML/Test/XmlAttributeTests.cs124
-rwxr-xr-xmcs/class/System.XML/Test/XmlCDataSectionTests.cs99
-rw-r--r--mcs/class/System.XML/Test/XmlCharacterDataTests.cs175
-rwxr-xr-xmcs/class/System.XML/Test/XmlCommentTests.cs107
-rwxr-xr-xmcs/class/System.XML/Test/XmlDeclarationTests.cs153
-rwxr-xr-xmcs/class/System.XML/Test/XmlDocumentFragmentTests.cs93
-rw-r--r--mcs/class/System.XML/Test/XmlDocumentTests.cs875
-rwxr-xr-xmcs/class/System.XML/Test/XmlDocumentTypeTests.cs104
-rw-r--r--mcs/class/System.XML/Test/XmlElementTests.cs337
-rwxr-xr-xmcs/class/System.XML/Test/XmlEntityReferenceTests.cs35
-rw-r--r--mcs/class/System.XML/Test/XmlNamespaceManagerTests.cs138
-rw-r--r--mcs/class/System.XML/Test/XmlNodeListTests.cs215
-rw-r--r--mcs/class/System.XML/Test/XmlNodeTests.cs182
-rw-r--r--mcs/class/System.XML/Test/XmlProcessingInstructionTests.cs36
-rwxr-xr-xmcs/class/System.XML/Test/XmlSignificantWhitespaceTests.cs127
-rw-r--r--mcs/class/System.XML/Test/XmlTextReaderTests.cs1776
-rw-r--r--mcs/class/System.XML/Test/XmlTextTests.cs36
-rw-r--r--mcs/class/System.XML/Test/XmlTextWriterTests.cs943
-rwxr-xr-xmcs/class/System.XML/Test/XmlWhiteSpaceTests.cs118
-rw-r--r--mcs/class/System.XML/Test/XmlWriterTests.cs206
-rw-r--r--mcs/class/System.XML/Test/makefile.gnu22
-rwxr-xr-xmcs/class/System.XML/list192
-rwxr-xr-xmcs/class/System.XML/list.unix226
-rw-r--r--mcs/class/System.XML/makefile.gnu16
281 files changed, 44585 insertions, 0 deletions
diff --git a/mcs/class/System.XML/.cvsignore b/mcs/class/System.XML/.cvsignore
new file mode 100644
index 00000000000..c61ca171548
--- /dev/null
+++ b/mcs/class/System.XML/.cvsignore
@@ -0,0 +1,9 @@
+*.dll
+list
+*.suo
+*.csproj.user
+bin
+obj
+.makefrag
+.response
+library-deps.stamp
diff --git a/mcs/class/System.XML/ChangeLog b/mcs/class/System.XML/ChangeLog
new file mode 100644
index 00000000000..9352d6954a4
--- /dev/null
+++ b/mcs/class/System.XML/ChangeLog
@@ -0,0 +1,56 @@
+2003-01-16 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * updated Mono.System.Xml.csproj. (patch by David B. Bitton)
+
+2002-12-10 Jeroen Janssen <japj@darius.demon.nl>
+
+ * updated .build file(s) to correctly contain required buildfile
+ attribute for nant
+
+2002-10-28 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * makefile.gnu: added test target.
+
+2002-08-22 Tim Coleman <tim@timcoleman.com>
+ * list.unix:
+ Add System.Xml.Serialization/XmlCustomFormatter.cs
+
+2002-08-19 Tim Coleman <tim@timcoleman.com>
+ * list.unix:
+ Add System.Xml.Serialization/XmlSerializationWriter.cs
+
+2002-07-24 Tim Coleman <tim@timcoleman.com>
+ * list.unix:
+ Add some more classes to this build list.
+
+2002-07-22 Tim Coleman <tim@timcoleman.com>
+ * list.unix:
+ Add System.Xml.Serialization/SoapReflectionImporter.cs to build
+ list.
+
+2002-07-22 Tim Coleman <tim@timcoleman.com>
+ * list.unix: added new classes to build list.
+
+2002-06-20 Ajay kumar Dwivedi <adwiv@yahoo.com>
+
+ * System.Xml.Serialization: Added to build target
+
+2002-05-24 Miguel de Icaza <miguel@ximian.com>
+
+ * System.Xml.Serialization/XmlElementAttribute.cs: Add allowmultiple
+
+2002-03-06 Jason Diamond <jason@injektilo.org>
+
+ * System.XML.build: Disable warning CS0679: Other languages may permit the internal virtual member 'foo' to be overridden.
+
+2002-02-23 Nick Drochak <ndrochak@gol.com>
+
+ * System.XML.build: Change dll name to System.Xml.dll from
+ System.XML.dll (not easy to notice, btw)
+
+2001-12-07 Nick Drochak <ndrochak@gol.com>
+
+ * ChangeLog: Add the change log to this directory
+
+ * System.XML.build: Add dependancy on linux target to test target. Need to have the dll before we can test it, right? Plus is encourages other to try 'make test'.
+
diff --git a/mcs/class/System.XML/Mono.System.XML.csproj b/mcs/class/System.XML/Mono.System.XML.csproj
new file mode 100644
index 00000000000..eddc84d379a
--- /dev/null
+++ b/mcs/class/System.XML/Mono.System.XML.csproj
@@ -0,0 +1,1265 @@
+<VisualStudioProject>
+ <CSHARP
+ ProjectType = "Local"
+ ProductVersion = "7.0.9466"
+ SchemaVersion = "1.0"
+ ProjectGuid = "{0CB7FB41-3C0F-40E8-ACD3-8C5B8BC35B2C}"
+ >
+ <Build>
+ <Settings
+ ApplicationIcon = ""
+ AssemblyKeyContainerName = ""
+ AssemblyName = "System.XML"
+ AssemblyOriginatorKeyFile = ""
+ DefaultClientScript = "JScript"
+ DefaultHTMLPageLayout = "Grid"
+ DefaultTargetSchema = "IE50"
+ DelaySign = "false"
+ OutputType = "Library"
+ RootNamespace = "System.XML"
+ StartupObject = ""
+ >
+ <Config
+ Name = "Debug"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "DEBUG;TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "true"
+ FileAlignment = "4096"
+ IncrementalBuild = "true"
+ Optimize = "false"
+ OutputPath = "bin\Debug\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ <Config
+ Name = "Release"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "false"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ Optimize = "true"
+ OutputPath = "bin\Release\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ </Settings>
+ <References>
+ <Reference
+ Name = "System"
+ AssemblyName = "System"
+ HintPath = "..\..\..\..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.dll"
+ />
+ <Reference
+ Name = "System.Data"
+ AssemblyName = "System.Data"
+ HintPath = "..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.Data.dll"
+ />
+ </References>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "System.Xml\ChangeLog"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Xml\Driver.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\EntityHandling.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\Formatting.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\IHasXmlNode.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\IXmlLineInfo.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\NameTable.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\Profile.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\ReadState.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\TODOAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\ValidationType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\WhitespaceHandling.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\WriteState.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlAttributeCollection.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlCDataSection.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlChar.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlCharacterData.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlComment.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlConstructs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlConvert.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlDeclaration.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlDocument.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlDocumentFragment.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlDocumentNavigator.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlDocumentType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlElement.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlEntity.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlEntityReference.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlException.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlImplementation.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlLinkedNode.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlNamedNodeMap.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlNamespaceManager.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlNameTable.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlNode.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlNodeArrayList.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlNodeChangedAction.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlNodeChangedEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlNodeChangedEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlNodeList.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlNodeListChildren.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlNodeOrder.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlNodeReader.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlNodeType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlNotation.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlParserContext.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlProcessingInstruction.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlQualifiedName.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlReader.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlResolver.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlSignificantWhitespace.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlSpace.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlText.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlTextReader.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlTextWriter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlTextWriterOpenElement.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlTokenizedType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlUrlResolver.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlWhitespace.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml\XmlWriter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\BUGS.txt"
+ BuildAction = "Content"
+ />
+ <File
+ RelPath = "System.Xml.Schema\BUGS-MS.txt"
+ BuildAction = "Content"
+ />
+ <File
+ RelPath = "System.Xml.Schema\ChangeLog"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Xml.Schema\ValidationEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\ValidationHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchema.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaAll.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaAnnotated.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaAnnotation.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaAny.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaAnyAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaAppInfo.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaAttributeGroup.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaAttributeGroupRef.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaChoice.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaCollection.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaCollectionEnumerator.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaComplexContent.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaComplexContentExtension.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaComplexContentRestriction.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaComplexType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaContent.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaContentModel.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaContentProcessing.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaContentType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaDatatype.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaDerivationMethod.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaDocumentation.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaElement.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaEnumerationFacet.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaException.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaExternal.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaFacet.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaForm.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaFractionDigitsFacet.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaGroup.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaGroupBase.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaGroupRef.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaIdentityConstraint.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaImport.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaInclude.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaInfo.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaKey.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaKeyref.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaLengthFacet.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaMaxExclusiveFacet.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaMaxInclusiveFacet.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaMaxLengthFacet.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaMinExclusiveFacet.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaMinInclusiveFacet.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaMinLengthFacet.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaNotation.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaNumericFacet.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaObject.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaObjectCollection.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaObjectEnumerator.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaObjectTable.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaParticle.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaPatternFacet.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaReader.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaRedefine.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaSequence.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaSimpleContent.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaSimpleContentExtension.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaSimpleContentRestriction.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaSimpleType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaSimpleTypeContent.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaSimpleTypeList.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaSimpleTypeRestriction.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaSimpleTypeUnion.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaTotalDigitsFacet.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaUnique.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaUse.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaUtil.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaWhiteSpaceFacet.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSchemaXPath.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\XmlSeverityType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Schema\CVS\Entries"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Xml.Schema\CVS\Repository"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Xml.Schema\CVS\Root"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\AssemblyInfo.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\ChangeLog"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\CodeIdentifier.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\CodeIdentifiers.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\IXmlSerializable.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\SchemaTypes.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\SoapAttributeAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\SoapAttributeOverrides.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\SoapAttributes.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\SoapCodeExporter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\SoapElementAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\SoapEnumAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\SoapIgnoreAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\SoapIncludeAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\SoapReflectionImporter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\SoapSchemaExporter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\SoapSchemaImporter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\SoapSchemaMember.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\SoapTypeAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\TypeData.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\TypeMember.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\TypeTranslator.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\UnreferencedObjectEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\UnreferencedObjectEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlAnyAttributeAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlAnyElementAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlAnyElementAttributes.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlArrayAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlArrayItemAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlArrayItemAttributes.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlAttributeAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlAttributeEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlAttributeEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlAttributeOverrides.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlAttributes.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlChoiceIdentifierAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlCodeExporter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlCustomFormatter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlElementAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlElementAttributes.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlElementEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlElementEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlEnumAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlIgnoreAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlIncludeAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlMapping.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlMemberMapping.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlMembersMapping.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlNamespaceDeclarationsAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlNodeEventArgs.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlNodeEventHandler.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlReflectionImporter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlReflectionMember.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlRootAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlSchemaExporter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlSchemaImporter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlSchemas.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlSerializationCollectionFixupCallback.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlSerializationFixupCallback.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlSerializationReadCallback.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlSerializationReader.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlSerializationWriteCallback.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlSerializationWriter.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlSerializer.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlSerializerNamespaces.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlTextAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlTypeAttribute.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\XmlTypeMapping.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\CVS\Entries"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\CVS\Repository"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Xml.Serialization\CVS\Root"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Xml.XPath\ChangeLog"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Xml.XPath\DefaultContext.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.XPath\Expression.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.XPath\Iterator.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.XPath\IXPathNavigable.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.XPath\Parser.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.XPath\Parser.jay"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "System.Xml.XPath\Tokenizer.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.XPath\XmlCaseOrder.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.XPath\XmlDataType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.XPath\XmlSortOrder.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.XPath\XPathDocument.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.XPath\XPathException.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.XPath\XPathExpression.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.XPath\XPathNamespaceScope.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.XPath\XPathNavigator.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.XPath\XPathNodeIterator.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.XPath\XPathNodeType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.XPath\XPathResultType.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Xsl\IXsltContextFunction.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Xsl\IXsltContextVariable.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Xsl\XsltArgumentList.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Xsl\XsltCompileException.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Xsl\XsltContext.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Xsl\XsltException.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "System.Xml.Xsl\XslTransform.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ </Include>
+ </Files>
+ </CSHARP>
+</VisualStudioProject>
+
diff --git a/mcs/class/System.XML/Mono.System.XML.sln b/mcs/class/System.XML/Mono.System.XML.sln
new file mode 100644
index 00000000000..0d2c98ae7dd
--- /dev/null
+++ b/mcs/class/System.XML/Mono.System.XML.sln
@@ -0,0 +1,27 @@
+Microsoft Visual Studio Solution File, Format Version 7.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.System.XML", "Mono.System.XML.csproj", "{0CB7FB41-3C0F-40E8-ACD3-8C5B8BC35B2C}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoMicro.Test", "Test\MonoMicro.Test.csproj", "{F7734143-3845-4288-B1CA-FE614FFA70F0}"
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ ConfigName.0 = Debug
+ ConfigName.1 = Release
+ EndGlobalSection
+ GlobalSection(ProjectDependencies) = postSolution
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {0CB7FB41-3C0F-40E8-ACD3-8C5B8BC35B2C}.Debug.ActiveCfg = Debug|.NET
+ {0CB7FB41-3C0F-40E8-ACD3-8C5B8BC35B2C}.Debug.Build.0 = Debug|.NET
+ {0CB7FB41-3C0F-40E8-ACD3-8C5B8BC35B2C}.Release.ActiveCfg = Release|.NET
+ {0CB7FB41-3C0F-40E8-ACD3-8C5B8BC35B2C}.Release.Build.0 = Release|.NET
+ {F7734143-3845-4288-B1CA-FE614FFA70F0}.Debug.ActiveCfg = Debug|.NET
+ {F7734143-3845-4288-B1CA-FE614FFA70F0}.Debug.Build.0 = Debug|.NET
+ {F7734143-3845-4288-B1CA-FE614FFA70F0}.Release.ActiveCfg = Release|.NET
+ {F7734143-3845-4288-B1CA-FE614FFA70F0}.Release.Build.0 = Release|.NET
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/mcs/class/System.XML/README b/mcs/class/System.XML/README
new file mode 100755
index 00000000000..498b53d0796
--- /dev/null
+++ b/mcs/class/System.XML/README
@@ -0,0 +1,8 @@
+Build instructions for use with the mono runtime.
+
+Run:
+ mcs @list.unix
+
+If no errors occourred, copy the generated System.Xml.dll file to the runtime dir
+(probably /usr/local/lib).
+
diff --git a/mcs/class/System.XML/System.XML.build b/mcs/class/System.XML/System.XML.build
new file mode 100644
index 00000000000..cee6b79d8b9
--- /dev/null
+++ b/mcs/class/System.XML/System.XML.build
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+
+<!-- NAnt build file for System.XML.dll -->
+
+<project name="System.XML" default="build">
+ <property name="debug" value="false"/>
+
+ <target name="build">
+ <mkdir dir="../lib"/>
+ <csc target="library" output="../lib/System.Xml.dll" debug="${debug}">
+ <!-- 'foo' is defined in multiple places; using definition from 'bar' -->
+ <arg value="/nowarn:1595"/>
+ <!-- Other languages may permit the internal virtual member 'foo' to be overridden -->
+ <arg value="/nowarn:0679"/>
+ <arg value="/nowarn:0649"/>
+ <sources>
+ <includes name="**/*.cs"/>
+ <excludes name="Test/**"/>
+ <!--excludes name="System.Xml.Serialization/**"/-->
+ </sources>
+ </csc>
+ <copy file="../lib/System.Xml.dll" tofile="Test/System.XML.dll"/>
+ <nant basedir="Test" target="build"/>
+ </target>
+
+ <target name="test" depends="build">
+ <nant basedir="Test" target="test"/>
+ </target>
+
+ <target name="clean">
+ <nant basedir="Test" target="clean"/>
+ <delete file="../lib/System.XML.dll" failonerror="false"/>
+ <delete file="../lib/System.Xml.dll" failonerror="false"/>
+ <delete file="Test/System.XML.dll" failonerror="false"/>
+ <delete file="Test/System.Xml.dll" failonerror="false"/>
+ <delete file="../lib/System.XML.pdb" failonerror="false"/>
+ </target>
+</project>
diff --git a/mcs/class/System.XML/System.Xml.Schema/BUGS-MS.txt b/mcs/class/System.XML/System.Xml.Schema/BUGS-MS.txt
new file mode 100755
index 00000000000..ad4ece9c910
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/BUGS-MS.txt
@@ -0,0 +1,20 @@
+BUGS in MS Implementation of XmlSchema:
+
+1. Does not allow duplicate values in lists for final* and block* attributes.
+ For example "restriction restriction" is not allowed even though its a valid
+ value for blockDefault.
+
+2. Resets the minOccurs to 0 if maxOccurs="0", whereas it should raise an error.
+
+3. Allows abstract="true" in the a localElement whereas it is not allowed.
+ <?xml version="1.0"?>
+ <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xsdtesting" xmlns:x="http://xsdtesting" elementFormDefault="qualified">
+ <xsd:element name="doc">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="elem1"/>
+ <xsd:element abstract="true" name="elem2"/> <!--This element is not valid -->
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema> \ No newline at end of file
diff --git a/mcs/class/System.XML/System.Xml.Schema/BUGS.txt b/mcs/class/System.XML/System.Xml.Schema/BUGS.txt
new file mode 100755
index 00000000000..cf602178c3d
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/BUGS.txt
@@ -0,0 +1,5 @@
+Bugs in Implementation:
+
+// None of the XmlSchemaObjects except the XmlSchema populate XmlSerializerNamespaces.
+//2. Non schema attributes are not being handled. Need an internal XmlAttribute constructor.
+//3. Documentation and appInfo's Markup is not being read in the Read() Method.
diff --git a/mcs/class/System.XML/System.Xml.Schema/ChangeLog b/mcs/class/System.XML/System.Xml.Schema/ChangeLog
new file mode 100755
index 00000000000..13917ba73c5
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/ChangeLog
@@ -0,0 +1,69 @@
+2002-07-23 Duncan Mak <duncan@ximian.com>
+
+ * XmlSchemaException.cs: Partiall implement the ISerializable
+ methods. It's not clear now SourceSchemaObject should be deserialized.
+
+2002-07-22 Tim Coleman <tim@timcoleman.com>
+ * XmlSchema.cs: Removed isCompiled which is defined as internal
+ in XmlSchemaObject.
+
+2002-06-18 Dwivedi, Ajay kumar <adwiv@yahoo.com>
+
+ * XmlSchema: Started work on Validate methods
+
+2002-06-18 Dwivedi, Ajay kumar <adwiv@yahoo.com>
+ * XmlSchema: The Read and Write methods are no more [MonoTODO] :)
+
+ * XmlSchemaAppInfo: Xml Markup is now being read.
+
+ * XmlSchemaDocumentation: Xml Markup is now being read.
+
+ * All: Unhandled attributes are being handled properly.
+
+ * All: Reordered the properties in all cs files to match with MS
+ Implementation. This was required since the order is importatnt
+ for the XmlSerializer.
+
+2002-06-14 Dwivedi, Ajay kumar <adwiv@yahoo.com>
+ * General: Fixed a few more Bugs
+
+2002-06-10 Dwivedi, Ajay kumar <adwiv@yahoo.com>
+ * XmlSchemaReader: A Wrapper class around XmlReader with customized
+ methods to suit reading a schema.
+ * General: Implemented Read() method for the schema. There are only
+ a few minor bugs remaining.
+
+2002-05-25 Dwivedi, Ajay kumar <adwiv@yahoo.com>
+ * BUGS.txt: New file to keep track of bugs
+
+ * ALL: All classes are initialized exactly as in .NET except
+ 1. inclusion of language attribute in schema
+ 2. ComplexContent's Particle is initialized to null whereas .NET
+ to some internal implementation. IMO Null is more appropriate
+
+ * ALL: Changed the Compile methods to return the count of errors.
+
+ * ALL: Complile methods are almost complete. Pass 1453 of 3061 tests.
+ This number should shoot up if we write a parser to read the
+ Schema instead of using reflection (which is slower too)
+
+2002-05-04 Dwivedi, Ajay kumar <adwiv@yahoo.com>
+ * XmlSchemaUtil.cs: New file added.
+
+ * Parser.cs: New file Added. Unused at the moment.
+
+ * XmlSchemaObjectCollection: Fixed GetEnumerator
+
+ * General: Preprocessing for Attributes and SimpleTypes completed.
+
+2002-04-26 Duncan Mak <duncan@ximian.com>
+
+ * ValidationHandler.cs: New file.
+
+ * XmlSchemaInfo.cs: New file.
+
+ * *.cs: More updates from Ajay.
+
+2002-03-27 Duncan Mak <duncan@ximian.com>
+
+ * *.cs: Updates from Ajay Dwivedi <AjayKumar.Dwivedi@dresdner-bank.com>.
diff --git a/mcs/class/System.XML/System.Xml.Schema/ValidationEventArgs.cs b/mcs/class/System.XML/System.Xml.Schema/ValidationEventArgs.cs
new file mode 100755
index 00000000000..df846514e1e
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/ValidationEventArgs.cs
@@ -0,0 +1,38 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for ValidationEventArgs.
+ /// </summary>
+ public sealed class ValidationEventArgs : EventArgs
+ {
+ private XmlSchemaException exception;
+ private string message;
+ private XmlSeverityType severity;
+
+ private ValidationEventArgs()
+ {}
+
+ internal ValidationEventArgs(XmlSchemaException ex, string message, XmlSeverityType severity)
+ {
+ this.exception = ex;
+ this.message = message;
+ this.severity = severity;
+ }
+ public XmlSchemaException Exception
+ {
+ get{ return exception; }
+ }
+ public string Message
+ {
+ get{ return message; }
+ }
+ public XmlSeverityType Severity
+ {
+ get{ return severity; }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/ValidationHandler.cs b/mcs/class/System.XML/System.Xml.Schema/ValidationHandler.cs
new file mode 100755
index 00000000000..898a10a840f
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/ValidationHandler.cs
@@ -0,0 +1,48 @@
+using System;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// </summary>
+ public delegate void ValidationEventHandler(object sender,ValidationEventArgs e);
+
+ /// <summary>
+ /// Docs say we need to raise an exception if ValidationEventHandler is not set(null)
+ /// So we use this class to raise the events rather than calling the delegate by itself
+ /// </summary>
+ internal class ValidationHandler
+ {
+ public static void RaiseValidationEvent(ValidationEventHandler handle, Exception innerException, object sender, string message, XmlSeverityType severity)
+ {
+ XmlSchemaException ex = new XmlSchemaException(message,innerException);
+ ValidationEventArgs e = new ValidationEventArgs(ex,message,severity);
+ if(handle == null)
+ {
+ throw e.Exception;
+ }
+ else
+ {
+ handle(sender,e);
+ }
+ }
+ public static void RaiseValidationError(ValidationEventHandler handle, object sender, string message)
+ {
+ RaiseValidationEvent(handle,null,sender,message,XmlSeverityType.Error);
+ }
+
+ public static void RaiseValidationError(ValidationEventHandler handle, string message, Exception innerException)
+ {
+ RaiseValidationEvent(handle, innerException, null, message, XmlSeverityType.Error);
+ }
+
+ public static void RaiseValidationWarning (ValidationEventHandler handle, object sender, string message)
+ {
+ RaiseValidationEvent(handle,null,sender,message,XmlSeverityType.Warning);
+ }
+
+ public static void RaiseValidationWarning(ValidationEventHandler handle, string message, Exception innerException)
+ {
+ RaiseValidationEvent(handle, innerException, null, message, XmlSeverityType.Warning);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs
new file mode 100755
index 00000000000..61f16ec71ca
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchema.cs
@@ -0,0 +1,711 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Collections;
+using System.Xml;
+using System.IO;
+using System.Xml.Serialization;
+using System.ComponentModel;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchema.
+ /// </summary>
+ [XmlRoot("schema",Namespace="http://www.w3.org/2001/XMLSchema")]
+ public class XmlSchema : XmlSchemaObject
+ {
+ //public constants
+ public const string Namespace = "http://www.w3.org/2001/XMLSchema";
+ public const string InstanceNamespace = "http://www.w3.org/2001/XMLSchema-instance";
+
+ //private fields
+ private XmlSchemaForm attributeFormDefault ;
+ private XmlSchemaObjectTable attributeGroups ;
+ private XmlSchemaObjectTable attributes ;
+ private XmlSchemaDerivationMethod blockDefault ;
+ private XmlSchemaForm elementFormDefault ;
+ private XmlSchemaObjectTable elements ;
+ private XmlSchemaDerivationMethod finalDefault ;
+ private XmlSchemaObjectTable groups ;
+ private string id ;
+ private XmlSchemaObjectCollection includes ;
+ private XmlSchemaObjectCollection items ;
+ private XmlSchemaObjectTable notations ;
+ private XmlSchemaObjectTable schemaTypes ;
+ private string targetNamespace ;
+ private XmlAttribute[] unhandledAttributes ;
+ private string version;
+ private string language;
+
+ // Compiler specific things
+ private XmlSchemaInfo info;
+ private static string xmlname = "schema";
+
+ public XmlSchema()
+ {
+ attributeFormDefault= XmlSchemaForm.None;
+ blockDefault = XmlSchemaDerivationMethod.None;
+ elementFormDefault = XmlSchemaForm.None;
+ finalDefault = XmlSchemaDerivationMethod.None;
+ includes = new XmlSchemaObjectCollection();
+ isCompiled = false;
+ items = new XmlSchemaObjectCollection();
+ attributeGroups = new XmlSchemaObjectTable();
+ attributes = new XmlSchemaObjectTable();
+ elements = new XmlSchemaObjectTable();
+ groups = new XmlSchemaObjectTable();
+ notations = new XmlSchemaObjectTable();
+ schemaTypes = new XmlSchemaObjectTable();
+ }
+
+ #region Properties
+
+ [DefaultValue(XmlSchemaForm.None)]
+ [System.Xml.Serialization.XmlAttribute("attributeFormDefault")]
+ public XmlSchemaForm AttributeFormDefault
+ {
+ get{ return attributeFormDefault; }
+ set{ this.attributeFormDefault = value;}
+ }
+
+ [DefaultValue(XmlSchemaDerivationMethod.None)]
+ [System.Xml.Serialization.XmlAttribute("blockDefault")]
+ public XmlSchemaDerivationMethod BlockDefault
+ {
+ get{ return blockDefault;}
+ set{ blockDefault = value;}
+ }
+
+ [DefaultValue(XmlSchemaDerivationMethod.None)]
+ [System.Xml.Serialization.XmlAttribute("finalDefault")]
+ public XmlSchemaDerivationMethod FinalDefault
+ {
+ get{ return finalDefault;}
+ set{ finalDefault = value;}
+ }
+
+ [DefaultValue(XmlSchemaForm.None)]
+ [System.Xml.Serialization.XmlAttribute("elementFormDefault")]
+ public XmlSchemaForm ElementFormDefault
+ {
+ get{ return elementFormDefault;}
+ set{ elementFormDefault = value;}
+ }
+
+ [System.Xml.Serialization.XmlAttribute("targetNamespace")]
+ public string TargetNamespace
+ {
+ get{ return targetNamespace;}
+ set{ targetNamespace = value;}
+ }
+
+ [System.Xml.Serialization.XmlAttribute("version")]
+ public string Version
+ {
+ get{ return version;}
+ set{ version = value;}
+ }
+
+ [XmlElement("include",typeof(XmlSchemaInclude),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("import",typeof(XmlSchemaImport),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("redefine",typeof(XmlSchemaRedefine),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection Includes
+ {
+ get{ return includes;}
+ }
+
+ [XmlElement("simpleType",typeof(XmlSchemaSimpleType),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("complexType",typeof(XmlSchemaComplexType),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("group",typeof(XmlSchemaGroup),Namespace="http://www.w3.org/2001/XMLSchema")]
+ //Only Schema's attributeGroup has type XmlSchemaAttributeGroup.
+ //Others (complextype, restrictions etc) must have XmlSchemaAttributeGroupRef
+ [XmlElement("attributeGroup",typeof(XmlSchemaAttributeGroup),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("element",typeof(XmlSchemaElement),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("attribute",typeof(XmlSchemaAttribute),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("notation",typeof(XmlSchemaNotation),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("annotation",typeof(XmlSchemaAnnotation),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection Items
+ {
+ get{ return items;}
+ }
+
+ [XmlIgnore]
+ public bool IsCompiled
+ {
+ get{ return isCompiled;}
+ }
+
+ [XmlIgnore]
+ public XmlSchemaObjectTable Attributes
+ {
+ get{ return attributes;}
+ }
+
+ [XmlIgnore]
+ public XmlSchemaObjectTable AttributeGroups
+ {
+ get{ return attributeGroups; }
+ }
+
+ [XmlIgnore]
+ public XmlSchemaObjectTable SchemaTypes
+ {
+ get{ return schemaTypes; }
+ }
+
+ [XmlIgnore]
+ public XmlSchemaObjectTable Elements
+ {
+ get{ return elements;}
+ }
+
+ [System.Xml.Serialization.XmlAttribute("id")]
+ public string Id
+ {
+ get{ return id;}
+ set{ id = value;}
+ }
+
+ [XmlAnyAttribute]
+ public XmlAttribute[] UnhandledAttributes
+ {
+ get
+ {
+ if(unhandledAttributeList != null)
+ {
+ unhandledAttributes = (XmlAttribute[]) unhandledAttributeList.ToArray(typeof(XmlAttribute));
+ unhandledAttributeList = null;
+ }
+ return unhandledAttributes;
+ }
+ set
+ {
+ unhandledAttributes = value;
+ unhandledAttributeList = null;
+ }
+ }
+
+ [XmlIgnore]
+ public XmlSchemaObjectTable Groups
+ {
+ get{ return groups;}
+ }
+
+ [XmlIgnore]
+ public XmlSchemaObjectTable Notations
+ {
+ get{ return notations;}
+ }
+
+ // New attribute defined in W3C schema element
+ [System.Xml.Serialization.XmlAttribute("xml:lang")]
+ public string Language
+ {
+ get{ return language; }
+ set{ language = value; }
+ }
+
+ #endregion
+
+ #region Compile
+
+ // Methods
+ /// <summary>
+ /// This compile method does two things:
+ /// 1. It compiles and fills the PSVI dataset
+ /// 2. Validates the schema by calling Validate method.
+ /// Every XmlSchemaObject has a Compile Method which gets called.
+ /// </summary>
+ /// <remarks>
+ /// 1. blockDefault must be one of #all | List of (extension | restriction | substitution)
+ /// 2. finalDefault must be one of (#all | List of (extension | restriction| union| list))
+ /// 3. id must be of type ID
+ /// 4. targetNamespace should be any uri
+ /// 5. version should be a normalizedString
+ /// 6. xml:lang should be a language
+ /// </remarks>
+ [MonoTODO]
+ public void Compile(ValidationEventHandler handler)
+ {
+ // Create the xmlschemainfo object which we use to pass variables like targetnamespace;
+ info = new XmlSchemaInfo();
+
+ //1. Union and List are not allowed in block default
+ if(BlockDefault != XmlSchemaDerivationMethod.All)
+ {
+ if((BlockDefault & XmlSchemaDerivationMethod.List)!=0 )
+ error(handler, "list is not allowed in blockDefault attribute");
+ if((BlockDefault & XmlSchemaDerivationMethod.Union)!=0 )
+ error(handler, "union is not allowed in blockDefault attribute");
+ }
+
+ //2. Substitution is not allowed in finaldefault.
+ if(FinalDefault != XmlSchemaDerivationMethod.All)
+ {
+ if((FinalDefault & XmlSchemaDerivationMethod.Substitution)!=0 )
+ error(handler, "substitution is not allowed in finalDefault attribute");
+ }
+
+ //3. id must be of type ID
+ XmlSchemaUtil.CompileID(Id, this, info.IDCollection, handler);
+
+ //4. targetNamespace should be of type anyURI or absent
+ if(TargetNamespace != null)
+ {
+ if(!XmlSchemaUtil.CheckAnyUri(TargetNamespace))
+ error(handler, TargetNamespace+" is not a valid value for targetNamespace attribute of schema");
+ else
+ info.TargetNamespace = TargetNamespace;
+ }
+
+ //5. version should be of type normalizedString
+ if(!XmlSchemaUtil.CheckNormalizedString(Version))
+ error(handler, Version + "is not a valid value for version attribute of schema");
+
+ //6. xml:lang must be a language
+ if(!XmlSchemaUtil.CheckLanguage(Language))
+ error(handler, Language + " is not a valid language");
+
+ // elementFormDefault defaults to UnQualified
+ if(ElementFormDefault != XmlSchemaForm.Qualified)
+ info.ElementFormDefault = XmlSchemaForm.Unqualified;
+ else
+ info.ElementFormDefault = XmlSchemaForm.Qualified;
+
+ // attributeFormDefault defaults to UnQualified
+ if(AttributeFormDefault != XmlSchemaForm.Qualified)
+ info.AttributeFormDefault = XmlSchemaForm.Unqualified;
+ else
+ info.AttributeFormDefault = XmlSchemaForm.Qualified;
+
+ if(FinalDefault == XmlSchemaDerivationMethod.All)
+ info.FinalDefault = XmlSchemaDerivationMethod.All;
+ else // If finalDefault is None, info's finalDefault is set to empty
+ info.FinalDefault = (FinalDefault & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction));
+
+ if(BlockDefault == XmlSchemaDerivationMethod.All)
+ info.BlockDefault = XmlSchemaDerivationMethod.All;
+ else // If finalDefault is None, info's blockDefault is set to empty
+ info.BlockDefault = (blockDefault & (XmlSchemaDerivationMethod.Extension |
+ XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Substitution));
+
+ // Compile the content of this schema
+ foreach(XmlSchemaObject obj in Includes)
+ {
+ if(obj is XmlSchemaExternal)
+ {
+ //FIXME: Kuch to karo! (Do Something ;)
+ }
+ else
+ {
+ error(handler,"Object of Type "+obj.GetType().Name+" is not valid in Includes Property of XmlSchema");
+ }
+ }
+ foreach(XmlSchemaObject obj in Items)
+ {
+ if(obj is XmlSchemaAnnotation)
+ {
+ int numerr = ((XmlSchemaAnnotation)obj).Compile(handler,info);
+ errorCount += numerr;
+ if( numerr == 0)
+ {
+ //FIXME: What PSVI set do we add this to?
+ }
+ }
+ else if(obj is XmlSchemaAttribute)
+ {
+ XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;
+ attr.parentIsSchema = true;
+ int numerr = attr.Compile(handler,info);
+ errorCount += numerr;
+ if(numerr == 0)
+ {
+ Attributes.Add(attr.QualifiedName, attr);
+ }
+ }
+ else if(obj is XmlSchemaAttributeGroup)
+ {
+ XmlSchemaAttributeGroup attrgrp = (XmlSchemaAttributeGroup) obj;
+ int numerr = attrgrp.Compile(handler,info);
+ errorCount += numerr;
+ if(numerr == 0)
+ {
+ AttributeGroups.Add(attrgrp.QualifiedName, attrgrp);
+ }
+ }
+ else if(obj is XmlSchemaComplexType)
+ {
+ XmlSchemaComplexType ctype = (XmlSchemaComplexType) obj;
+ ctype.istoplevel = true;
+ int numerr = ctype.Compile(handler,info);
+ errorCount += numerr;
+ if(numerr == 0)
+ {
+ schemaTypes.Add(ctype.QualifiedName, ctype);
+ }
+ }
+ else if(obj is XmlSchemaSimpleType)
+ {
+ XmlSchemaSimpleType stype = (XmlSchemaSimpleType) obj;
+ stype.islocal = false; //This simple type is toplevel
+ int numerr = stype.Compile(handler,info);
+ errorCount += numerr;
+ if(numerr == 0)
+ {
+ SchemaTypes.Add(stype.QualifiedName, stype);
+ }
+ }
+ else if(obj is XmlSchemaElement)
+ {
+ XmlSchemaElement elem = (XmlSchemaElement) obj;
+ elem.parentIsSchema = true;
+ int numerr = elem.Compile(handler,info);
+ errorCount += numerr;
+ if(numerr == 0)
+ {
+ Elements.Add(elem.QualifiedName,elem);
+ }
+ }
+ else if(obj is XmlSchemaGroup)
+ {
+ XmlSchemaGroup grp = (XmlSchemaGroup) obj;
+ int numerr = grp.Compile(handler,info);
+ errorCount += numerr;
+ if(numerr == 0)
+ {
+ Groups.Add(grp.QualifiedName,grp);
+ }
+ }
+ else if(obj is XmlSchemaNotation)
+ {
+ XmlSchemaNotation ntn = (XmlSchemaNotation) obj;
+ int numerr = ntn.Compile(handler,info);
+ errorCount += numerr;
+ if(numerr == 0)
+ {
+ Notations.Add(ntn.QualifiedName, ntn);
+ }
+ }
+ else
+ {
+ ValidationHandler.RaiseValidationError(handler,this,
+ "Object of Type "+obj.GetType().Name+" is not valid in Item Property of Schema");
+ }
+ }
+ Validate(handler);
+ }
+
+ #endregion
+
+ [MonoTODO]
+ private void Validate(ValidationEventHandler handler)
+ {
+ info.SchemaTypes = SchemaTypes;
+
+ foreach(XmlSchemaAttribute attr in Attributes.Values)
+ {
+ attr.Validate(handler, info);
+ }
+ foreach(XmlSchemaAttributeGroup attrgrp in AttributeGroups.Values)
+ {
+ attrgrp.Validate(handler);
+ }
+ foreach(XmlSchemaType type in SchemaTypes.Values)
+ {
+ if(type is XmlSchemaComplexType)
+ {
+ ((XmlSchemaComplexType)type).Validate(handler);
+ }
+ else
+ ((XmlSchemaSimpleType)type).Validate(handler, info);
+ }
+ foreach(XmlSchemaElement elem in Elements.Values)
+ {
+ elem.Validate(handler);
+ }
+ foreach(XmlSchemaGroup grp in Groups.Values)
+ {
+ grp.Validate(handler);
+ }
+ foreach(XmlSchemaNotation ntn in Notations.Values)
+ {
+ ntn.Validate(handler);
+ }
+ }
+
+
+ #region Read
+
+ public static XmlSchema Read(TextReader reader, ValidationEventHandler validationEventHandler)
+ {
+ return Read(new XmlTextReader(reader),validationEventHandler);
+ }
+ public static XmlSchema Read(Stream stream, ValidationEventHandler validationEventHandler)
+ {
+ return Read(new XmlTextReader(stream),validationEventHandler);
+ }
+
+ public static XmlSchema Read(XmlReader rdr, ValidationEventHandler validationEventHandler)
+ {
+ //XmlSerializer xser = new XmlSerializer(typeof(XmlSchema));
+ //return (XmlSchema) xser.Deserialize(reader);
+ XmlSchemaReader reader = new XmlSchemaReader(rdr, validationEventHandler);
+
+ while(reader.ReadNextElement())
+ {
+ switch(reader.NodeType)
+ {
+ case XmlNodeType.Element:
+ if(reader.LocalName == "schema")
+ {
+ XmlSchema schema = new XmlSchema();
+
+ schema.LineNumber = reader.LineNumber;
+ schema.LinePosition = reader.LinePosition;
+ schema.SourceUri = reader.BaseURI;
+
+ ReadAttributes(schema, reader, validationEventHandler);
+ //IsEmptyElement does not behave properly if reader is
+ //positioned at an attribute.
+ reader.MoveToElement();
+ if(!reader.IsEmptyElement)
+ {
+ ReadContent(schema, reader, validationEventHandler);
+ }
+ return schema;
+ }
+ else
+ {
+ //Schema can't be generated. Throw an exception
+ throw new XmlSchemaException("The root element must be schema", null);
+ }
+ default:
+ error(validationEventHandler, "This should never happen. XmlSchema.Read 1 ",null);
+ break;
+ }
+ }
+ throw new XmlSchemaException("The top level schema must have namespace "+XmlSchema.Namespace, null);
+ }
+
+ private static void ReadAttributes(XmlSchema schema, XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ Exception ex;
+
+ reader.MoveToElement();
+ while(reader.MoveToNextAttribute())
+ {
+ switch(reader.Name)
+ {
+ case "attributeFormDefault" :
+ schema.attributeFormDefault = XmlSchemaUtil.ReadFormAttribute(reader,out ex);
+ if(ex != null)
+ error(h, reader.Value + " is not a valid value for attributeFormDefault.", ex);
+ break;
+ case "blockDefault" :
+ schema.blockDefault = XmlSchemaUtil.ReadDerivationAttribute(reader,out ex, "blockDefault");
+ if(ex != null)
+ warn(h, ex.Message, ex);
+ break;
+ case "elementFormDefault":
+ schema.elementFormDefault = XmlSchemaUtil.ReadFormAttribute(reader, out ex);
+ if(ex != null)
+ error(h, reader.Value + " is not a valid value for elementFormDefault.", ex);
+ break;
+ case "finalDefault":
+ schema.finalDefault = XmlSchemaUtil.ReadDerivationAttribute(reader, out ex, "finalDefault");
+ if(ex != null)
+ warn(h, ex.Message , ex);
+ break;
+ case "id":
+ schema.id = reader.Value;
+ break;
+ case "targetNamespace":
+ schema.targetNamespace = reader.Value;
+ break;
+ case "version":
+ schema.version = reader.Value;
+ break;
+ case "xml:lang":
+ schema.language = reader.Value;
+ break;
+ default:
+ if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ error(h, reader.Name + " attribute is not allowed in schema element",null);
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,schema);
+ }
+ break;
+ }
+ }
+ }
+
+ private static void ReadContent(XmlSchema schema, XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ reader.MoveToElement();
+ if(reader.LocalName != "schema" && reader.NamespaceURI != XmlSchema.Namespace && reader.NodeType != XmlNodeType.Element)
+ error(h, "UNREACHABLE CODE REACHED: Method: Schema.ReadContent, " + reader.LocalName + ", " + reader.NamespaceURI,null);
+
+ //(include | import | redefine | annotation)*,
+ //((simpleType | complexType | group | attributeGroup | element | attribute | notation | annotation)*
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchema.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1)
+ {
+ if(reader.LocalName == "include")
+ {
+ XmlSchemaInclude include = XmlSchemaInclude.Read(reader,h);
+ if(include != null)
+ schema.includes.Add(include);
+ continue;
+ }
+ if(reader.LocalName == "import")
+ {
+ XmlSchemaImport import = XmlSchemaImport.Read(reader,h);
+ if(import != null)
+ schema.includes.Add(import);
+ continue;
+ }
+ if(reader.LocalName == "redefine")
+ {
+ XmlSchemaRedefine redefine = XmlSchemaRedefine.Read(reader,h);
+ if(redefine != null)
+ schema.includes.Add(redefine);
+ continue;
+ }
+ if(reader.LocalName == "annotation")
+ {
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ schema.items.Add(annotation);
+ continue;
+ }
+ }
+ if(level <=2)
+ {
+ level = 2;
+ if(reader.LocalName == "simpleType")
+ {
+ XmlSchemaSimpleType stype = XmlSchemaSimpleType.Read(reader,h);
+ if(stype != null)
+ schema.items.Add(stype);
+ continue;
+ }
+ if(reader.LocalName == "complexType")
+ {
+ XmlSchemaComplexType ctype = XmlSchemaComplexType.Read(reader,h);
+ if(ctype != null)
+ schema.items.Add(ctype);
+ continue;
+ }
+ if(reader.LocalName == "group")
+ {
+ XmlSchemaGroup group = XmlSchemaGroup.Read(reader,h);
+ if(group != null)
+ schema.items.Add(group);
+ continue;
+ }
+ if(reader.LocalName == "attributeGroup")
+ {
+ XmlSchemaAttributeGroup attributeGroup = XmlSchemaAttributeGroup.Read(reader,h);
+ if(attributeGroup != null)
+ schema.items.Add(attributeGroup);
+ continue;
+ }
+ if(reader.LocalName == "element")
+ {
+ XmlSchemaElement element = XmlSchemaElement.Read(reader,h);
+ if(element != null)
+ schema.items.Add(element);
+ continue;
+ }
+ if(reader.LocalName == "attribute")
+ {
+ XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader,h);
+ if(attr != null)
+ schema.items.Add(attr);
+ continue;
+ }
+ if(reader.LocalName == "notation")
+ {
+ XmlSchemaNotation notation = XmlSchemaNotation.Read(reader,h);
+ if(notation != null)
+ schema.items.Add(notation);
+ continue;
+ }
+ if(reader.LocalName == "annotation")
+ {
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ schema.items.Add(annotation);
+ continue;
+ }
+ }
+ reader.RaiseInvalidElementError();
+ }
+ }
+ #endregion
+
+ #region write
+
+ public void Write(System.IO.Stream stream)
+ {
+ Write(stream,null);
+ }
+ public void Write(System.IO.TextWriter writer)
+ {
+ Write(writer,null);
+ }
+ public void Write(System.Xml.XmlWriter writer)
+ {
+ Write(writer,null);
+ }
+ public void Write(System.IO.Stream stream, System.Xml.XmlNamespaceManager namespaceManager)
+ {
+ Write(new XmlTextWriter(stream,null),namespaceManager);
+ }
+ public void Write(System.IO.TextWriter writer, System.Xml.XmlNamespaceManager namespaceManager)
+ {
+ XmlTextWriter xwriter = new XmlTextWriter(writer);
+ xwriter.Formatting = Formatting.Indented;
+ Write(xwriter,namespaceManager);
+ }
+ public void Write(System.Xml.XmlWriter writer, System.Xml.XmlNamespaceManager namespaceManager)
+ {
+ if(Namespaces == null)
+ {
+ Namespaces = new XmlSerializerNamespaces();
+ }
+ //Add the xml schema namespace.
+ if(Namespaces.Count == 0)
+ {
+ Namespaces.Add("xs", XmlSchema.Namespace);
+ if (TargetNamespace != null && TargetNamespace != String.Empty)
+ Namespaces.Add("tns", TargetNamespace);
+ }
+ if(namespaceManager != null)
+ {
+ foreach(string name in namespaceManager)
+ {
+ //xml and xmlns namespaced are added by default in namespaceManager.
+ //So we should ignore them
+ if(name!="xml" && name != "xmlns")
+ Namespaces.Add(name,namespaceManager.LookupNamespace(name));
+ }
+ }
+
+ XmlSerializer xser = new XmlSerializer(typeof(XmlSchema));
+ xser.Serialize(writer,this,Namespaces);
+ writer.Flush();
+ }
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAll.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAll.cs
new file mode 100755
index 00000000000..21e52e7e5b6
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAll.cs
@@ -0,0 +1,165 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaAll.
+ /// </summary>
+ public class XmlSchemaAll : XmlSchemaGroupBase
+ {
+ private XmlSchemaObjectCollection items;
+ private static string xmlname = "all";
+
+ public XmlSchemaAll()
+ {
+ items = new XmlSchemaObjectCollection();
+ }
+
+ [XmlElement("element",typeof(XmlSchemaElement),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public override XmlSchemaObjectCollection Items
+ {
+ get{ return items; }
+ }
+
+ /// <remarks>
+ /// 1. MaxOccurs must be one. (default is also one)
+ /// 2. MinOccurs must be zero or one.
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ //FIXME: Should we reset the values on error??
+ if(MaxOccurs != Decimal.One)
+ error(h,"maxOccurs must be 1");
+ if(MinOccurs != Decimal.One && MinOccurs != Decimal.Zero)
+ error(h,"minOccurs must be 0 or 1");
+
+ XmlSchemaUtil.CompileID(Id, this, info.IDCollection, h);
+
+ foreach(XmlSchemaObject obj in Items)
+ {
+ if(obj is XmlSchemaElement)
+ {
+ XmlSchemaElement elem = (XmlSchemaElement)obj;
+ if(elem.MaxOccurs != Decimal.One && elem.MaxOccurs != Decimal.Zero)
+ {
+ elem.error(h,"The {max occurs} of all the elements of 'all' must be 0 or 1. ");
+ }
+ errorCount += elem.Compile(h,info);
+ }
+ else
+ {
+ error(h,"XmlSchemaAll can only contain Items of type Element");
+ }
+ }
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+ //<all
+ // id = ID
+ // maxOccurs = 1 : 1
+ // minOccurs = (0 | 1) : 1
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, element*)
+ //</all>
+ internal static XmlSchemaAll Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaAll all = new XmlSchemaAll();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaAll.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ all.LineNumber = reader.LineNumber;
+ all.LinePosition = reader.LinePosition;
+ all.SourceUri = reader.BaseURI;
+
+ //Read Attributes
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ all.Id = reader.Value;
+ }
+ else if(reader.Name == "maxOccurs")
+ {
+ try
+ {
+ all.MaxOccursString = reader.Value;
+ }
+ catch(Exception e)
+ {
+ error(h,reader.Value + " is an invalid value for maxOccurs",e);
+ }
+ }
+ else if(reader.Name == "minOccurs")
+ {
+ try
+ {
+ all.MinOccursString = reader.Value;
+ }
+ catch(Exception e)
+ {
+ error(h,reader.Value + " is an invalid value for minOccurs",e);
+ }
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for all",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,all);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return all;
+
+ //Content: (annotation?, element*)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaAll.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ all.Annotation = annotation;
+ continue;
+ }
+ if(level <=2 && reader.LocalName == "element")
+ {
+ level = 2;
+ XmlSchemaElement element = XmlSchemaElement.Read(reader,h);
+ if(element != null)
+ all.items.Add(element);
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return all;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAnnotated.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAnnotated.cs
new file mode 100755
index 00000000000..6631dfed480
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAnnotated.cs
@@ -0,0 +1,56 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Collections;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaAnnotated.
+ /// </summary>
+
+ public class XmlSchemaAnnotated : XmlSchemaObject
+ {
+ private XmlSchemaAnnotation annotation;
+ private string id;
+ private XmlAttribute[] unhandledAttributes;
+
+ public XmlSchemaAnnotated()
+ {}
+
+ [System.Xml.Serialization.XmlAttribute("id")]
+ public string Id
+ {
+ get{ return id; }
+ set{ id = value; }
+ }
+
+ [XmlElement("annotation",Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaAnnotation Annotation
+ {
+ get{ return annotation; }
+ set{ annotation = value; }
+ }
+
+ [XmlAnyAttribute]
+ public XmlAttribute[] UnhandledAttributes
+ {
+ get
+ {
+ if(unhandledAttributeList != null)
+ {
+ unhandledAttributes = (XmlAttribute[]) unhandledAttributeList.ToArray(typeof(XmlAttribute));
+ unhandledAttributeList = null;
+ }
+ return unhandledAttributes;
+ }
+ set
+ {
+ unhandledAttributes = value;
+ unhandledAttributeList = null;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAnnotation.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAnnotation.cs
new file mode 100755
index 00000000000..12fe3d26875
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAnnotation.cs
@@ -0,0 +1,145 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Collections;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaAnnotation.
+ /// </summary>
+ public class XmlSchemaAnnotation : XmlSchemaObject
+ {
+ private string id;
+ private XmlSchemaObjectCollection items;
+ private XmlAttribute[] unhandledAttributes;
+ private static string xmlname = "annotation";
+ public XmlSchemaAnnotation()
+ {
+ items = new XmlSchemaObjectCollection();
+ }
+
+ [System.Xml.Serialization.XmlAttribute("id")]
+ public string Id
+ {
+ get{ return id; }
+ set{ id = value; }
+ }
+
+ [XmlElement("appinfo",typeof(XmlSchemaAppInfo),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("documentation",typeof(XmlSchemaDocumentation),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection Items
+ {
+ get{ return items; }
+ }
+
+ [XmlAnyAttribute]
+ public XmlAttribute[] UnhandledAttributes
+ {
+ get
+ {
+ if(unhandledAttributeList != null)
+ {
+ unhandledAttributes = (XmlAttribute[]) unhandledAttributeList.ToArray(typeof(XmlAttribute));
+ unhandledAttributeList = null;
+ }
+ return unhandledAttributes;
+ }
+ set
+ {
+ unhandledAttributes = value;
+ unhandledAttributeList = null;
+ }
+ }
+
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ return 0;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return 0;
+ }
+
+ //<annotation
+ // id = ID
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (appinfo | documentation)*
+ //</annotation>
+ internal static XmlSchemaAnnotation Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaAnnotation annotation = new XmlSchemaAnnotation();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaAnnotation.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ annotation.LineNumber = reader.LineNumber;
+ annotation.LinePosition = reader.LinePosition;
+ annotation.SourceUri = reader.BaseURI;
+
+ //Read Attributes
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ annotation.Id = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for annotation",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,annotation);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return annotation;
+
+ //Content: (appinfo | documentation)*
+ bool skip = false;
+ while(!reader.EOF)
+ {
+ if(skip)
+ skip=false;
+ else
+ reader.ReadNextElement();
+
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaAnnotation.Read, name="+reader.Name,null);
+ break;
+ }
+ if(reader.LocalName == "appinfo")
+ {
+ XmlSchemaAppInfo appinfo = XmlSchemaAppInfo.Read(reader,h,out skip);
+ if(appinfo != null)
+ annotation.items.Add(appinfo);
+ continue;
+ }
+ if(reader.LocalName == "documentation")
+ {
+ XmlSchemaDocumentation documentation = XmlSchemaDocumentation.Read(reader,h, out skip);
+ if(documentation != null)
+ annotation.items.Add(documentation);
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return annotation;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAny.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAny.cs
new file mode 100755
index 00000000000..6f652481669
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAny.cs
@@ -0,0 +1,192 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+using System.ComponentModel;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaAny.
+ /// </summary>
+ public class XmlSchemaAny : XmlSchemaParticle
+ {
+ private string nameSpace;
+ private XmlSchemaContentProcessing processing;
+ private static string xmlname = "any";
+
+ public XmlSchemaAny()
+ {
+ }
+
+ [System.Xml.Serialization.XmlAttribute("namespace")]
+ public string Namespace
+ {
+ get{ return nameSpace; }
+ set{ nameSpace = value; }
+ }
+
+ [DefaultValue(XmlSchemaContentProcessing.None)]
+ [System.Xml.Serialization.XmlAttribute("processContents")]
+ public XmlSchemaContentProcessing ProcessContents
+ {
+ get{ return processing; }
+ set{ processing = value; }
+ }
+
+ /// <remarks>
+ /// 1. id must be of type ID
+ /// 2. namespace can have one of the following values:
+ /// a) ##any or ##other
+ /// b) list of anyURI and ##targetNamespace and ##local
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ errorCount = 0;
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ //define ##any=1,##other=2,##targetNamespace=4,##local=8,anyURI=16
+ int nscount = 0;
+ string[] nslist = XmlSchemaUtil.SplitList(Namespace);
+ foreach(string ns in nslist)
+ {
+ switch(ns)
+ {
+ case "##any":
+ nscount |= 1;
+ break;
+ case "##other":
+ nscount |= 2;
+ break;
+ case "##targetNamespace":
+ nscount |= 4;
+ break;
+ case "##local":
+ nscount |= 8;
+ break;
+ default:
+ if(!XmlSchemaUtil.CheckAnyUri(ns))
+ error(h,"the namespace is not a valid anyURI");
+ else
+ nscount |= 16;
+ break;
+ }
+ }
+ if((nscount&1) == 1 && nscount != 1)
+ error(h,"##any if present must be the only namespace attribute");
+ if((nscount&2) == 2 && nscount != 2)
+ error(h,"##other if present must be the only namespace attribute");
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+ //<any
+ // id = ID
+ // maxOccurs = (nonNegativeInteger | unbounded) : 1
+ // minOccurs = nonNegativeInteger : 1
+ // namespace = ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) ) : ##any
+ // processContents = (lax | skip | strict) : strict
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</any>
+ internal static XmlSchemaAny Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaAny any = new XmlSchemaAny();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaAny.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ any.LineNumber = reader.LineNumber;
+ any.LinePosition = reader.LinePosition;
+ any.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ any.Id = reader.Value;
+ }
+ else if(reader.Name == "maxOccurs")
+ {
+ try
+ {
+ any.MaxOccursString = reader.Value;
+ }
+ catch(Exception e)
+ {
+ error(h,reader.Value + " is an invalid value for maxOccurs",e);
+ }
+ }
+ else if(reader.Name == "minOccurs")
+ {
+ try
+ {
+ any.MinOccursString = reader.Value;
+ }
+ catch(Exception e)
+ {
+ error(h,reader.Value + " is an invalid value for minOccurs", e);
+ }
+ }
+ else if(reader.Name == "namespace")
+ {
+ any.nameSpace = reader.Value;
+ }
+ else if(reader.Name == "processContents")
+ {
+ Exception innerex;
+ any.processing = XmlSchemaUtil.ReadProcessingAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for processContents",innerex);
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for any",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,any);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return any;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaAny.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ any.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return any;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAnyAttribute.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAnyAttribute.cs
new file mode 100755
index 00000000000..fb1a515e5ca
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAnyAttribute.cs
@@ -0,0 +1,169 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.ComponentModel;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaAnyAttribute.
+ /// </summary>
+ public class XmlSchemaAnyAttribute : XmlSchemaAnnotated
+ {
+ private string nameSpace;
+ private XmlSchemaContentProcessing processing;
+ private static string xmlname = "anyAttribute";
+
+ public XmlSchemaAnyAttribute()
+ {
+ }
+
+ [System.Xml.Serialization.XmlAttribute("namespace")]
+ public string Namespace
+ {
+ get{ return nameSpace; }
+ set{ nameSpace = value; }
+ }
+
+ [DefaultValue(XmlSchemaContentProcessing.None)]
+ [System.Xml.Serialization.XmlAttribute("processContents")]
+ public XmlSchemaContentProcessing ProcessContents
+ {
+ get{ return processing; }
+ set{ processing = value; }
+ }
+
+ /// <remarks>
+ /// 1. id must be of type ID
+ /// 2. namespace can have one of the following values:
+ /// a) ##any or ##other
+ /// b) list of anyURI and ##targetNamespace and ##local
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ errorCount = 0;
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ //define ##any=1,##other=2,##targetNamespace=4,##local=8,anyURI=16
+ int nscount = 0;
+ string[] nslist = XmlSchemaUtil.SplitList(Namespace);
+ foreach(string ns in nslist)
+ {
+ switch(ns)
+ {
+ case "##any":
+ nscount |= 1;
+ break;
+ case "##other":
+ nscount |= 2;
+ break;
+ case "##targetNamespace":
+ nscount |= 4;
+ break;
+ case "##local":
+ nscount |= 8;
+ break;
+ default:
+ if(!XmlSchemaUtil.CheckAnyUri(ns))
+ error(h,"the namespace is not a valid anyURI");
+ else
+ nscount |= 16;
+ break;
+ }
+ }
+ if((nscount&1) == 1 && nscount != 1)
+ error(h,"##any if present must be the only namespace attribute");
+ if((nscount&2) == 2 && nscount != 2)
+ error(h,"##other if present must be the only namespace attribute");
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+
+ //<anyAttribute
+ // id = ID
+ // namespace = ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) ) : ##any
+ // processContents = (lax | skip | strict) : strict
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</anyAttribute>
+ internal static XmlSchemaAnyAttribute Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaAnyAttribute any = new XmlSchemaAnyAttribute();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaAnyAttribute.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ any.LineNumber = reader.LineNumber;
+ any.LinePosition = reader.LinePosition;
+ any.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ any.Id = reader.Value;
+ }
+ else if(reader.Name == "namespace")
+ {
+ any.nameSpace = reader.Value;
+ }
+ else if(reader.Name == "processContents")
+ {
+ Exception innerex;
+ any.processing = XmlSchemaUtil.ReadProcessingAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for processContents",innerex);
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for anyAttribute",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,any);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return any;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaAnyAttribute.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ any.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return any;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAppInfo.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAppInfo.cs
new file mode 100755
index 00000000000..da66837c504
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAppInfo.cs
@@ -0,0 +1,91 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaAppInfo.
+ /// </summary>
+ public class XmlSchemaAppInfo : XmlSchemaObject
+ {
+ private XmlNode[] markup;
+ private string source;
+
+ public XmlSchemaAppInfo()
+ {
+ }
+
+ [System.Xml.Serialization.XmlAttribute("source")]
+ public string Source
+ {
+ get{ return source; }
+ set{ source = value; }
+ }
+
+ [XmlAnyElement]
+ [XmlText]
+ public XmlNode[] Markup
+ {
+ get{ return markup; }
+ set{ markup = value; }
+ }
+
+ //<appinfo
+ // source = anyURI>
+ // Content: ({any})*
+ //</appinfo>
+ internal static XmlSchemaAppInfo Read(XmlSchemaReader reader, ValidationEventHandler h, out bool skip)
+ {
+ skip = false;
+ XmlSchemaAppInfo appinfo = new XmlSchemaAppInfo();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != "appinfo")
+ {
+ error(h,"Should not happen :1: XmlSchemaAppInfo.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ appinfo.LineNumber = reader.LineNumber;
+ appinfo.LinePosition = reader.LinePosition;
+ appinfo.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "source")
+ {
+ appinfo.source = reader.Value;
+ }
+ else
+ {
+ error(h,reader.Name + " is not a valid attribute for appinfo",null);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return appinfo;
+
+ //Content {any}*
+ //FIXME: This is a pure Quick Hack; There must be a another method;
+ XmlDocument xmldoc = new XmlDocument();
+ xmldoc.AppendChild(xmldoc.ReadNode(reader));
+ XmlNode root = xmldoc.FirstChild;
+ if(root != null && root.ChildNodes != null)
+ {
+ appinfo.Markup = new XmlNode[root.ChildNodes.Count];
+ for(int i=0;i<root.ChildNodes.Count;i++)
+ {
+ appinfo.Markup[i] = root.ChildNodes[i];
+ }
+ }
+ if(reader.NodeType == XmlNodeType.Element || reader.NodeType == XmlNodeType.EndElement)
+ skip = true;
+ return appinfo;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttribute.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttribute.cs
new file mode 100755
index 00000000000..a7e82b6db3f
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttribute.cs
@@ -0,0 +1,435 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.ComponentModel;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaAttribute.
+ /// </summary>
+ public class XmlSchemaAttribute : XmlSchemaAnnotated
+ {
+ private object attributeType;
+ private string defaultValue;
+ private string fixedValue;
+ private XmlSchemaForm form;
+ private string name;
+ private XmlQualifiedName qualifiedName;
+ private XmlQualifiedName refName;
+ private XmlSchemaSimpleType schemaType;
+ private XmlQualifiedName schemaTypeName;
+ private XmlSchemaUse use;
+ //Compilation fields
+ internal bool parentIsSchema = false;
+ private static string xmlname = "attribute";
+
+ public XmlSchemaAttribute()
+ {
+ //FIXME: Docs says the default is optional.
+ //Whereas the MS implementation has default None.
+ form = XmlSchemaForm.None;
+ use = XmlSchemaUse.None;
+ schemaTypeName = XmlQualifiedName.Empty;
+ qualifiedName = XmlQualifiedName.Empty;
+ refName = XmlQualifiedName.Empty;
+ }
+
+ // Properties
+ #region Properties
+
+ [DefaultValue(null)]
+ [System.Xml.Serialization.XmlAttribute("default")]
+ public string DefaultValue
+ {
+ get{ return defaultValue;}
+ set
+ { // Default Value and fixed Value are mutually exclusive
+ fixedValue = null;
+ defaultValue = value;
+ }
+ }
+
+ [DefaultValue(null)]
+ [System.Xml.Serialization.XmlAttribute("fixed")]
+ public string FixedValue
+ {
+ get{ return fixedValue;}
+ set
+ { // Default Value and fixed Value are mutually exclusive
+ defaultValue = null;
+ fixedValue = value;
+ }
+ }
+
+ [DefaultValue(XmlSchemaForm.None)]
+ [System.Xml.Serialization.XmlAttribute("form")]
+ public XmlSchemaForm Form
+ {
+ get{ return form;}
+ set{ form = value;}
+ }
+
+ [System.Xml.Serialization.XmlAttribute("name")]
+ public string Name
+ {
+ get{ return name;}
+ set
+ {
+ name = value;
+ }
+ }
+
+ [System.Xml.Serialization.XmlAttribute("ref")]
+ public XmlQualifiedName RefName
+ {
+ get{ return refName;}
+ set
+ {
+ refName = value;
+ }
+ }
+
+ [System.Xml.Serialization.XmlAttribute("type")]
+ public XmlQualifiedName SchemaTypeName
+ {
+ get{ return schemaTypeName;}
+ set{ schemaTypeName = value;}
+ }
+
+ [XmlElement("simpleType",Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaSimpleType SchemaType
+ {
+ get{ return schemaType;}
+ set{ schemaType = value;}
+ }
+
+ [DefaultValue(XmlSchemaUse.None)]
+ [System.Xml.Serialization.XmlAttribute("use")]
+ public XmlSchemaUse Use
+ {
+ get{ return use;}
+ set{ use = value;}
+ }
+
+ [XmlIgnore]
+ public XmlQualifiedName QualifiedName
+ {
+ get{ return qualifiedName;}
+ }
+
+ [XmlIgnore]
+ public object AttributeType
+ { //FIXME: This is not correct. Is it?
+ get{ return attributeType; }
+ }
+
+ #endregion
+
+ /// <remarks>
+ /// For an attribute:
+ /// a) If the parent is schema
+ /// 1-5 are from <xs:complexType name="topLevelAttribute"> in the Schema for Schema
+ /// 6-8 are from "Constraints on XML Representations of Attribute Declarations"
+ /// 9-10 are from "Attribute Declaration Schema Component"
+ /// 11-16 are from "Constraints on Attribute Declaration Schema Components"
+ /// 1. ref must be absent
+ /// 2. form must be absent
+ /// 3. use must be absent
+ /// 4. name must be present and of type NCName
+ /// 5. *NO CHECK REQUIRED* Only simple types and annotation are allowed as content
+ /// 6. default and fixed must not both be present.
+ /// 7. *NO CHECK REQUIRED* If default and use are both present... (Not possible since use is absent)
+ /// 8. type and <simpleType> must not both be present.
+ /// 9. Target Namespace should be schema's targetnamespace or absent
+ /// 10. Type Definiton coressponds to <simpletype> element, or type value, or absent
+ /// 11. *TO UNDERSTAND* Missing Sub-components
+ /// 12. value constraint must be of the same datatype as of type
+ /// 13. if the type definition is ID then there should be no value constraint.
+ /// 14. name must not be xmlns
+ /// 15. Targetnamespace must not be xsi. This implies the target namespace of schema can't be xsi if toplevel attributes are used.
+ /// 16. *Exception to rule 15* inbuilt attributes: xsi:nil, xsi:type, xsi:schemaLocation, xsi: noNamespaceSchemaLocation
+ /// b) If the parent is complextype and ref is not set
+ /// 1. name must be present and of type NCName.
+ /// 2. type and <simpleType> must not both be present.
+ /// 3. default and fixed must not both be present.
+ /// 4. If default and use are both present, use must have the ·actual value· optional.
+ /// 5. name must not be xmlns
+ /// 6. Targetnamespace must not be xsi.
+ /// 7. *Exception to rule 15* inbuilt attributes: xsi:nil, xsi:type, xsi:schemaLocation, xsi: noNamespaceSchemaLocation
+ /// 8. If form has actual value qualified or the schema's formdefault is qualified, targetnamespace
+ /// is same as schema's target namespace, otherwise absent.
+ /// c) if the parent is not schema and ref is set
+ /// 1. name must not be present
+ /// 2. all of <simpleType>, form and type must be absent.
+ /// 3. default and fixed must not both be present.
+ /// 4. If default and use are both present, use must have the ·actual value· optional.
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ errorCount = 0;
+
+ if(parentIsSchema)//a
+ {
+ if(RefName!= null && !RefName.IsEmpty) // a.1
+ error(h,"ref must be absent in the top level <attribute>");
+
+ if(Form != XmlSchemaForm.None) // a.2
+ error(h,"form must be absent in the top level <attribute>");
+
+ if(Use != XmlSchemaUse.None) // a.3
+ error(h,"use must be absent in the top level <attribute>");
+
+ // TODO: a.10, a.11, a.12, a.13
+ CompileCommon(h,info, true);
+ }
+ else // local
+ {
+ //FIXME: How to Use of AttributeFormDefault????
+ if(RefName == null || RefName.IsEmpty)
+ {
+ //TODO: b.8
+ CompileCommon(h,info, true);
+ }
+ else
+ {
+ if(this.name != null)
+ error(h,"name must be absent if ref is present");
+ if(this.form != XmlSchemaForm.None)
+ error(h,"form must be absent if ref is present");
+ if(this.schemaType != null)
+ error(h,"simpletype must be absent if ref is present");
+ if(this.schemaTypeName != null && !this.schemaTypeName.IsEmpty)
+ error(h,"type must be absent if ref is present");
+ CompileCommon(h,info,false);
+ }
+ }
+
+ return errorCount;
+ }
+
+ private void CompileCommon(ValidationEventHandler h, XmlSchemaInfo info, bool refIsNotPresent)
+ {
+ if(refIsNotPresent)
+ {
+ if(Name == null) //a.4, b.1,
+ error(h,"Required attribute name must be present");
+ else if(!XmlSchemaUtil.CheckNCName(Name)) // a.4.2, b1.2
+ error(h,"attribute name must be NCName");
+ else if(Name == "xmlns") // a.14 , b5
+ error(h,"attribute name must not be xmlns");
+ else
+ qualifiedName = new XmlQualifiedName(Name, info.TargetNamespace);
+
+ if(SchemaType != null)
+ {
+ if(SchemaTypeName != null && !SchemaTypeName.IsEmpty) // a.8
+ error(h,"attribute can't have both a type and <simpleType> content");
+
+ errorCount += SchemaType.Compile(h,info);
+ }
+
+ if(SchemaTypeName != null && !XmlSchemaUtil.CheckQName(SchemaTypeName))
+ error(h,SchemaTypeName+" is not a valid QName");
+ }
+ else
+ {
+ if(RefName == null || RefName.IsEmpty)
+ error(h,"Error: Should Never Happen. refname must be present");
+ else
+ qualifiedName = RefName;
+ }
+
+ if(info.TargetNamespace == XmlSchema.InstanceNamespace && Name != "nil" && Name != "type"
+ && Name != "schemaLocation" && Name != "noNamespaceSchemaLocation") // a.15, a.16
+ error(h,"targetNamespace can't be " + XmlSchema.InstanceNamespace);
+
+ if(DefaultValue != null && FixedValue != null) // a.6, b.3, c.3
+ error(h,"default and fixed must not both be present in an Attribute");
+
+ if(DefaultValue != null && Use != XmlSchemaUse.None && Use != XmlSchemaUse.Optional)
+ error(h,"if default is present, use must be optional");
+
+ XmlSchemaUtil.CompileID(Id, this, info.IDCollection, h);
+ }
+
+ /// <summary>
+ /// Schema Component:
+ /// QName, SimpleType, Scope, Default|Fixed, annotation
+ /// </summary>
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ if(isCompiled)
+ return errorCount;
+
+ //If Parent is schema:
+ if(parentIsSchema)
+ {
+ if(SchemaType != null)
+ {
+ errorCount += SchemaType.Validate(h, info);
+ attributeType = SchemaType;
+ }
+ else if(SchemaTypeName != null && !SchemaTypeName.IsEmpty)
+ {
+ //First Try to get a Inbuilt DataType
+ XmlSchemaDatatype dtype = XmlSchemaDatatype.GetType(SchemaTypeName);
+ if(dtype != null)
+ {
+ attributeType = dtype;
+ }
+ else
+ {
+ XmlSchemaObject obj = info.SchemaTypes[SchemaTypeName];
+
+ if(obj is XmlSchemaSimpleType)
+ {
+ XmlSchemaSimpleType stype = (XmlSchemaSimpleType) obj;
+ errorCount += stype.Validate(h, info);
+ attributeType = stype;
+ }
+ else if(attributeType == null)
+ error(h,"The type '"+ SchemaTypeName +"' is not defined in the schema");
+ else if(attributeType is XmlSchemaComplexType)
+ error(h,"An attribute can't have complexType Content");
+ else
+ error(h, "Should Never Happen. Illegal content in SchemaTypes");
+ }
+ }
+ else
+ {
+ error(h,"Should Never Happen. Attribute SimpleType Not set. Should have been caught in the Compile() phase");
+ }
+ }
+ else
+ {
+ //TODO: Local Attribute Validation
+ }
+ isCompiled = true;
+ return errorCount;
+ }
+ //<attribute
+ // default = string
+ // fixed = string
+ // form = (qualified | unqualified)
+ // id = ID
+ // name = NCName
+ // ref = QName
+ // type = QName
+ // use = (optional | prohibited | required) : optional
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, (simpleType?))
+ //</attribute>
+ internal static XmlSchemaAttribute Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaAttribute attribute = new XmlSchemaAttribute();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaAttribute.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ attribute.LineNumber = reader.LineNumber;
+ attribute.LinePosition = reader.LinePosition;
+ attribute.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "default")
+ {
+ attribute.defaultValue = reader.Value;
+ }
+ else if(reader.Name == "fixed")
+ {
+ attribute.fixedValue = reader.Value;
+ }
+ else if(reader.Name == "form")
+ {
+ Exception innerex;
+ attribute.form = XmlSchemaUtil.ReadFormAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for form attribute", innerex);
+ }
+ else if(reader.Name == "id")
+ {
+ attribute.Id = reader.Value;
+ }
+ else if(reader.Name == "name")
+ {
+ attribute.name = reader.Value;
+ }
+ else if(reader.Name == "ref")
+ {
+ Exception innerex;
+ attribute.refName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for ref attribute",innerex);
+ }
+ else if(reader.Name == "type")
+ {
+ Exception innerex;
+ attribute.schemaTypeName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for type attribute",innerex);
+ }
+ else if(reader.Name == "use")
+ {
+ Exception innerex;
+ attribute.use = XmlSchemaUtil.ReadUseAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for use attribute", innerex);
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for attribute",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,attribute);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return attribute;
+
+ // Content: (annotation?, (simpleType?))
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaAttribute.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ attribute.Annotation = annotation;
+ continue;
+ }
+ if(level <=2 && reader.LocalName == "simpleType")
+ {
+ level = 3;
+ XmlSchemaSimpleType stype = XmlSchemaSimpleType.Read(reader,h);
+ if(stype != null)
+ attribute.schemaType = stype;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return attribute;
+ }
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttributeGroup.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttributeGroup.cs
new file mode 100755
index 00000000000..ab5d1da1afe
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttributeGroup.cs
@@ -0,0 +1,208 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaAttributeGroup.
+ /// </summary>
+ public class XmlSchemaAttributeGroup : XmlSchemaAnnotated
+ {
+ private XmlSchemaAnyAttribute any;
+ private XmlSchemaObjectCollection attributes;
+ private string name;
+ private XmlSchemaAttributeGroup redefined;
+ private XmlQualifiedName qualifiedName;
+ private static string xmlname = "attributeGroup";
+
+ public XmlSchemaAttributeGroup()
+ {
+ attributes = new XmlSchemaObjectCollection();
+ }
+
+ [System.Xml.Serialization.XmlAttribute("name")]
+ public string Name
+ {
+ get{ return name;}
+ set{ name = value;}
+ }
+
+ [XmlElement("attribute",typeof(XmlSchemaAttribute),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("attributeGroup",typeof(XmlSchemaAttributeGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection Attributes
+ {
+ get{ return attributes;}
+ }
+
+ [XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaAnyAttribute AnyAttribute
+ {
+ get{ return any;}
+ set{ any = value;}
+ }
+
+ //Undocumented property
+ [XmlIgnore]
+ public XmlSchemaAttributeGroup RedefinedAttributeGroup
+ {
+ get{ return redefined;}
+ }
+
+ [XmlIgnore]
+ internal XmlQualifiedName QualifiedName
+ {
+ get{ return qualifiedName;}
+ }
+
+ /// <remarks>
+ /// An Attribute group can only be defined as a child of XmlSchema or in XmlSchemaRedefine.
+ /// The other attributeGroup has type XmlSchemaAttributeGroupRef.
+ /// 1. Name must be present
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ errorCount = 0;
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ if(this.Name == null) //1
+ error(h,"Name is required in top level simpletype");
+ else if(!XmlSchemaUtil.CheckNCName(this.Name)) // b.1.2
+ error(h,"name attribute of a simpleType must be NCName");
+ else
+ this.qualifiedName = new XmlQualifiedName(this.Name,info.TargetNamespace);
+
+ if(this.AnyAttribute != null)
+ {
+ errorCount += this.AnyAttribute.Compile(h,info);
+ }
+
+ foreach(XmlSchemaObject obj in Attributes)
+ {
+ if(obj is XmlSchemaAttribute)
+ {
+ XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;
+ errorCount += attr.Compile(h, info);
+ }
+ else if(obj is XmlSchemaAttributeGroupRef)
+ {
+ XmlSchemaAttributeGroupRef gref = (XmlSchemaAttributeGroupRef) obj;
+ errorCount += gref.Compile(h, info);
+ }
+ else
+ {
+ error(h,"invalid type of object in Attributes property");
+ }
+ }
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+
+ //<attributeGroup
+ // id = ID
+ // name = NCName
+ // ref = QName // Not present in this class.
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, ((attribute | attributeGroup)*, anyAttribute?))
+ //</attributeGroup>
+ internal static XmlSchemaAttributeGroup Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaAttributeGroup attrgrp = new XmlSchemaAttributeGroup();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaAttributeGroup.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ attrgrp.LineNumber = reader.LineNumber;
+ attrgrp.LinePosition = reader.LinePosition;
+ attrgrp.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ attrgrp.Id = reader.Value;
+ }
+ else if(reader.Name == "name")
+ {
+ attrgrp.name = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for attributeGroup in this context",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,attrgrp);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return attrgrp;
+
+ //Content: 1.annotation?, 2.(attribute | attributeGroup)*, 3.anyAttribute?
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaAttributeGroup.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ attrgrp.Annotation = annotation;
+ continue;
+ }
+ if(level <= 2)
+ {
+ if(reader.LocalName == "attribute")
+ {
+ level = 2;
+ XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader,h);
+ if(attr != null)
+ attrgrp.Attributes.Add(attr);
+ continue;
+ }
+ if(reader.LocalName == "attributeGroup")
+ {
+ level = 2;
+ XmlSchemaAttributeGroupRef attr = XmlSchemaAttributeGroupRef.Read(reader,h);
+ if(attr != null)
+ attrgrp.attributes.Add(attr);
+ continue;
+ }
+ }
+ if(level <= 3 && reader.LocalName == "anyAttribute")
+ {
+ level = 4;
+ XmlSchemaAnyAttribute anyattr = XmlSchemaAnyAttribute.Read(reader,h);
+ if(anyattr != null)
+ attrgrp.AnyAttribute = anyattr;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return attrgrp;
+ }
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttributeGroupRef.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttributeGroupRef.cs
new file mode 100755
index 00000000000..0fb4a4261aa
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaAttributeGroupRef.cs
@@ -0,0 +1,126 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaAttributeGroupRef.
+ /// </summary>
+ public class XmlSchemaAttributeGroupRef : XmlSchemaAnnotated
+ {
+ private XmlQualifiedName refName;
+ private static string xmlname = "attributeGroup";
+ public XmlSchemaAttributeGroupRef()
+ {
+ refName = XmlQualifiedName.Empty;
+ }
+
+ [System.Xml.Serialization.XmlAttribute("ref")]
+ public XmlQualifiedName RefName
+ {
+ get{ return refName; }
+ set{ refName = value; }
+ }
+
+ /// <remarks>
+ /// 1. ref must be present
+ /// 2. The element must be empty. ?? FIXME: Is this correct or annotation is permitted?
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ errorCount = 0;
+ if(RefName == null || RefName.IsEmpty)
+ error(h, "ref must be present");
+ else if(!XmlSchemaUtil.CheckQName(RefName))
+ error(h, "ref must be a valid qname");
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+// if(this.Annotation != null)
+// error(h, "attributegroup with a ref can't have any content");
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+
+ //<attributeGroup
+ // id = ID
+ // ref = QName
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</attributeGroup>
+ internal static XmlSchemaAttributeGroupRef Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaAttributeGroupRef attrgrp = new XmlSchemaAttributeGroupRef();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaAttributeGroupRef.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ attrgrp.LineNumber = reader.LineNumber;
+ attrgrp.LinePosition = reader.LinePosition;
+ attrgrp.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ attrgrp.Id = reader.Value;
+ }
+ else if(reader.Name == "ref")
+ {
+ Exception innerex;
+ attrgrp.refName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for ref attribute",innerex);
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for attributeGroup in this context",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,attrgrp);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return attrgrp;
+ int level = 1;
+
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaAttributeGroupRef.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ attrgrp.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return attrgrp;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaChoice.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaChoice.cs
new file mode 100755
index 00000000000..040de9d9719
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaChoice.cs
@@ -0,0 +1,203 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaAll.
+ /// </summary>
+ public class XmlSchemaChoice : XmlSchemaGroupBase
+ {
+ private XmlSchemaObjectCollection items;
+ private static string xmlname = "choice";
+
+ public XmlSchemaChoice()
+ {
+ items = new XmlSchemaObjectCollection();
+ }
+
+ [XmlElement("element",typeof(XmlSchemaElement),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("group",typeof(XmlSchemaGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("choice",typeof(XmlSchemaChoice),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("sequence",typeof(XmlSchemaSequence),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("any",typeof(XmlSchemaAny),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public override XmlSchemaObjectCollection Items
+ {
+ get{ return items; }
+ }
+
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ //FIXME: Should we reset the values
+ if(MinOccurs > MaxOccurs)
+ error(h,"minOccurs must be less than or equal to maxOccurs");
+
+ XmlSchemaUtil.CompileID(Id, this, info.IDCollection, h);
+
+ foreach(XmlSchemaObject obj in Items)
+ {
+ if(obj is XmlSchemaElement)
+ {
+ errorCount += ((XmlSchemaElement)obj).Compile(h,info);
+ }
+ else if(obj is XmlSchemaGroupRef)
+ {
+ errorCount += ((XmlSchemaGroupRef)obj).Compile(h,info);
+ }
+ else if(obj is XmlSchemaChoice)
+ {
+ errorCount += ((XmlSchemaChoice)obj).Compile(h,info);
+ }
+ else if(obj is XmlSchemaSequence)
+ {
+ errorCount += ((XmlSchemaSequence)obj).Compile(h,info);
+ }
+ else if(obj is XmlSchemaAny)
+ {
+ errorCount += ((XmlSchemaAny)obj).Compile(h,info);
+ }
+ }
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+ //<choice
+ // id = ID
+ // maxOccurs = (nonNegativeInteger | unbounded) : 1
+ // minOccurs = nonNegativeInteger : 1
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, (element | group | choice | sequence | any)*)
+ //</choice>
+ internal static XmlSchemaChoice Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaChoice choice = new XmlSchemaChoice();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaChoice.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ choice.LineNumber = reader.LineNumber;
+ choice.LinePosition = reader.LinePosition;
+ choice.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ choice.Id = reader.Value;
+ }
+ else if(reader.Name == "maxOccurs")
+ {
+ try
+ {
+ choice.MaxOccursString = reader.Value;
+ }
+ catch(Exception e)
+ {
+ error(h,reader.Value + " is an invalid value for maxOccurs",e);
+ }
+ }
+ else if(reader.Name == "minOccurs")
+ {
+ try
+ {
+ choice.MinOccursString = reader.Value;
+ }
+ catch(Exception e)
+ {
+ error(h,reader.Value + " is an invalid value for minOccurs",e);
+ }
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for choice",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,choice);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return choice;
+
+ // Content: (annotation?, (element | group | choice | sequence | any)*)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaChoice.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ choice.Annotation = annotation;
+ continue;
+ }
+ if(level <=2)
+ {
+ if(reader.LocalName == "element")
+ {
+ level = 2;
+ XmlSchemaElement element = XmlSchemaElement.Read(reader,h);
+ if(element != null)
+ choice.items.Add(element);
+ continue;
+ }
+ if(reader.LocalName == "group")
+ {
+ level = 2;
+ XmlSchemaGroupRef group = XmlSchemaGroupRef.Read(reader,h);
+ if(group != null)
+ choice.items.Add(group);
+ continue;
+ }
+ if(reader.LocalName == "choice")
+ {
+ level = 2;
+ XmlSchemaChoice ch = XmlSchemaChoice.Read(reader,h);
+ if(ch != null)
+ choice.items.Add(ch);
+ continue;
+ }
+ if(reader.LocalName == "sequence")
+ {
+ level = 2;
+ XmlSchemaSequence sequence = XmlSchemaSequence.Read(reader,h);
+ if(sequence != null)
+ choice.items.Add(sequence);
+ continue;
+ }
+ if(reader.LocalName == "any")
+ {
+ level = 2;
+ XmlSchemaAny any = XmlSchemaAny.Read(reader,h);
+ if(any != null)
+ choice.items.Add(any);
+ continue;
+ }
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return choice;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaCollection.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaCollection.cs
new file mode 100755
index 00000000000..57f73fc72b8
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaCollection.cs
@@ -0,0 +1,130 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Collections;
+using System.Xml;
+
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaCollection.
+ /// </summary>
+ public sealed class XmlSchemaCollection : ICollection, IEnumerable
+ {
+ //private fields
+ private Hashtable htable;
+ private Hashtable uriTable;
+ private XmlNameTable ntable;
+
+ public XmlSchemaCollection()
+ : this (new NameTable ())
+ {
+ }
+
+ public XmlSchemaCollection(XmlNameTable nametable)
+ {
+ htable = new Hashtable();
+ uriTable = new Hashtable ();
+ ntable = nametable;
+ }
+
+ //properties
+ public int Count
+ {
+ get
+ {
+ return this.htable.Count;
+ }
+ }
+ public XmlNameTable NameTable
+ {
+ get
+ {
+ return this.ntable;
+ }
+ }
+ public XmlSchema this[ string ns ]
+ {
+ get
+ {
+ return (XmlSchema) this.htable[ns];
+ }
+ }
+
+ // Events
+ public event ValidationEventHandler ValidationEventHandler;
+
+ // Methods
+ [MonoTODO]
+ public XmlSchema Add(string ns, XmlReader reader)
+ {
+ if (reader == null)
+ throw new ArgumentNullException ("reader");
+
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public XmlSchema Add(string ns, string uri)
+ {
+ if (uri == null || uri == String.Empty)
+ throw new ArgumentNullException ("uri");
+
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public XmlSchema Add(XmlSchema schema)
+ {
+ if (schema == null)
+ throw new ArgumentNullException ("schema");
+
+ throw new NotImplementedException ();
+ }
+
+ public void Add(XmlSchemaCollection schema)
+ {
+ if (schema == null)
+ throw new ArgumentNullException ("schema");
+
+ foreach (XmlSchema s in schema)
+ Add (s);
+ }
+
+ public bool Contains(string ns)
+ {
+ return this.htable.Contains(ns);
+ }
+ public bool Contains(XmlSchema schema)
+ {
+ return this.htable.Contains(schema.TargetNamespace);
+ }
+ public void CopyTo(XmlSchema[] array, int index)
+ {
+
+ }
+ public XmlSchemaCollectionEnumerator GetEnumerator()
+ {
+ return new XmlSchemaCollectionEnumerator(this.htable);
+ }
+
+ //assembly Methods
+ [MonoTODO]
+ void ICollection.CopyTo(Array array, int index)
+ {
+ }
+ bool ICollection.IsSynchronized
+ {
+ get { return false; }
+ }
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return this.htable.GetEnumerator();
+ }
+ Object ICollection.SyncRoot
+ {
+ get { return this; }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaCollectionEnumerator.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaCollectionEnumerator.cs
new file mode 100755
index 00000000000..3130c3094ac
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaCollectionEnumerator.cs
@@ -0,0 +1,47 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Collections;
+
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaCollectionEnumerator.
+ /// </summary>
+ public sealed class XmlSchemaCollectionEnumerator : IEnumerator
+ {
+ private IDictionaryEnumerator xenum;
+ internal XmlSchemaCollectionEnumerator(Hashtable htable)
+ {
+ this.xenum = htable.GetEnumerator();
+ }
+ // Properties
+ public XmlSchema Current
+ {
+ get
+ {
+ return (XmlSchema) xenum.Current;
+ }
+ }
+ // Methods
+ public bool MoveNext()
+ {
+ return xenum.MoveNext();
+ }
+
+ //Explicit Interface implementation
+ bool IEnumerator.MoveNext()
+ {
+ return xenum.MoveNext();
+ }
+ void IEnumerator.Reset()
+ {
+ xenum.Reset();
+ }
+ object IEnumerator.Current
+ {
+ get{return (XmlSchema) xenum.Current;}
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContent.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContent.cs
new file mode 100755
index 00000000000..45b07b3b1f0
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContent.cs
@@ -0,0 +1,162 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaComplexContent.
+ /// </summary>
+ public class XmlSchemaComplexContent : XmlSchemaContentModel
+ {
+ private XmlSchemaContent content;
+ private bool isMixed;
+ private static string xmlname = "complexContent";
+
+ public XmlSchemaComplexContent()
+ {}
+
+ [System.Xml.Serialization.XmlAttribute("mixed")]
+ public bool IsMixed
+ {
+ get{ return isMixed; }
+ set{ isMixed = value; }
+ }
+
+ [XmlElement("restriction",typeof(XmlSchemaComplexContentRestriction),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("extension",typeof(XmlSchemaComplexContentExtension),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public override XmlSchemaContent Content
+ {
+ get{ return content; }
+ set{ content = value; }
+ }
+
+ /// <remarks>
+ /// 1. Content must be present
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ if(Content == null)
+ {
+ error(h, "Content must be present in a complexContent");
+ }
+ else
+ {
+ if(Content is XmlSchemaComplexContentRestriction)
+ {
+ XmlSchemaComplexContentRestriction xscr = (XmlSchemaComplexContentRestriction) Content;
+ errorCount += xscr.Compile(h,info);
+ }
+ else if(Content is XmlSchemaComplexContentExtension)
+ {
+ XmlSchemaComplexContentExtension xsce = (XmlSchemaComplexContentExtension) Content;
+ errorCount += xsce.Compile(h,info);
+ }
+ else
+ error(h,"complexContent can't have any value other than restriction or extention");
+ }
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+ //<complexContent
+ // id = ID
+ // mixed = boolean
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, (restriction | extension))
+ //</complexContent>
+ internal static XmlSchemaComplexContent Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaComplexContent complex = new XmlSchemaComplexContent();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaComplexContent.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ complex.LineNumber = reader.LineNumber;
+ complex.LinePosition = reader.LinePosition;
+ complex.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ complex.Id = reader.Value;
+ }
+ else if(reader.Name == "mixed")
+ {
+ Exception innerex;
+ complex.isMixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h,reader.Value + " is an invalid value for mixed",innerex);
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for complexContent",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,complex);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return complex;
+ //Content: (annotation?, (restriction | extension))
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaComplexContent.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ complex.Annotation = annotation;
+ continue;
+ }
+ if(level <=2)
+ {
+ if(reader.LocalName == "restriction")
+ {
+ level = 3;
+ XmlSchemaComplexContentRestriction restriction = XmlSchemaComplexContentRestriction.Read(reader,h);
+ if(restriction != null)
+ complex.content = restriction;
+ continue;
+ }
+ if(reader.LocalName == "extension")
+ {
+ level = 3;
+ XmlSchemaComplexContentExtension extension = XmlSchemaComplexContentExtension.Read(reader,h);
+ if(extension != null)
+ complex.content = extension;
+ continue;
+ }
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return complex;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContentExtension.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContentExtension.cs
new file mode 100755
index 00000000000..4deced9326a
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContentExtension.cs
@@ -0,0 +1,254 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaComplexContentExtension.
+ /// </summary>
+ public class XmlSchemaComplexContentExtension : XmlSchemaContent
+ {
+ private XmlSchemaAnyAttribute any;
+ private XmlSchemaObjectCollection attributes;
+ private XmlQualifiedName baseTypeName;
+ private XmlSchemaParticle particle;
+ private static string xmlname = "extension";
+
+ public XmlSchemaComplexContentExtension()
+ {
+ attributes = new XmlSchemaObjectCollection();
+ baseTypeName = XmlQualifiedName.Empty;
+ }
+
+ [System.Xml.Serialization.XmlAttribute("base")]
+ public XmlQualifiedName BaseTypeName
+ {
+ get{ return baseTypeName; }
+ set{ baseTypeName = value; }
+ }
+
+ [XmlElement("group",typeof(XmlSchemaGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("all",typeof(XmlSchemaAll),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("choice",typeof(XmlSchemaChoice),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("sequence",typeof(XmlSchemaSequence),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaParticle Particle
+ {
+ get{ return particle; }
+ set{ particle = value; }
+ }
+
+ [XmlElement("attribute",typeof(XmlSchemaAttribute),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("attributeGroup",typeof(XmlSchemaAttributeGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection Attributes
+ {
+ get{ return attributes; }
+ }
+
+ [XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaAnyAttribute AnyAttribute
+ {
+ get{ return any; }
+ set{ any = value;}
+ }
+
+ /// <remarks>
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ if(BaseTypeName == null || BaseTypeName.IsEmpty)
+ {
+ error(h, "base must be present and a QName");
+ }
+ else if(!XmlSchemaUtil.CheckQName(BaseTypeName))
+ error(h,"BaseTypeName is not a valid XmlQualifiedName");
+
+ if(this.AnyAttribute != null)
+ {
+ errorCount += AnyAttribute.Compile(h,info);
+ }
+
+ foreach(XmlSchemaObject obj in Attributes)
+ {
+ if(obj is XmlSchemaAttribute)
+ {
+ XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;
+ errorCount += attr.Compile(h,info);
+ }
+ else if(obj is XmlSchemaAttributeGroupRef)
+ {
+ XmlSchemaAttributeGroupRef atgrp = (XmlSchemaAttributeGroupRef) obj;
+ errorCount += atgrp.Compile(h,info);
+ }
+ else
+ error(h,obj.GetType() +" is not valid in this place::ComplexConetnetExtension");
+ }
+
+ if(Particle != null)
+ {
+ if(Particle is XmlSchemaGroupRef)
+ {
+ errorCount += ((XmlSchemaGroupRef)Particle).Compile(h,info);
+ }
+ else if(Particle is XmlSchemaAll)
+ {
+ errorCount += ((XmlSchemaAll)Particle).Compile(h,info);
+ }
+ else if(Particle is XmlSchemaChoice)
+ {
+ errorCount += ((XmlSchemaChoice)Particle).Compile(h,info);
+ }
+ else if(Particle is XmlSchemaSequence)
+ {
+ errorCount += ((XmlSchemaSequence)Particle).Compile(h,info);
+ }
+ }
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+ //<extension
+ // base = QName
+ // id = ID
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?)))
+ //</extension>
+ internal static XmlSchemaComplexContentExtension Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaComplexContentExtension extension = new XmlSchemaComplexContentExtension();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaComplexContentExtension.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ extension.LineNumber = reader.LineNumber;
+ extension.LinePosition = reader.LinePosition;
+ extension.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "base")
+ {
+ Exception innerex;
+ extension.baseTypeName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for base attribute",innerex);
+ }
+ else if(reader.Name == "id")
+ {
+ extension.Id = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for extension",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,extension);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return extension;
+ //Content: 1. annotation?,
+ // (2.(group | all | choice | sequence)?, (3.(attribute | attributeGroup)*, 4.anyAttribute?)))
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaComplexContentExtension.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ extension.Annotation = annotation;
+ continue;
+ }
+ if(level <= 2)
+ {
+ if(reader.LocalName == "group")
+ {
+ level = 3;
+ XmlSchemaGroupRef group = XmlSchemaGroupRef.Read(reader,h);
+ if(group != null)
+ extension.particle = group;
+ continue;
+ }
+ if(reader.LocalName == "all")
+ {
+ level = 3;
+ XmlSchemaAll all = XmlSchemaAll.Read(reader,h);
+ if(all != null)
+ extension.particle = all;
+ continue;
+ }
+ if(reader.LocalName == "choice")
+ {
+ level = 3;
+ XmlSchemaChoice choice = XmlSchemaChoice.Read(reader,h);
+ if(choice != null)
+ extension.particle = choice;
+ continue;
+ }
+ if(reader.LocalName == "sequence")
+ {
+ level = 3;
+ XmlSchemaSequence sequence = XmlSchemaSequence.Read(reader,h);
+ if(sequence != null)
+ extension.particle = sequence;
+ continue;
+ }
+ }
+ if(level <= 3)
+ {
+ if(reader.LocalName == "attribute")
+ {
+ level = 3;
+ XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader,h);
+ if(attr != null)
+ extension.Attributes.Add(attr);
+ continue;
+ }
+ if(reader.LocalName == "attributeGroup")
+ {
+ level = 3;
+ XmlSchemaAttributeGroupRef attr = XmlSchemaAttributeGroupRef.Read(reader,h);
+ if(attr != null)
+ extension.attributes.Add(attr);
+ continue;
+ }
+ }
+ if(level <= 4 && reader.LocalName == "anyAttribute")
+ {
+ level = 5;
+ XmlSchemaAnyAttribute anyattr = XmlSchemaAnyAttribute.Read(reader,h);
+ if(anyattr != null)
+ extension.AnyAttribute = anyattr;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return extension;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContentRestriction.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContentRestriction.cs
new file mode 100755
index 00000000000..e744a3a47c0
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexContentRestriction.cs
@@ -0,0 +1,256 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaComplexContentRestriction.
+ /// </summary>
+ public class XmlSchemaComplexContentRestriction : XmlSchemaContent
+ {
+ private XmlSchemaAnyAttribute any;
+ private XmlSchemaObjectCollection attributes;
+ private XmlQualifiedName baseTypeName;
+ private XmlSchemaParticle particle;
+ private static string xmlname = "restriction";
+
+ public XmlSchemaComplexContentRestriction()
+ {
+ baseTypeName = XmlQualifiedName.Empty;
+ attributes = new XmlSchemaObjectCollection();
+ }
+
+ [System.Xml.Serialization.XmlAttribute("base")]
+ public XmlQualifiedName BaseTypeName
+ {
+ get{ return baseTypeName; }
+ set{ baseTypeName = value; }
+ }
+
+ [XmlElement("group",typeof(XmlSchemaGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("all",typeof(XmlSchemaAll),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("choice",typeof(XmlSchemaChoice),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("sequence",typeof(XmlSchemaSequence),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaParticle Particle
+ {
+ get{ return particle; }
+ set{ particle = value; }
+ }
+
+ [XmlElement("attribute",typeof(XmlSchemaAttribute),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("attributeGroup",typeof(XmlSchemaAttributeGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection Attributes
+ {
+ get{ return attributes; }
+ }
+
+ [XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaAnyAttribute AnyAttribute
+ {
+ get{ return any; }
+ set{ any = value; }
+ }
+
+ /// <remarks>
+ /// 1. base must be present
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ if(BaseTypeName == null || BaseTypeName.IsEmpty)
+ {
+ error(h, "base must be present and a QName");
+ }
+ else if(!XmlSchemaUtil.CheckQName(BaseTypeName))
+ error(h,"BaseTypeName is not a valid XmlQualifiedName");
+
+ if(this.AnyAttribute != null)
+ {
+ errorCount += AnyAttribute.Compile(h,info);
+ }
+
+ foreach(XmlSchemaObject obj in Attributes)
+ {
+ if(obj is XmlSchemaAttribute)
+ {
+ XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;
+ errorCount += attr.Compile(h,info);
+ }
+ else if(obj is XmlSchemaAttributeGroupRef)
+ {
+ XmlSchemaAttributeGroupRef atgrp = (XmlSchemaAttributeGroupRef) obj;
+ errorCount += atgrp.Compile(h,info);
+ }
+ else
+ error(h,obj.GetType() +" is not valid in this place::ComplexContentRestriction");
+ }
+
+ if(Particle != null)
+ {
+ if(Particle is XmlSchemaGroupRef)
+ {
+ errorCount += ((XmlSchemaGroupRef)Particle).Compile(h,info);
+ }
+ else if(Particle is XmlSchemaAll)
+ {
+ errorCount += ((XmlSchemaAll)Particle).Compile(h,info);
+ }
+ else if(Particle is XmlSchemaChoice)
+ {
+ errorCount += ((XmlSchemaChoice)Particle).Compile(h,info);
+ }
+ else if(Particle is XmlSchemaSequence)
+ {
+ errorCount += ((XmlSchemaSequence)Particle).Compile(h,info);
+ }
+ }
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+
+ //<restriction
+ // base = QName
+ // id = ID
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?)))
+ //</restriction>
+ internal static XmlSchemaComplexContentRestriction Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaComplexContentRestriction restriction = new XmlSchemaComplexContentRestriction();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaComplexContentRestriction.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ restriction.LineNumber = reader.LineNumber;
+ restriction.LinePosition = reader.LinePosition;
+ restriction.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "base")
+ {
+ Exception innerex;
+ restriction.baseTypeName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for base attribute",innerex);
+ }
+ else if(reader.Name == "id")
+ {
+ restriction.Id = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for restriction",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,restriction);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return restriction;
+ //Content: 1. annotation?,
+ // (2.(group | all | choice | sequence)?, (3.(attribute | attributeGroup)*, 4.anyAttribute?)))
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaComplexContentRestriction.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ restriction.Annotation = annotation;
+ continue;
+ }
+ if(level <= 2)
+ {
+ if(reader.LocalName == "group")
+ {
+ level = 3;
+ XmlSchemaGroupRef group = XmlSchemaGroupRef.Read(reader,h);
+ if(group != null)
+ restriction.particle = group;
+ continue;
+ }
+ if(reader.LocalName == "all")
+ {
+ level = 3;
+ XmlSchemaAll all = XmlSchemaAll.Read(reader,h);
+ if(all != null)
+ restriction.particle = all;
+ continue;
+ }
+ if(reader.LocalName == "choice")
+ {
+ level = 3;
+ XmlSchemaChoice choice = XmlSchemaChoice.Read(reader,h);
+ if(choice != null)
+ restriction.particle = choice;
+ continue;
+ }
+ if(reader.LocalName == "sequence")
+ {
+ level = 3;
+ XmlSchemaSequence sequence = XmlSchemaSequence.Read(reader,h);
+ if(sequence != null)
+ restriction.particle = sequence;
+ continue;
+ }
+ }
+ if(level <= 3)
+ {
+ if(reader.LocalName == "attribute")
+ {
+ level = 3;
+ XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader,h);
+ if(attr != null)
+ restriction.Attributes.Add(attr);
+ continue;
+ }
+ if(reader.LocalName == "attributeGroup")
+ {
+ level = 3;
+ XmlSchemaAttributeGroupRef attr = XmlSchemaAttributeGroupRef.Read(reader,h);
+ if(attr != null)
+ restriction.attributes.Add(attr);
+ continue;
+ }
+ }
+ if(level <= 4 && reader.LocalName == "anyAttribute")
+ {
+ level = 5;
+ XmlSchemaAnyAttribute anyattr = XmlSchemaAnyAttribute.Read(reader,h);
+ if(anyattr != null)
+ restriction.AnyAttribute = anyattr;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return restriction;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexType.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexType.cs
new file mode 100755
index 00000000000..113aff9f415
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaComplexType.cs
@@ -0,0 +1,463 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.ComponentModel;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaComplexType.
+ /// </summary>
+ public class XmlSchemaComplexType : XmlSchemaType
+ {
+ private XmlSchemaAnyAttribute anyAttribute;
+ private XmlSchemaObjectCollection attributes;
+ private XmlSchemaObjectTable attributeUses;
+ private XmlSchemaAnyAttribute attributeWildcard;
+ private XmlSchemaDerivationMethod block;
+ private XmlSchemaDerivationMethod blockResolved;
+ private XmlSchemaContentModel contentModel;
+ private XmlSchemaContentType contentType;
+ private XmlSchemaParticle contentTypeParticle;
+ private bool isAbstract;
+ private bool isMixed;
+ private XmlSchemaParticle particle;
+
+ internal bool istoplevel = false;
+ private static string xmlname = "complexType";
+
+ public XmlSchemaComplexType()
+ {
+ attributes = new XmlSchemaObjectCollection();
+ block = XmlSchemaDerivationMethod.None;
+ attributeUses = new XmlSchemaObjectTable();
+ }
+
+ #region Attributes
+
+ [DefaultValue(false)]
+ [System.Xml.Serialization.XmlAttribute("abstract")]
+ public bool IsAbstract
+ {
+ get{ return isAbstract; }
+ set{ isAbstract = value; }
+ }
+ [DefaultValue(XmlSchemaDerivationMethod.None)]
+ [System.Xml.Serialization.XmlAttribute("block")]
+ public XmlSchemaDerivationMethod Block
+ {
+ get{ return block; }
+ set{ block = value; }
+ }
+ [DefaultValue(false)]
+ [System.Xml.Serialization.XmlAttribute("mixed")]
+ public override bool IsMixed
+ {
+ get{ return isMixed; }
+ set{ isMixed = value; }
+ }
+
+ #endregion
+
+ #region Elements
+
+ [XmlElement("simpleContent",typeof(XmlSchemaSimpleContent),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("complexContent",typeof(XmlSchemaComplexContent),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaContentModel ContentModel
+ {
+ get{ return contentModel; }
+ set{ contentModel = value; }
+ }
+
+ //LAMESPEC: The default value for particle in Schema is of Type EmptyParticle (internal?)
+ [XmlElement("group",typeof(XmlSchemaGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("all",typeof(XmlSchemaAll),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("choice",typeof(XmlSchemaChoice),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("sequence",typeof(XmlSchemaSequence),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaParticle Particle
+ {
+ get{ return particle; }
+ set{ particle = value; }
+ }
+
+ [XmlElement("attribute",typeof(XmlSchemaAttribute),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("attributeGroup",typeof(XmlSchemaAttributeGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection Attributes
+ {
+ get{ return attributes; }
+ }
+
+ [XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaAnyAttribute AnyAttribute
+ {
+ get{ return anyAttribute; }
+ set{ anyAttribute = value; }
+ }
+
+ #endregion
+
+ #region XmlIgnore
+ [XmlIgnore]
+ public XmlSchemaContentType ContentType
+ {
+ get{ return contentType; }
+ }
+ [XmlIgnore]
+ public XmlSchemaParticle ContentTypeParticle
+ {
+ get{ return contentTypeParticle; }
+ }
+ [XmlIgnore]
+ public XmlSchemaDerivationMethod BlockResolved
+ {
+ get{ return blockResolved; }
+ }
+ [XmlIgnore]
+ public XmlSchemaObjectTable AttributeUses
+ {
+ get{ return attributeUses; }
+ }
+ [XmlIgnore]
+ public XmlSchemaAnyAttribute AttributeWildcard
+ {
+ get{ return attributeWildcard; }
+ }
+ #endregion
+
+ /// <remarks>
+ /// 1. If ContentModel is present, neither particle nor Attributes nor AnyAttribute can be present.
+ /// 2. If particle is present,
+ /// a. For a topLevelComplexType
+ /// 1. name must be present and type NCName
+ /// 2. if block is #all, blockdefault is #all, else List of (extension | restriction)
+ /// 3. if final is #all, finaldefault is #all, else List of (extension | restriction)
+ /// b. For a local Complex type
+ /// 1. abstract must be false
+ /// 2. Name must be absent
+ /// 3. final must be absent
+ /// 4. block must be absent
+ ///
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ if(istoplevel)
+ {
+ if(this.Name == null || this.Name == string.Empty)
+ error(h,"name must be present in a top level complex type");
+ else if(!XmlSchemaUtil.CheckNCName(Name))
+ error(h,"name must be a NCName");
+ else
+ this.qName = new XmlQualifiedName(Name,info.TargetNamespace);
+
+ if(Block != XmlSchemaDerivationMethod.None)
+ {
+ if(Block == XmlSchemaDerivationMethod.All)
+ {
+ blockResolved = XmlSchemaDerivationMethod.All;
+ }
+ else
+ {
+ //TODO: Check what all is not allowed
+ blockResolved = Block & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction);
+ }
+ }
+ else
+ {
+ if(info.BlockDefault == XmlSchemaDerivationMethod.All)
+ {
+ blockResolved = XmlSchemaDerivationMethod.All;
+ }
+ else
+ blockResolved = info.BlockDefault & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction);
+ }
+ if(Final != XmlSchemaDerivationMethod.None)
+ {
+ if(Final == XmlSchemaDerivationMethod.All)
+ {
+ finalResolved = XmlSchemaDerivationMethod.All;
+ }
+ else
+ {
+ //TODO: Check what all is not allowed
+ finalResolved = Final & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction);
+ }
+ }
+ else
+ {
+ if(info.FinalDefault == XmlSchemaDerivationMethod.All)
+ {
+ finalResolved = XmlSchemaDerivationMethod.All;
+ }
+ else
+ {
+ finalResolved = info.BlockDefault & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction);
+ }
+ }
+ }
+ else // Not Top Level
+ {
+ if(isAbstract)
+ error(h,"abstract must be false in a local complex type");
+ if(Name != null)
+ error(h,"name must be absent in a local complex type");
+ if(Final != XmlSchemaDerivationMethod.None)
+ error(h,"final must be absent in a local complex type");
+ if(block != XmlSchemaDerivationMethod.None)
+ error(h,"block must be absent in a local complex type");
+ }
+
+ if(ContentModel != null)
+ {
+ if(anyAttribute != null || Attributes.Count != 0 || Particle != null)
+ error(h,"attributes, particles or anyattribute is not allowed if ContentModel is present");
+
+ if(ContentModel is XmlSchemaSimpleContent)
+ {
+ XmlSchemaSimpleContent smodel = (XmlSchemaSimpleContent)ContentModel;
+ errorCount += smodel.Compile(h,info);
+ }
+ else if(ContentModel is XmlSchemaComplexContent)
+ {
+ XmlSchemaComplexContent cmodel = (XmlSchemaComplexContent)ContentModel;
+ errorCount += cmodel.Compile(h,info);
+ }
+ }
+ else
+ {
+ if(Particle is XmlSchemaGroupRef)
+ {
+ XmlSchemaGroupRef xsgr = (XmlSchemaGroupRef)Particle;
+ errorCount += xsgr.Compile(h,info);
+ }
+ else if(Particle is XmlSchemaAll)
+ {
+ XmlSchemaAll xsa = (XmlSchemaAll)Particle;
+ errorCount += xsa.Compile(h,info);
+ }
+ else if(Particle is XmlSchemaChoice)
+ {
+ XmlSchemaChoice xsc = (XmlSchemaChoice)Particle;
+ errorCount += xsc.Compile(h,info);
+ }
+ else if(Particle is XmlSchemaSequence)
+ {
+ XmlSchemaSequence xss = (XmlSchemaSequence)Particle;
+ errorCount += xss.Compile(h,info);
+ }
+
+ if(this.anyAttribute != null)
+ {
+ AnyAttribute.Compile(h,info);
+ }
+ foreach(XmlSchemaObject obj in Attributes)
+ {
+ if(obj is XmlSchemaAttribute)
+ {
+ XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;
+ errorCount += attr.Compile(h,info);
+ }
+ else if(obj is XmlSchemaAttributeGroupRef)
+ {
+ XmlSchemaAttributeGroupRef atgrp = (XmlSchemaAttributeGroupRef) obj;
+ errorCount += atgrp.Compile(h,info);
+ }
+ else
+ error(h,obj.GetType() +" is not valid in this place::ComplexType");
+ }
+ }
+
+ XmlSchemaUtil.CompileID(Id, this, info.IDCollection, h);
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+
+ //<complexType
+ // abstract = boolean : false
+ // block = (#all | List of (extension | restriction))
+ // final = (#all | List of (extension | restriction))
+ // id = ID
+ // mixed = boolean : false
+ // name = NCName
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, (simpleContent | complexContent | ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?))))
+ //</complexType>
+ internal static XmlSchemaComplexType Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaComplexType ctype = new XmlSchemaComplexType();
+ reader.MoveToElement();
+ Exception innerex;
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaComplexType.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ ctype.LineNumber = reader.LineNumber;
+ ctype.LinePosition = reader.LinePosition;
+ ctype.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "abstract")
+ {
+ ctype.IsAbstract = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h,reader.Value + " is invalid value for abstract",innerex);
+ }
+ else if(reader.Name == "block")
+ {
+ ctype.block = XmlSchemaUtil.ReadDerivationAttribute(reader,out innerex, "block");
+ if(innerex != null)
+ warn(h,"some invalid values for block attribute were found",innerex);
+ }
+ else if(reader.Name == "final")
+ {
+ ctype.Final = XmlSchemaUtil.ReadDerivationAttribute(reader,out innerex, "block");
+ if(innerex != null)
+ warn(h,"some invalid values for final attribute were found",innerex);
+ }
+ else if(reader.Name == "id")
+ {
+ ctype.Id = reader.Value;
+ }
+ else if(reader.Name == "mixed")
+ {
+ ctype.isMixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h,reader.Value + " is invalid value for mixed",innerex);
+ }
+ else if(reader.Name == "name")
+ {
+ ctype.Name = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for complexType",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,ctype);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return ctype;
+
+ //Content: 1. annotation?,
+ // 2. simpleContent | 2. complexContent |
+ // (3.(group | all | choice | sequence)?, (4.(attribute | attributeGroup)*, 5.anyAttribute?)))
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaComplexType.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ ctype.Annotation = annotation;
+ continue;
+ }
+ if(level <=2)
+ {
+ if(reader.LocalName == "simpleContent")
+ {
+ level = 6;
+ XmlSchemaSimpleContent simple = XmlSchemaSimpleContent.Read(reader,h);
+ if(simple != null)
+ ctype.ContentModel = simple;
+ continue;
+ }
+ if(reader.LocalName == "complexContent")
+ {
+ level = 6;
+ XmlSchemaComplexContent complex = XmlSchemaComplexContent.Read(reader,h);
+ if(complex != null)
+ ctype.contentModel = complex;
+ continue;
+ }
+ }
+ if(level <= 3)
+ {
+ if(reader.LocalName == "group")
+ {
+ level = 4;
+ XmlSchemaGroupRef group = XmlSchemaGroupRef.Read(reader,h);
+ if(group != null)
+ ctype.particle = group;
+ continue;
+ }
+ if(reader.LocalName == "all")
+ {
+ level = 4;
+ XmlSchemaAll all = XmlSchemaAll.Read(reader,h);
+ if(all != null)
+ ctype.particle = all;
+ continue;
+ }
+ if(reader.LocalName == "choice")
+ {
+ level = 4;
+ XmlSchemaChoice choice = XmlSchemaChoice.Read(reader,h);
+ if(choice != null)
+ ctype.particle = choice;
+ continue;
+ }
+ if(reader.LocalName == "sequence")
+ {
+ level = 4;
+ XmlSchemaSequence sequence = XmlSchemaSequence.Read(reader,h);
+ if(sequence != null)
+ ctype.particle = sequence;
+ continue;
+ }
+ }
+ if(level <= 4)
+ {
+ if(reader.LocalName == "attribute")
+ {
+ level = 4;
+ XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader,h);
+ if(attr != null)
+ ctype.Attributes.Add(attr);
+ continue;
+ }
+ if(reader.LocalName == "attributeGroup")
+ {
+ level = 4;
+ XmlSchemaAttributeGroupRef attr = XmlSchemaAttributeGroupRef.Read(reader,h);
+ if(attr != null)
+ ctype.attributes.Add(attr);
+ continue;
+ }
+ }
+ if(level <= 5 && reader.LocalName == "anyAttribute")
+ {
+ level = 6;
+ XmlSchemaAnyAttribute anyattr = XmlSchemaAnyAttribute.Read(reader,h);
+ if(anyattr != null)
+ ctype.AnyAttribute = anyattr;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return ctype;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaContent.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaContent.cs
new file mode 100755
index 00000000000..ac32916437a
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaContent.cs
@@ -0,0 +1,15 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaContent.
+ /// </summary>
+ public abstract class XmlSchemaContent : XmlSchemaAnnotated
+ {
+ protected XmlSchemaContent()
+ {}
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaContentModel.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaContentModel.cs
new file mode 100755
index 00000000000..994dd211de5
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaContentModel.cs
@@ -0,0 +1,19 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaContentModel.
+ /// </summary>
+ public abstract class XmlSchemaContentModel : XmlSchemaAnnotated
+ {
+ protected XmlSchemaContentModel()
+ {
+ }
+ [XmlIgnore]
+ public abstract XmlSchemaContent Content {get; set;}
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaContentProcessing.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaContentProcessing.cs
new file mode 100755
index 00000000000..2cd60231a03
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaContentProcessing.cs
@@ -0,0 +1,22 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaContentProcessing.
+ /// </summary>
+ public enum XmlSchemaContentProcessing
+ {
+ [XmlIgnore]
+ None = 0,
+ [XmlEnum("skip")]
+ Skip = 1,
+ [XmlEnum("lax")]
+ Lax = 2,
+ [XmlEnum("strict")]
+ Strict = 3,
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaContentType.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaContentType.cs
new file mode 100755
index 00000000000..dc7bda2433e
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaContentType.cs
@@ -0,0 +1,17 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaContentType.
+ /// </summary>
+ public enum XmlSchemaContentType
+ {
+ TextOnly = 0,
+ Empty = 1,
+ ElementOnly = 2,
+ Mixed = 3,
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaDatatype.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaDatatype.cs
new file mode 100755
index 00000000000..778a9ef39ec
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaDatatype.cs
@@ -0,0 +1,30 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaDatatype.
+ /// </summary>
+ public abstract class XmlSchemaDatatype
+ {
+ protected XmlSchemaDatatype()
+ {
+ }
+
+ public abstract XmlTokenizedType TokenizedType { get; }
+ public abstract Type ValueType { get; }
+
+ // Methods
+ public abstract object ParseValue(string s,
+ XmlNameTable nameTable, XmlNamespaceManager nsmgr);
+
+ //TODO: This should return appropriate inbuilt type
+ internal static XmlSchemaDatatype GetType(XmlQualifiedName qname)
+ {
+ return null;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaDerivationMethod.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaDerivationMethod.cs
new file mode 100755
index 00000000000..fcd63c899fe
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaDerivationMethod.cs
@@ -0,0 +1,31 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaDerivationMethod.
+ /// </summary>
+ [Flags]
+ public enum XmlSchemaDerivationMethod
+ {
+ [XmlEnum("")]
+ Empty = 0x00000000,
+ [XmlEnum("substitution")]
+ Substitution= 0x00000001,
+ [XmlEnum("extension")]
+ Extension = 0x00000002,
+ [XmlEnum("restriction")]
+ Restriction = 0x00000004,
+ [XmlEnum("list")]
+ List = 0x00000008,
+ [XmlEnum("union")]
+ Union = 0x00000010,
+ [XmlEnum("#all")]
+ All = 0x000000FF,
+ [XmlIgnore]
+ None = 0x00000100,
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaDocumentation.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaDocumentation.cs
new file mode 100755
index 00000000000..7788d6d685b
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaDocumentation.cs
@@ -0,0 +1,104 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaDocumentation.
+ /// </summary>
+ public class XmlSchemaDocumentation : XmlSchemaObject
+ {
+ private string language;
+ private XmlNode[] markup;
+ private string source;
+
+ public XmlSchemaDocumentation()
+ {
+ }
+
+ [XmlAnyElement]
+ [XmlText]
+ public XmlNode[] Markup
+ {
+ get{ return markup; }
+ set{ markup = value; }
+ }
+
+ [System.Xml.Serialization.XmlAttribute("source")]
+ public string Source
+ {
+ get{ return source; }
+ set{ source = value; }
+ }
+
+ [System.Xml.Serialization.XmlAttribute("xml:lang")]
+ public string Language
+ {
+ get{ return language; }
+ set{ language = value; }
+ }
+
+ //<documentation
+ // source = anyURI
+ // xml:lang = language>
+ // Content: ({any})*
+ //</documentation>
+ internal static XmlSchemaDocumentation Read(XmlSchemaReader reader, ValidationEventHandler h, out bool skip)
+ {
+ skip = false;
+ XmlSchemaDocumentation doc = new XmlSchemaDocumentation();
+
+ reader.MoveToElement();
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != "documentation")
+ {
+ error(h,"Should not happen :1: XmlSchemaDocumentation.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ doc.LineNumber = reader.LineNumber;
+ doc.LinePosition = reader.LinePosition;
+ doc.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "source")
+ {
+ doc.source = reader.Value;
+ }
+ else if(reader.Name == "xml:lang")
+ {
+ doc.language = reader.Value;
+ }
+ else
+ {
+ error(h,reader.Name + " is not a valid attribute for documentation",null);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return doc;
+
+ //Content {any}*
+ XmlDocument xmldoc = new XmlDocument();
+ xmldoc.AppendChild(xmldoc.ReadNode(reader));
+ XmlNode root = xmldoc.FirstChild;
+ if(root != null && root.ChildNodes != null)
+ {
+ doc.Markup = new XmlNode[root.ChildNodes.Count];
+ for(int i=0;i<root.ChildNodes.Count;i++)
+ {
+ doc.Markup[i] = root.ChildNodes[i];
+ }
+ }
+ if(reader.NodeType == XmlNodeType.Element || reader.NodeType == XmlNodeType.EndElement)
+ skip = true;
+
+ return doc;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaElement.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaElement.cs
new file mode 100755
index 00000000000..5f95fd66ef2
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaElement.cs
@@ -0,0 +1,625 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+using System.ComponentModel;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaElement.
+ /// </summary>
+ public class XmlSchemaElement : XmlSchemaParticle
+ {
+ private XmlSchemaDerivationMethod block;
+ private XmlSchemaDerivationMethod blockResolved;
+ private XmlSchemaObjectCollection constraints;
+ private string defaultValue;
+ private object elementType;
+ private XmlSchemaDerivationMethod final;
+ private XmlSchemaDerivationMethod finalResolved;
+ private string fixedValue;
+ private XmlSchemaForm form;
+ private bool isAbstract;
+ private bool isNillable;
+ private string name;
+ private XmlQualifiedName qName;
+ private XmlQualifiedName refName;
+ private XmlSchemaType schemaType;
+ private XmlQualifiedName schemaTypeName;
+ private XmlQualifiedName substitutionGroup;
+ internal bool parentIsSchema = false;
+ private string targetNamespace;
+ private string hash;
+
+ private static string xmlname = "element";
+
+ public XmlSchemaElement()
+ {
+ block = XmlSchemaDerivationMethod.None;
+ final = XmlSchemaDerivationMethod.None;
+ constraints = new XmlSchemaObjectCollection();
+ qName = XmlQualifiedName.Empty;
+ refName = XmlQualifiedName.Empty;
+ schemaTypeName = XmlQualifiedName.Empty;
+ substitutionGroup = XmlQualifiedName.Empty;
+ substitutionGroup = XmlQualifiedName.Empty;
+ }
+
+ #region Attributes
+
+ [DefaultValue(false)]
+ [System.Xml.Serialization.XmlAttribute("abstract")]
+ public bool IsAbstract
+ {
+ get{ return isAbstract; }
+ set{ isAbstract = value; }
+ }
+
+ [DefaultValue(XmlSchemaDerivationMethod.None)]
+ [System.Xml.Serialization.XmlAttribute("block")]
+ public XmlSchemaDerivationMethod Block
+ {
+ get{ return block; }
+ set{ block = value; }
+ }
+
+ [DefaultValue(null)]
+ [System.Xml.Serialization.XmlAttribute("default")]
+ public string DefaultValue
+ {
+ get{ return defaultValue; }
+ set{ defaultValue = value; }
+ }
+
+ [DefaultValue(XmlSchemaDerivationMethod.None)]
+ [System.Xml.Serialization.XmlAttribute("final")]
+ public XmlSchemaDerivationMethod Final
+ {
+ get{ return final; }
+ set{ final = value; }
+ }
+
+ [DefaultValue(null)]
+ [System.Xml.Serialization.XmlAttribute("fixed")]
+ public string FixedValue
+ {
+ get{ return fixedValue; }
+ set{ fixedValue = value; }
+ }
+ [DefaultValue(XmlSchemaForm.None)]
+ [System.Xml.Serialization.XmlAttribute("form")]
+ public XmlSchemaForm Form
+ {
+ get{ return form; }
+ set{ form = value; }
+ }
+
+ [DefaultValue(null)]
+ [System.Xml.Serialization.XmlAttribute("name")]
+ public string Name
+ {
+ get{ return name; }
+ set{ name = value; }
+ }
+
+ [DefaultValue(false)]
+ [System.Xml.Serialization.XmlAttribute("nillable")]
+ public bool IsNillable
+ {
+ get{ return isNillable; }
+ set{ isNillable = value; }
+ }
+
+ [System.Xml.Serialization.XmlAttribute("ref")]
+ public XmlQualifiedName RefName
+ {
+ get{ return refName; }
+ set{ refName = value;}
+ }
+
+ [System.Xml.Serialization.XmlAttribute("substitutionGroup")]
+ public XmlQualifiedName SubstitutionGroup
+ {
+ get{ return substitutionGroup; }
+ set{ substitutionGroup = value; }
+ }
+
+ [System.Xml.Serialization.XmlAttribute("type")]
+ public XmlQualifiedName SchemaTypeName
+ {
+ get{ return schemaTypeName; }
+ set{ schemaTypeName = value; }
+ }
+
+ [XmlElement("simpleType",typeof(XmlSchemaSimpleType),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("complexType",typeof(XmlSchemaComplexType),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaType SchemaType
+ {
+ get{ return schemaType; }
+ set{ schemaType = value; }
+ }
+
+ [XmlElement("unique",typeof(XmlSchemaUnique),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("key",typeof(XmlSchemaKey),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("keyref",typeof(XmlSchemaKeyref),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection Constraints
+ {
+ get{ return constraints; }
+ }
+
+ [XmlIgnore]
+ public XmlQualifiedName QualifiedName
+ {
+ get{ return qName; }
+ }
+
+ [XmlIgnore]
+ public object ElementType
+ {
+ get{ return elementType; }
+ }
+
+ [XmlIgnore]
+ public XmlSchemaDerivationMethod BlockResolved
+ {
+ get{ return blockResolved; }
+ }
+
+ [XmlIgnore]
+ public XmlSchemaDerivationMethod FinalResolved
+ {
+ get{ return finalResolved; }
+ }
+
+ #endregion
+
+ /// <remarks>
+ /// a) If Element has parent as schema:
+ /// 1. name must be present and of type NCName.
+ /// 2. ref must be absent
+ /// 3. form must be absent
+ /// 4. minOccurs must be absent
+ /// 5. maxOccurs must be absent
+ /// b) If Element has parent is not schema and ref is absent
+ /// 1. name must be present and of type NCName.
+ /// 2. if form equals qualified or form is absent and schema's formdefault is qualifed,
+ /// targetNamespace is schema's targetnamespace else empty.
+ /// 3. type and either <simpleType> or <complexType> are mutually exclusive
+ /// 4. default and fixed must not both be present.
+ /// 5. substitutiongroup must be absent
+ /// 6. final must be absent
+ /// 7. abstract must be absent
+ /// c) if the parent is not schema and ref is set
+ /// 1. name must not be present
+ /// 2. all of <simpleType>,<complexType>, <key>, <keyref>, <unique>, nillable,
+ /// default, fixed, form, block and type, must be absent.
+ /// 3. substitutiongroup is prohibited
+ /// 4. final is prohibited
+ /// 5. abstract is prohibited
+ /// 6. default and fixed must not both be present.(Actually both are absent)
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ if(this.defaultValue != null && this.fixedValue != null)
+ error(h,"both default and fixed can't be present");
+
+ if(parentIsSchema)
+ {
+ if(this.refName != null && !RefName.IsEmpty)
+ error(h,"ref must be absent");
+
+ if(this.name == null) //b1
+ error(h,"Required attribute name must be present");
+ else if(!XmlSchemaUtil.CheckNCName(this.name)) // b1.2
+ error(h,"attribute name must be NCName");
+ else
+ this.qName = new XmlQualifiedName(this.name, info.TargetNamespace);
+
+ if(form != XmlSchemaForm.None)
+ error(h,"form must be absent");
+ if(MinOccursString != null)
+ error(h,"minOccurs must be absent");
+ if(MaxOccursString != null)
+ error(h,"maxOccurs must be absent");
+
+ XmlSchemaDerivationMethod allfinal = (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction);
+ if(final == XmlSchemaDerivationMethod.All)
+ finalResolved = allfinal;
+ else if(final == XmlSchemaDerivationMethod.None)
+ finalResolved = info.BlockDefault & allfinal;
+ else
+ {
+ if((final & ~allfinal) != 0)
+ warn(h,"some values for final are invalid in this context");
+ finalResolved = final & allfinal;
+ }
+
+ XmlSchemaDerivationMethod allblock = XmlSchemaDerivationMethod.Extension |
+ XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Substitution;
+
+ if(block == XmlSchemaDerivationMethod.All)
+ blockResolved = allblock;
+ else if(block == XmlSchemaDerivationMethod.None)
+ blockResolved = info.BlockDefault & allblock;
+ else
+ {
+ if((block & ~allblock) != 0)
+ warn(h,"Some of the values for block are invalid in this context");
+ blockResolved = block & allblock;
+ }
+
+ if(schemaType != null && schemaTypeName != null && !schemaTypeName.IsEmpty)
+ {
+ error(h,"both schemaType and content can't be present");
+ }
+
+ //Even if both are present, read both of them.
+ if(schemaType != null)
+ {
+ if(schemaType is XmlSchemaSimpleType)
+ {
+ errorCount += ((XmlSchemaSimpleType)schemaType).Compile(h,info);
+ }
+ else if(schemaType is XmlSchemaComplexType)
+ {
+ errorCount += ((XmlSchemaComplexType)schemaType).Compile(h,info);
+ }
+ else
+ error(h,"only simpletype or complextype is allowed");
+ }
+ if(schemaTypeName != null && !schemaTypeName.IsEmpty)
+ {
+ if(!XmlSchemaUtil.CheckQName(SchemaTypeName))
+ error(h,"SchemaTypeName must be an XmlQualifiedName");
+ }
+ if(SubstitutionGroup != null && !SubstitutionGroup.IsEmpty)
+ {
+ if(!XmlSchemaUtil.CheckQName(SubstitutionGroup))
+ error(h,"SubstitutionGroup must be a valid XmlQualifiedName");
+ }
+
+ foreach(XmlSchemaObject obj in constraints)
+ {
+ if(obj is XmlSchemaUnique)
+ errorCount += ((XmlSchemaUnique)obj).Compile(h,info);
+ else if(obj is XmlSchemaKey)
+ errorCount += ((XmlSchemaKey)obj).Compile(h,info);
+ else if(obj is XmlSchemaKeyref)
+ errorCount += ((XmlSchemaKeyref)obj).Compile(h,info);
+ }
+
+
+ }
+ else
+ {
+ if(substitutionGroup != null && !substitutionGroup.IsEmpty)
+ error(h,"substitutionGroup must be absent");
+ if(final != XmlSchemaDerivationMethod.None)
+ error(h,"final must be absent");
+ if(isAbstract)
+ error(h,"abstract must be absent");
+
+ //FIXME: Should we reset the values
+ if(MinOccurs > MaxOccurs)
+ error(h,"minOccurs must be less than or equal to maxOccurs");
+
+ if(refName == null || RefName.IsEmpty)
+ {
+ if(form == XmlSchemaForm.Qualified || (form == XmlSchemaForm.None && info.ElementFormDefault == XmlSchemaForm.Qualified))
+ this.targetNamespace = info.TargetNamespace;
+ else
+ this.targetNamespace = string.Empty;
+
+ if(this.name == null) //b1
+ error(h,"Required attribute name must be present");
+ else if(!XmlSchemaUtil.CheckNCName(this.name)) // b1.2
+ error(h,"attribute name must be NCName");
+ else
+ this.qName = new XmlQualifiedName(this.name, this.targetNamespace);
+
+ XmlSchemaDerivationMethod allblock = XmlSchemaDerivationMethod.Extension |
+ XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Substitution;
+
+ if(block == XmlSchemaDerivationMethod.All)
+ blockResolved = allblock;
+ else if(block == XmlSchemaDerivationMethod.None)
+ blockResolved = info.BlockDefault & allblock;
+ else
+ {
+ if((block & ~allblock) != 0)
+ warn(h,"Some of the values for block are invalid in this context");
+ blockResolved = block & allblock;
+ }
+
+ if(schemaType != null && schemaTypeName != null && !schemaTypeName.IsEmpty)
+ {
+ error(h,"both schemaType and content can't be present");
+ }
+
+ //Even if both are present, read both of them.
+ if(schemaType != null)
+ {
+ if(schemaType is XmlSchemaSimpleType)
+ {
+ errorCount += ((XmlSchemaSimpleType)schemaType).Compile(h,info);
+ }
+ else if(schemaType is XmlSchemaComplexType)
+ {
+ errorCount += ((XmlSchemaComplexType)schemaType).Compile(h,info);
+ }
+ else
+ error(h,"only simpletype or complextype is allowed");
+ }
+ if(schemaTypeName != null && !schemaTypeName.IsEmpty)
+ {
+ if(!XmlSchemaUtil.CheckQName(SchemaTypeName))
+ error(h,"SchemaTypeName must be an XmlQualifiedName");
+ }
+ if(SubstitutionGroup != null && !SubstitutionGroup.IsEmpty)
+ {
+ if(!XmlSchemaUtil.CheckQName(SubstitutionGroup))
+ error(h,"SubstitutionGroup must be a valid XmlQualifiedName");
+ }
+
+ foreach(XmlSchemaObject obj in constraints)
+ {
+ if(obj is XmlSchemaUnique)
+ errorCount += ((XmlSchemaUnique)obj).Compile(h,info);
+ else if(obj is XmlSchemaKey)
+ errorCount += ((XmlSchemaKey)obj).Compile(h,info);
+ else if(obj is XmlSchemaKeyref)
+ errorCount += ((XmlSchemaKeyref)obj).Compile(h,info);
+ }
+ }
+ else
+ {
+ if(!XmlSchemaUtil.CheckQName(RefName))
+ error(h,"RefName must be a XmlQualifiedName");
+
+ if(name != null)
+ error(h,"name must not be present when ref is present");
+ if(Constraints.Count != 0)
+ error(h,"key, keyref and unique must be absent");
+ if(isNillable)
+ error(h,"nillable must be absent");
+ if(defaultValue != null)
+ error(h,"default must be absent");
+ if(fixedValue != null)
+ error(h,"fixed must be null");
+ if(form != XmlSchemaForm.None)
+ error(h,"form must be absent");
+ if(block != XmlSchemaDerivationMethod.None)
+ error(h,"block must be absent");
+ if(schemaTypeName != null && !schemaTypeName.IsEmpty)
+ error(h,"type must be absent");
+ if(SchemaType != null)
+ error(h,"simpleType or complexType must be absent");
+ }
+ }
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+
+ //<element
+ // abstract = boolean : false
+ // block = (#all | List of (extension | restriction | substitution))
+ // default = string
+ // final = (#all | List of (extension | restriction))
+ // fixed = string
+ // form = (qualified | unqualified)
+ // id = ID
+ // maxOccurs = (nonNegativeInteger | unbounded) : 1
+ // minOccurs = nonNegativeInteger : 1
+ // name = NCName
+ // nillable = boolean : false
+ // ref = QName
+ // substitutionGroup = QName
+ // type = QName
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, ((simpleType | complexType)?, (unique | key | keyref)*))
+ //</element>
+
+ internal static XmlSchemaElement Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaElement element = new XmlSchemaElement();
+ Exception innerex;
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaElement.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ element.LineNumber = reader.LineNumber;
+ element.LinePosition = reader.LinePosition;
+ element.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "abstract")
+ {
+ element.IsAbstract = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h,reader.Value + " is invalid value for abstract",innerex);
+ }
+ else if(reader.Name == "block")
+ {
+ element.block = XmlSchemaUtil.ReadDerivationAttribute(reader,out innerex, "block");
+ if(innerex != null)
+ warn(h,"some invalid values for block attribute were found",innerex);
+ }
+ else if(reader.Name == "default")
+ {
+ element.defaultValue = reader.Value;
+ }
+ else if(reader.Name == "final")
+ {
+ element.Final = XmlSchemaUtil.ReadDerivationAttribute(reader,out innerex, "block");
+ if(innerex != null)
+ warn(h,"some invalid values for final attribute were found",innerex);
+ }
+ else if(reader.Name == "fixed")
+ {
+ element.fixedValue = reader.Value;
+ }
+ else if(reader.Name == "form")
+ {
+ element.form = XmlSchemaUtil.ReadFormAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h,reader.Value + " is an invalid value for form attribute",innerex);
+ }
+ else if(reader.Name == "id")
+ {
+ element.Id = reader.Value;
+ }
+ else if(reader.Name == "maxOccurs")
+ {
+ try
+ {
+ element.MaxOccursString = reader.Value;
+ }
+ catch(Exception e)
+ {
+ error(h,reader.Value + " is an invalid value for maxOccurs",e);
+ }
+ }
+ else if(reader.Name == "minOccurs")
+ {
+ try
+ {
+ element.MinOccursString = reader.Value;
+ }
+ catch(Exception e)
+ {
+ error(h,reader.Value + " is an invalid value for minOccurs",e);
+ }
+ }
+ else if(reader.Name == "name")
+ {
+ element.Name = reader.Value;
+ }
+ else if(reader.Name == "nillable")
+ {
+ element.IsNillable = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h,reader.Value + "is not a valid value for nillable",innerex);
+ }
+ else if(reader.Name == "ref")
+ {
+ element.refName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for ref attribute",innerex);
+ }
+ else if(reader.Name == "substitutionGroup")
+ {
+ element.substitutionGroup = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for substitutionGroup attribute",innerex);
+ }
+ else if(reader.Name == "type")
+ {
+ element.SchemaTypeName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for type attribute",innerex);
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for element",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,element);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return element;
+
+ // Content: annotation?,
+ // (simpleType | complexType)?,
+ // (unique | key | keyref)*
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaElement.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ element.Annotation = annotation;
+ continue;
+ }
+ if(level <= 2)
+ {
+ if(reader.LocalName == "simpleType")
+ {
+ level = 3;
+ XmlSchemaSimpleType simple = XmlSchemaSimpleType.Read(reader,h);
+ if(simple != null)
+ element.SchemaType = simple;
+ continue;
+ }
+ if(reader.LocalName == "complexType")
+ {
+ level = 3;
+ XmlSchemaComplexType complex = XmlSchemaComplexType.Read(reader,h);
+ if(complex != null)
+ {
+ element.SchemaType = complex;
+ }
+ continue;
+ }
+ }
+ if(level <= 3)
+ {
+ if(reader.LocalName == "unique")
+ {
+ level = 3;
+ XmlSchemaUnique unique = XmlSchemaUnique.Read(reader,h);
+ if(unique != null)
+ element.constraints.Add(unique);
+ continue;
+ }
+ else if(reader.LocalName == "key")
+ {
+ level = 3;
+ XmlSchemaKey key = XmlSchemaKey.Read(reader,h);
+ if(key != null)
+ element.constraints.Add(key);
+ continue;
+ }
+ else if(reader.LocalName == "keyref")
+ {
+ level = 3;
+ XmlSchemaKeyref keyref = XmlSchemaKeyref.Read(reader,h);
+ if(keyref != null)
+ element.constraints.Add(keyref);
+ continue;
+ }
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return element;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaEnumerationFacet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaEnumerationFacet.cs
new file mode 100755
index 00000000000..512b3c7d70a
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaEnumerationFacet.cs
@@ -0,0 +1,87 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaEnumerationFacet.
+ /// </summary>
+ public class XmlSchemaEnumerationFacet : XmlSchemaFacet
+ {
+ private static string xmlname = "enumeration";
+ public XmlSchemaEnumerationFacet()
+ {
+ }
+
+ //<enumeration
+ // id = ID
+ // value = anySimpleType
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</enumeration>
+ internal static XmlSchemaEnumerationFacet Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaEnumerationFacet enumeration = new XmlSchemaEnumerationFacet();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaEnumerationFacet.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ enumeration.LineNumber = reader.LineNumber;
+ enumeration.LinePosition = reader.LinePosition;
+ enumeration.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ enumeration.Id = reader.Value;
+ }
+ else if(reader.Name == "value")
+ {
+ enumeration.Value = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,enumeration);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return enumeration;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaEnumerationFacet.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ enumeration.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return enumeration;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaException.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaException.cs
new file mode 100755
index 00000000000..01ea8721d3b
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaException.cs
@@ -0,0 +1,94 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Runtime.Serialization;
+
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaException.
+ /// </summary>
+ [Serializable]
+ public class XmlSchemaException : System.SystemException
+ {
+ //fields
+ private int lineNumber;
+ private int linePosition;
+ private XmlSchemaObject sourceObj;
+ private string sourceUri;
+
+ protected XmlSchemaException(SerializationInfo info, StreamingContext context)
+ : base (info, context)
+ {
+ this.lineNumber = info.GetInt32 ("lineNumber");
+ this.linePosition = info.GetInt32 ("linePosition");
+ this.sourceUri = info.GetString ("sourceUri");
+ this.sourceObj = info.GetValue ("sourceObj", typeof (XmlSchemaObject)) as XmlSchemaObject;
+ }
+
+
+ internal XmlSchemaException(string message, int lineNumber, int linePosition,
+ XmlSchemaObject sourceObject, string sourceUri, Exception innerException)
+ : base(message, innerException)
+ {
+ this.lineNumber = lineNumber;
+ this.linePosition = linePosition;
+ this.sourceObj = sourceObject;
+ this.sourceUri = sourceUri;
+ }
+ internal XmlSchemaException(string message, XmlSchemaObject sourceObject,
+ Exception innerException)
+ : base(message, innerException)
+ {
+ this.lineNumber = sourceObject.LineNumber;
+ this.linePosition = sourceObject.LinePosition;
+ this.sourceObj = sourceObject;
+ this.sourceUri = sourceObject.SourceUri;
+ }
+
+ public XmlSchemaException(string message, Exception innerException)
+ : base(message,innerException){}
+
+ // Properties
+ public int LineNumber
+ {
+ get{ return this.lineNumber;}
+ }
+ public int LinePosition
+ {
+ get{ return this.linePosition;}
+ }
+ public XmlSchemaObject SourceSchemaObject
+ {
+ get{ return this.sourceObj; }
+ }
+ public string SourceUri
+ {
+ get{ return this.sourceUri; }
+ }
+
+ public override string Message
+ {
+ get {
+ string msg = base.Message;
+ if (sourceUri != null)
+ msg = String.Format ("XmlSchema error: {0}\n" +
+ "URI: {1}, line {2}, position {3}",
+ msg, sourceUri, lineNumber, linePosition);
+
+ return msg;
+ }
+ }
+
+ // Methods
+ public override void GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ base.GetObjectData (info, context);
+ info.AddValue ("lineNumber", lineNumber);
+ info.AddValue ("linePosition", linePosition);
+ info.AddValue ("sourceUri", sourceUri);
+ info.AddValue ("sourceObj", sourceObj);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaExternal.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaExternal.cs
new file mode 100755
index 00000000000..1f691587ea1
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaExternal.cs
@@ -0,0 +1,62 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+using System.Collections;
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaExternal.
+ /// </summary>
+ public abstract class XmlSchemaExternal : XmlSchemaObject
+ {
+ private string id;
+ private XmlSchema schema;
+ private string location;
+ private XmlAttribute[] unhandledAttributes;
+
+ protected XmlSchemaExternal()
+ {}
+
+ [System.Xml.Serialization.XmlAttribute("schemaLocation")]
+ public string SchemaLocation
+ {
+ get{ return location; }
+ set{ location = value; }
+ }
+
+ [XmlIgnore]
+ public XmlSchema Schema
+ {
+ get{ return schema; }
+ set{ schema = value; }
+ }
+
+ [System.Xml.Serialization.XmlAttribute("id")]
+ public string Id
+ {
+ get{ return id; }
+ set{ id = value; }
+ }
+
+ [XmlAnyAttribute]
+ public XmlAttribute[] UnhandledAttributes
+ {
+ get
+ {
+ if(unhandledAttributeList != null)
+ {
+ unhandledAttributes = (XmlAttribute[]) unhandledAttributeList.ToArray(typeof(XmlAttribute));
+ unhandledAttributeList = null;
+ }
+ return unhandledAttributes;
+ }
+ set
+ {
+ unhandledAttributes = value;
+ unhandledAttributeList = null;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaFacet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaFacet.cs
new file mode 100755
index 00000000000..076bc74486d
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaFacet.cs
@@ -0,0 +1,37 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+using System.ComponentModel;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaFacet.
+ /// </summary>
+ public abstract class XmlSchemaFacet : XmlSchemaAnnotated
+ {
+ private bool isFixed;
+ private string val;
+
+ protected XmlSchemaFacet()
+ {
+ }
+
+ [System.Xml.Serialization.XmlAttribute("value")]
+ public string Value
+ {
+ get{ return val; }
+ set{ val = value; }
+ }
+
+ [DefaultValue(false)]
+ [System.Xml.Serialization.XmlAttribute("fixed")]
+ public virtual bool IsFixed
+ {
+ get{ return isFixed; }
+ set{ isFixed = value; }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaForm.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaForm.cs
new file mode 100755
index 00000000000..8efb7e3d548
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaForm.cs
@@ -0,0 +1,19 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaForm.
+ /// </summary>
+ public enum XmlSchemaForm
+ {
+ [XmlIgnore]
+ None = 0x00000000,
+ [XmlEnum("qualified")]
+ Qualified = 0x00000001,
+ [XmlEnum("unqualified")]
+ Unqualified = 0x00000002,
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaFractionDigitsFacet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaFractionDigitsFacet.cs
new file mode 100755
index 00000000000..319d19fd8e3
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaFractionDigitsFacet.cs
@@ -0,0 +1,98 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaFractionDigitsFacet.
+ /// </summary>
+ public class XmlSchemaFractionDigitsFacet : XmlSchemaNumericFacet
+ {
+ private static string xmlname = "fractionDigits";
+
+ public XmlSchemaFractionDigitsFacet()
+ {
+ }
+
+ //<fractionDigits
+ // fixed = boolean : false
+ // id = ID
+ // value = nonNegativeInteger
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</fractionDigits>
+ internal static XmlSchemaFractionDigitsFacet Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaFractionDigitsFacet fraction = new XmlSchemaFractionDigitsFacet();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaFractionDigitsFacet.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ fraction.LineNumber = reader.LineNumber;
+ fraction.LinePosition = reader.LinePosition;
+ fraction.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ fraction.Id = reader.Value;
+ }
+ else if(reader.Name == "fixed")
+ {
+ Exception innerex;
+ fraction.IsFixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for fixed attribute",innerex);
+ }
+ else if(reader.Name == "value")
+ {
+ fraction.Value = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,fraction);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return fraction;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaFractionDigitsFacet.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ fraction.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return fraction;
+ }
+
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroup.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroup.cs
new file mode 100755
index 00000000000..9848d6ad319
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroup.cs
@@ -0,0 +1,195 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// refers to the named group
+ /// </summary>
+ public class XmlSchemaGroup : XmlSchemaAnnotated
+ {
+ private string name;
+ private XmlSchemaGroupBase particle;
+ private XmlQualifiedName qualifiedName;
+
+ private static string xmlname = "group";
+
+ public XmlSchemaGroup()
+ {
+ }
+
+ [System.Xml.Serialization.XmlAttribute("name")]
+ public string Name
+ {
+ get{ return name; }
+ set{ name = value; }
+ }
+
+ [XmlElement("all",typeof(XmlSchemaAll),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("choice",typeof(XmlSchemaChoice),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("sequence",typeof(XmlSchemaSequence),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaGroupBase Particle
+ {
+ get{ return particle; }
+ set{ particle = value; }
+ }
+
+ [XmlIgnore]
+ internal XmlQualifiedName QualifiedName
+ {
+ get{ return qualifiedName;}
+ }
+
+ // 1. name must be present
+ // 2. MinOccurs & MaxOccurs of the Particle must be absent
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ if(Name == null)
+ error(h,"Required attribute name must be present");
+ else if(!XmlSchemaUtil.CheckNCName(this.name))
+ error(h,"attribute name must be NCName");
+ else
+ qualifiedName = new XmlQualifiedName(Name,info.TargetNamespace);
+
+ if(Particle == null)
+ {
+ error(h,"Particle is required");
+ }
+ else
+ {
+ if(Particle.MaxOccursString != null)
+ Particle.error(h,"MaxOccurs must not be present when the Particle is a child of Group");
+ if(Particle.MinOccursString != null)
+ Particle.error(h,"MinOccurs must not be present when the Particle is a child of Group");
+
+ if(Particle is XmlSchemaChoice)
+ {
+ errorCount += ((XmlSchemaChoice)Particle).Compile(h,info);
+ }
+ else if(Particle is XmlSchemaSequence)
+ {
+ errorCount += ((XmlSchemaSequence)Particle).Compile(h,info);
+ }
+ else if(Particle is XmlSchemaAll)
+ {
+ errorCount += ((XmlSchemaAll)Particle).Compile(h,info);
+ }
+ else
+ {
+ error(h,"only all,choice or sequence are allowed");
+ }
+ }
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+
+ //From the Errata
+ //<group
+ // id = ID
+ // name = NCName
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, (all | choice | sequence)?)
+ //</group>
+ internal static XmlSchemaGroup Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaGroup group = new XmlSchemaGroup();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaGroup.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ group.LineNumber = reader.LineNumber;
+ group.LinePosition = reader.LinePosition;
+ group.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ group.Id = reader.Value;
+ }
+ else if(reader.Name == "name")
+ {
+ group.name = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for group",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,group);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return group;
+
+// Content: (annotation?, (all | choice | sequence)?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaGroup.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ group.Annotation = annotation;
+ continue;
+ }
+ if(level <= 2)
+ {
+ if(reader.LocalName == "all")
+ {
+ level = 3;
+ XmlSchemaAll all = XmlSchemaAll.Read(reader,h);
+ if(all != null)
+ group.Particle = all;
+ continue;
+ }
+ if(reader.LocalName == "choice")
+ {
+ level = 3;
+ XmlSchemaChoice choice = XmlSchemaChoice.Read(reader,h);
+ if(choice != null)
+ group.Particle = choice;
+ continue;
+ }
+ if(reader.LocalName == "sequence")
+ {
+ level = 3;
+ XmlSchemaSequence sequence = XmlSchemaSequence.Read(reader,h);
+ if(sequence != null)
+ group.Particle = sequence;
+ continue;
+ }
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return group;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroupBase.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroupBase.cs
new file mode 100755
index 00000000000..152e3b09f57
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroupBase.cs
@@ -0,0 +1,20 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaGroupBase.
+ /// </summary>
+ public abstract class XmlSchemaGroupBase : XmlSchemaParticle
+ {
+ protected XmlSchemaGroupBase()
+ {
+ }
+
+ [XmlIgnore]
+ public abstract XmlSchemaObjectCollection Items { get; }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroupRef.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroupRef.cs
new file mode 100755
index 00000000000..31ceaf8e864
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaGroupRef.cs
@@ -0,0 +1,156 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaGroupRef.
+ /// </summary>
+ public class XmlSchemaGroupRef : XmlSchemaParticle
+ {
+ private XmlSchemaGroupBase particle;
+ private XmlQualifiedName refName;
+ private static string xmlname = "group";
+
+ public XmlSchemaGroupRef()
+ {
+ refName = XmlQualifiedName.Empty;
+ }
+ [System.Xml.Serialization.XmlAttribute("ref")]
+ public XmlQualifiedName RefName
+ {
+ get{ return refName; }
+ set{ refName = value; }
+ }
+ [XmlIgnore]
+ public XmlSchemaGroupBase Particle
+ {
+ get{ return particle; }
+ }
+ /// <remarks>
+ /// 1. RefName must be present
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ //FIXME: Should we reset the values
+ if(MinOccurs > MaxOccurs)
+ error(h,"minOccurs must be less than or equal to maxOccurs");
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ if(refName == null || refName.IsEmpty)
+ {
+ error(h,"ref must be present");
+ }
+ else if(!XmlSchemaUtil.CheckQName(RefName))
+ error(h, "RefName must be a valid XmlQualifiedName");
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+
+ // <group
+ // id = ID
+ // ref = QName
+ // minOccurs = ? : 1
+ // maxOccurs = ? : 1>
+ // Content: (annotation?)
+ // </group>
+ internal static XmlSchemaGroupRef Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaGroupRef groupref = new XmlSchemaGroupRef();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaGroup.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ groupref.LineNumber = reader.LineNumber;
+ groupref.LinePosition = reader.LinePosition;
+ groupref.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ groupref.Id = reader.Value;
+ }
+ else if(reader.Name == "ref")
+ {
+ Exception innerex;
+ groupref.refName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for ref attribute",innerex);
+ }
+ else if(reader.Name == "maxOccurs")
+ {
+ try
+ {
+ groupref.MaxOccursString = reader.Value;
+ }
+ catch(Exception e)
+ {
+ error(h,reader.Value + " is an invalid value for maxOccurs",e);
+ }
+ }
+ else if(reader.Name == "minOccurs")
+ {
+ try
+ {
+ groupref.MinOccursString = reader.Value;
+ }
+ catch(Exception e)
+ {
+ error(h,reader.Value + " is an invalid value for minOccurs", e);
+ }
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for group",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,groupref);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return groupref;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaGroupRef.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ groupref.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return groupref;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaIdentityConstraint.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaIdentityConstraint.cs
new file mode 100755
index 00000000000..7e09ca0842d
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaIdentityConstraint.cs
@@ -0,0 +1,91 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaIdentityConstraint.
+ /// </summary>
+ public class XmlSchemaIdentityConstraint : XmlSchemaAnnotated
+ {
+ private XmlSchemaObjectCollection fields;
+ private string name;
+ private XmlQualifiedName qName;
+ private XmlSchemaXPath selector;
+
+ public XmlSchemaIdentityConstraint()
+ {
+ fields = new XmlSchemaObjectCollection();
+ qName = XmlQualifiedName.Empty;
+ }
+
+ [System.Xml.Serialization.XmlAttribute("name")]
+ public string Name
+ {
+ get{ return name; }
+ set{ name = value; }
+ }
+
+ [XmlElement("selector",typeof(XmlSchemaXPath),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaXPath Selector
+ {
+ get{ return selector; }
+ set{ selector = value; }
+ }
+
+ [XmlElement("field",typeof(XmlSchemaXPath),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection Fields
+ {
+ get{ return fields; }
+ }
+
+ [XmlIgnore]
+ public XmlQualifiedName QualifiedName
+ {
+ get{ return qName; }
+ }
+ /// <remarks>
+ /// 1. name must be present
+ /// 2. selector and field must be present
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ if(Name == null)
+ error(h,"Required attribute name must be present");
+ else if(!XmlSchemaUtil.CheckNCName(this.name))
+ error(h,"attribute name must be NCName");
+ else
+ this.qName = new XmlQualifiedName(Name,info.TargetNamespace);
+
+ if(Selector == null)
+ error(h,"selector must be present");
+ else
+ {
+ errorCount += Selector.Compile(h,info);
+ }
+
+ if(Fields.Count == 0)
+ error(h,"atleast one field value must be present");
+ else
+ {
+ foreach(XmlSchemaObject obj in Fields)
+ {
+ if(obj is XmlSchemaXPath)
+ {
+ XmlSchemaXPath field = (XmlSchemaXPath)obj;
+ errorCount += field.Compile(h,info);
+ }
+ else
+ error(h,"Object of type "+obj.GetType()+" is invalid in the Fields Collection");
+ }
+ }
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ return errorCount;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaImport.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaImport.cs
new file mode 100755
index 00000000000..7586b2db155
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaImport.cs
@@ -0,0 +1,109 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaImport.
+ /// </summary>
+ public class XmlSchemaImport : XmlSchemaExternal
+ {
+ private XmlSchemaAnnotation annotation;
+ private string nameSpace;
+ private static string xmlname = "import";
+
+ public XmlSchemaImport()
+ {
+ }
+
+ [System.Xml.Serialization.XmlAttribute("namespace")]
+ public string Namespace
+ {
+ get{ return nameSpace; }
+ set{ nameSpace = value; }
+ }
+
+ [XmlElement("annotation",Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaAnnotation Annotation
+ {
+ get{ return annotation; }
+ set{ annotation = value; }
+ }
+ //<import
+ // id = ID
+ // namespace = anyURI
+ // schemaLocation = anyURI
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</import>
+ internal static XmlSchemaImport Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaImport import = new XmlSchemaImport();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != "import")
+ {
+ error(h,"Should not happen :1: XmlSchemaImport.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ import.LineNumber = reader.LineNumber;
+ import.LinePosition = reader.LinePosition;
+ import.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ import.Id = reader.Value;
+ }
+ else if(reader.Name == "namespace")
+ {
+ import.nameSpace = reader.Value;
+ }
+ else if(reader.Name == "schemaLocation")
+ {
+ import.SchemaLocation = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for import",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,import);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return import;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaImport.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ import.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return import;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaInclude.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaInclude.cs
new file mode 100755
index 00000000000..8cbb081eb7a
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaInclude.cs
@@ -0,0 +1,97 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaInclude.
+ /// </summary>
+ public class XmlSchemaInclude : XmlSchemaExternal
+ {
+ private XmlSchemaAnnotation annotation;
+ private static string xmlname = "include";
+
+ public XmlSchemaInclude()
+ {
+ }
+ [XmlElement("annotation",Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaAnnotation Annotation
+ {
+ get{ return annotation; }
+ set{ annotation = value; }
+ }
+
+ //<include
+ // id = ID
+ // schemaLocation = anyURI
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</include>
+ internal static XmlSchemaInclude Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaInclude include = new XmlSchemaInclude();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaInclude.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ include.LineNumber = reader.LineNumber;
+ include.LinePosition = reader.LinePosition;
+ include.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ include.Id = reader.Value;
+ }
+ else if(reader.Name == "schemaLocation")
+ {
+ include.SchemaLocation = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for include",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,include);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return include;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaInclude.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ include.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+
+ return include;
+ }
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaInfo.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaInfo.cs
new file mode 100755
index 00000000000..9fc85b04f26
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaInfo.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Xml;
+using System.Collections;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// This class would store the infomation we need during compilation.
+ /// </summary>
+ internal class XmlSchemaInfo
+ {
+ internal XmlSchemaInfo()
+ {
+ IDCollection = new Hashtable();
+ }
+
+ internal string TargetNamespace = null;
+ internal XmlSchemaDerivationMethod FinalDefault = XmlSchemaDerivationMethod.None;
+ internal XmlSchemaDerivationMethod BlockDefault = XmlSchemaDerivationMethod.None;
+ internal XmlSchemaForm ElementFormDefault = XmlSchemaForm.None;
+ internal XmlSchemaForm AttributeFormDefault = XmlSchemaForm.None;
+ internal Hashtable IDCollection;
+ internal XmlSchemaObjectTable SchemaTypes ;
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaKey.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaKey.cs
new file mode 100755
index 00000000000..b883f9e8da7
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaKey.cs
@@ -0,0 +1,127 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaKey.
+ /// </summary>
+ public class XmlSchemaKey : XmlSchemaIdentityConstraint
+ {
+ private static string xmlname = "key";
+
+ public XmlSchemaKey()
+ {
+ }
+ /// <remarks>
+ /// 1. name must be present
+ /// 2. selector and field must be present
+ /// </remarks>
+ [MonoTODO]
+ internal new int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ return base.Compile(h,info);
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+
+ internal new void error(ValidationEventHandler handle, string message)
+ {
+ errorCount++;
+ ValidationHandler.RaiseValidationError(handle, this, message);
+ }
+
+ //<key
+ // id = ID
+ // name = NCName
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, (selector, field+))
+ //</key>
+ internal static XmlSchemaKey Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaKey key = new XmlSchemaKey();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaKey.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ key.LineNumber = reader.LineNumber;
+ key.LinePosition = reader.LinePosition;
+ key.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ key.Id = reader.Value;
+ }
+ else if(reader.Name == "name")
+ {
+ key.Name = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for key",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,key);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return key;
+
+ // Content: annotation?, selector, field+
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaKey.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ key.Annotation = annotation;
+ continue;
+ }
+ if(level <= 2 && reader.LocalName == "selector")
+ {
+ level = 3;
+ XmlSchemaXPath selector = XmlSchemaXPath.Read(reader,h,"selector");
+ if(selector != null)
+ key.Selector = selector;
+ continue;
+ }
+ if(level <= 3 && reader.LocalName == "field")
+ {
+ level = 3;
+ if(key.Selector == null)
+ error(h,"selector must be defined before field declarations",null);
+ XmlSchemaXPath field = XmlSchemaXPath.Read(reader,h,"field");
+ if(field != null)
+ key.Fields.Add(field);
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return key;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaKeyref.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaKeyref.cs
new file mode 100755
index 00000000000..f22a40f23bd
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaKeyref.cs
@@ -0,0 +1,151 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaKeyref.
+ /// </summary>
+ public class XmlSchemaKeyref : XmlSchemaIdentityConstraint
+ {
+ private XmlQualifiedName refer;
+ private static string xmlname = "keyref";
+
+ public XmlSchemaKeyref()
+ {
+ refer = XmlQualifiedName.Empty;
+ }
+
+ [System.Xml.Serialization.XmlAttribute("refer")]
+ public XmlQualifiedName Refer
+ {
+ get{ return refer; }
+ set{ refer = value; }
+ }
+ /// <remarks>
+ /// 1. name must be present
+ /// 2. selector and field must be present
+ /// 3. refer must be present
+ /// </remarks>
+ [MonoTODO]
+ internal new int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ errorCount += base.Compile(h,info);
+ if(refer == null || refer.IsEmpty)
+ error(h,"refer must be present");
+ else if(!XmlSchemaUtil.CheckQName(refer))
+ error(h,"Refer is not a valid XmlQualifiedName");
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+
+ internal new void error(ValidationEventHandler handle, string message)
+ {
+ errorCount++;
+ ValidationHandler.RaiseValidationError(handle, this, message);
+ }
+ //<key
+ // id = ID
+ // name = NCName
+ // refer = QName
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, (selector, field+))
+ //</key>
+ internal static XmlSchemaKeyref Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaKeyref keyref = new XmlSchemaKeyref();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaKeyref.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ keyref.LineNumber = reader.LineNumber;
+ keyref.LinePosition = reader.LinePosition;
+ keyref.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ keyref.Id = reader.Value;
+ }
+ else if(reader.Name == "name")
+ {
+ keyref.Name = reader.Value;
+ }
+ else if(reader.Name == "refer")
+ {
+ Exception innerex;
+ keyref.refer = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for refer attribute",innerex);
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for keyref",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,keyref);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return keyref;
+
+ // Content: annotation?, selector, field+
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaKeyref.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ keyref.Annotation = annotation;
+ continue;
+ }
+ if(level <= 2 && reader.LocalName == "selector")
+ {
+ level = 3;
+ XmlSchemaXPath selector = XmlSchemaXPath.Read(reader,h,"selector");
+ if(selector != null)
+ keyref.Selector = selector;
+ continue;
+ }
+ if(level <= 3 && reader.LocalName == "field")
+ {
+ level = 3;
+ if(keyref.Selector == null)
+ error(h,"selector must be defined before field declarations",null);
+ XmlSchemaXPath field = XmlSchemaXPath.Read(reader,h,"field");
+ if(field != null)
+ keyref.Fields.Add(field);
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return keyref;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaLengthFacet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaLengthFacet.cs
new file mode 100755
index 00000000000..263d3c1c58e
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaLengthFacet.cs
@@ -0,0 +1,96 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaLengthFacet.
+ /// </summary>
+ public class XmlSchemaLengthFacet : XmlSchemaNumericFacet
+ {
+ private static string xmlname = "length";
+
+ public XmlSchemaLengthFacet()
+ {
+ }
+
+ //<length
+ // fixed = boolean : false
+ // id = ID
+ // value = nonNegativeInteger
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</length>
+ internal static XmlSchemaLengthFacet Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaLengthFacet length = new XmlSchemaLengthFacet();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaLengthFacet.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ length.LineNumber = reader.LineNumber;
+ length.LinePosition = reader.LinePosition;
+ length.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ length.Id = reader.Value;
+ }
+ else if(reader.Name == "fixed")
+ {
+ Exception innerex;
+ length.IsFixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for fixed attribute",innerex);
+ }
+ else if(reader.Name == "value")
+ {
+ length.Value = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for group",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,length);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return length;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaLengthFacet.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ length.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return length;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxExclusiveFacet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxExclusiveFacet.cs
new file mode 100755
index 00000000000..258c5bf9ccc
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxExclusiveFacet.cs
@@ -0,0 +1,96 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaMaxExclusiveFacet.
+ /// </summary>
+ public class XmlSchemaMaxExclusiveFacet : XmlSchemaFacet
+ {
+ private static string xmlname = "maxExclusive";
+
+ public XmlSchemaMaxExclusiveFacet()
+ {
+ }
+
+ //<maxExclusive
+ // fixed = boolean : false
+ // id = ID
+ // value = anySimpleType
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</maxExclusive>
+ internal static XmlSchemaMaxExclusiveFacet Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaMaxExclusiveFacet maxex = new XmlSchemaMaxExclusiveFacet();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaMaxExclusiveFacet.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ maxex.LineNumber = reader.LineNumber;
+ maxex.LinePosition = reader.LinePosition;
+ maxex.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ maxex.Id = reader.Value;
+ }
+ else if(reader.Name == "fixed")
+ {
+ Exception innerex;
+ maxex.IsFixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for fixed attribute",innerex);
+ }
+ else if(reader.Name == "value")
+ {
+ maxex.Value = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,maxex);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return maxex;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaMaxExclusiveFacet.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ maxex.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return maxex;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxInclusiveFacet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxInclusiveFacet.cs
new file mode 100755
index 00000000000..c080abad8d9
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxInclusiveFacet.cs
@@ -0,0 +1,96 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaMaxInclusiveFacet.
+ /// </summary>
+ public class XmlSchemaMaxInclusiveFacet : XmlSchemaFacet
+ {
+ private static string xmlname = "maxInclusive";
+
+ public XmlSchemaMaxInclusiveFacet()
+ {
+ }
+
+ //<maxInclusive
+ // fixed = boolean : false
+ // id = ID
+ // value = anySimpleType
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</maxInclusive>
+ internal static XmlSchemaMaxInclusiveFacet Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaMaxInclusiveFacet maxi = new XmlSchemaMaxInclusiveFacet();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaMaxInclusiveFacet.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ maxi.LineNumber = reader.LineNumber;
+ maxi.LinePosition = reader.LinePosition;
+ maxi.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ maxi.Id = reader.Value;
+ }
+ else if(reader.Name == "fixed")
+ {
+ Exception innerex;
+ maxi.IsFixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for fixed attribute",innerex);
+ }
+ else if(reader.Name == "value")
+ {
+ maxi.Value = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,maxi);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return maxi;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaMaxInclusiveFacet.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ maxi.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return maxi;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxLengthFacet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxLengthFacet.cs
new file mode 100755
index 00000000000..a7bbb98b145
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMaxLengthFacet.cs
@@ -0,0 +1,97 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaMaxLengthFacet.
+ /// </summary>
+ public class XmlSchemaMaxLengthFacet : XmlSchemaNumericFacet
+ {
+ private static string xmlname = "maxLength";
+
+ public XmlSchemaMaxLengthFacet()
+ {
+ }
+
+ //<maxLength
+ // fixed = boolean : false
+ // id = ID
+ // value = nonNegativeInteger
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</maxLength>
+ internal static XmlSchemaMaxLengthFacet Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaMaxLengthFacet length = new XmlSchemaMaxLengthFacet();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaMaxLengthFacet.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ length.LineNumber = reader.LineNumber;
+ length.LinePosition = reader.LinePosition;
+ length.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ length.Id = reader.Value;
+ }
+ else if(reader.Name == "fixed")
+ {
+ Exception innerex;
+ length.IsFixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for fixed attribute",innerex);
+ }
+ else if(reader.Name == "value")
+ {
+ length.Value = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for group",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,length);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return length;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaMaxLengthFacet.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ length.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return length;
+ }
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMinExclusiveFacet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMinExclusiveFacet.cs
new file mode 100755
index 00000000000..ea0cda2c7fa
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMinExclusiveFacet.cs
@@ -0,0 +1,96 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaMinExclusiveFacet.
+ /// </summary>
+ public class XmlSchemaMinExclusiveFacet : XmlSchemaFacet
+ {
+ private static string xmlname = "minExclusive";
+
+ public XmlSchemaMinExclusiveFacet()
+ {
+ }
+
+ //<minExclusive
+ // fixed = boolean : false
+ // id = ID
+ // value = anySimpleType
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</minExclusive>
+ internal static XmlSchemaMinExclusiveFacet Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaMinExclusiveFacet minex = new XmlSchemaMinExclusiveFacet();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaMinExclusiveFacet.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ minex.LineNumber = reader.LineNumber;
+ minex.LinePosition = reader.LinePosition;
+ minex.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ minex.Id = reader.Value;
+ }
+ else if(reader.Name == "fixed")
+ {
+ Exception innerex;
+ minex.IsFixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for fixed attribute",innerex);
+ }
+ else if(reader.Name == "value")
+ {
+ minex.Value = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,minex);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return minex;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaMinExclusiveFacet.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ minex.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return minex;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMinInclusiveFacet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMinInclusiveFacet.cs
new file mode 100755
index 00000000000..8459cd3ebe5
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMinInclusiveFacet.cs
@@ -0,0 +1,95 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaMinInclusiveFacet.
+ /// </summary>
+ public class XmlSchemaMinInclusiveFacet : XmlSchemaFacet
+ {
+ private static string xmlname = "minInclusive";
+
+ public XmlSchemaMinInclusiveFacet()
+ {
+ }
+ //<minInclusive
+ // fixed = boolean : false
+ // id = ID
+ // value = anySimpleType
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</minInclusive>
+ internal static XmlSchemaMinInclusiveFacet Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaMinInclusiveFacet mini = new XmlSchemaMinInclusiveFacet();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaMinInclusiveFacet.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ mini.LineNumber = reader.LineNumber;
+ mini.LinePosition = reader.LinePosition;
+ mini.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ mini.Id = reader.Value;
+ }
+ else if(reader.Name == "fixed")
+ {
+ Exception innerex;
+ mini.IsFixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for fixed attribute",innerex);
+ }
+ else if(reader.Name == "value")
+ {
+ mini.Value = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,mini);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return mini;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaMinInclusiveFacet.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ mini.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return mini;
+ }
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMinLengthFacet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMinLengthFacet.cs
new file mode 100755
index 00000000000..51763977a4a
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaMinLengthFacet.cs
@@ -0,0 +1,96 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaMinLengthFacet.
+ /// </summary>
+ public class XmlSchemaMinLengthFacet : XmlSchemaNumericFacet
+ {
+ private static string xmlname = "minLength";
+
+ public XmlSchemaMinLengthFacet()
+ {
+ }
+
+ //<minLength
+ // fixed = boolean : false
+ // id = ID
+ // value = nonNegativeInteger
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</minLength>
+ internal static XmlSchemaMinLengthFacet Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaMinLengthFacet length = new XmlSchemaMinLengthFacet();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaMinLengthFacet.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ length.LineNumber = reader.LineNumber;
+ length.LinePosition = reader.LinePosition;
+ length.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ length.Id = reader.Value;
+ }
+ else if(reader.Name == "fixed")
+ {
+ Exception innerex;
+ length.IsFixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for fixed attribute",innerex);
+ }
+ else if(reader.Name == "value")
+ {
+ length.Value = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,length);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return length;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaMinLengthFacet.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ length.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return length;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaNotation.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaNotation.cs
new file mode 100755
index 00000000000..f07b83213c5
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaNotation.cs
@@ -0,0 +1,158 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaNotation.
+ /// </summary>
+ public class XmlSchemaNotation : XmlSchemaAnnotated
+ {
+ private string name;
+ private string pub;
+ private string system;
+ private XmlQualifiedName qualifiedName;
+ private static string xmlname = "notation";
+
+ public XmlSchemaNotation()
+ {
+ }
+ [System.Xml.Serialization.XmlAttribute("name")]
+ public string Name
+ {
+ get{ return name; }
+ set{ name = value; }
+ }
+ [System.Xml.Serialization.XmlAttribute("public")]
+ public string Public
+ {
+ get{ return pub; }
+ set{ pub = value; }
+ }
+ [System.Xml.Serialization.XmlAttribute("system")]
+ public string System
+ {
+ get{ return system; }
+ set{ system = value; }
+ }
+
+ [XmlIgnore]
+ internal XmlQualifiedName QualifiedName
+ {
+ get{ return qualifiedName;}
+ }
+
+ // 1. name and public must be present
+ // public and system must be anyURI
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ if(Name == null)
+ error(h,"Required attribute name must be present");
+ else if(!XmlSchemaUtil.CheckNCName(this.name))
+ error(h,"attribute name must be NCName");
+ else
+ qualifiedName = new XmlQualifiedName(Name,info.TargetNamespace);
+
+ if(Public==null)
+ error(h,"public must be present");
+ else if(!XmlSchemaUtil.CheckAnyUri(Public))
+ error(h,"public must be anyURI");
+
+ if(system != null && !XmlSchemaUtil.CheckAnyUri(system))
+ error(h,"system must be present and of Type anyURI");
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+
+ //<notation
+ // id = ID
+ // name = NCName
+ // public = anyURI
+ // system = anyURI
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</notation>
+ internal static XmlSchemaNotation Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaNotation notation = new XmlSchemaNotation();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaInclude.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ notation.LineNumber = reader.LineNumber;
+ notation.LinePosition = reader.LinePosition;
+ notation.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ notation.Id = reader.Value;
+ }
+ else if(reader.Name == "name")
+ {
+ notation.name = reader.Value;
+ }
+ else if(reader.Name == "public")
+ {
+ notation.pub = reader.Value;
+ }
+ else if(reader.Name == "system")
+ {
+ notation.system = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for notation",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,notation);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return notation;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaNotation.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ notation.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return notation;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaNumericFacet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaNumericFacet.cs
new file mode 100755
index 00000000000..72359a71f16
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaNumericFacet.cs
@@ -0,0 +1,16 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaNumericFacet.
+ /// </summary>
+ public abstract class XmlSchemaNumericFacet : XmlSchemaFacet
+ {
+ protected XmlSchemaNumericFacet()
+ {
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaObject.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaObject.cs
new file mode 100755
index 00000000000..71e8b57faf4
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaObject.cs
@@ -0,0 +1,75 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Collections;
+using System.Xml.Serialization;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaObject.
+ /// </summary>
+ public abstract class XmlSchemaObject
+ {
+ private int lineNumber;
+ private int linePosition;
+ private string sourceUri;
+ private XmlSerializerNamespaces namespaces;
+ internal ArrayList unhandledAttributeList ;
+ internal bool isCompiled = false;
+ internal int errorCount = 0;
+
+ protected XmlSchemaObject()
+ {
+ namespaces = new XmlSerializerNamespaces();
+ unhandledAttributeList = null;
+ }
+
+ [XmlIgnore]
+ public int LineNumber
+ {
+ get{ return lineNumber; }
+ set{ lineNumber = value; }
+ }
+ [XmlIgnore]
+ public int LinePosition
+ {
+ get{ return linePosition; }
+ set{ linePosition = value; }
+ }
+ [XmlIgnore]
+ public string SourceUri
+ {
+ get{ return sourceUri; }
+ set{ sourceUri = value; }
+ }
+
+ // Undocumented Property
+ [XmlNamespaceDeclarations]
+ public XmlSerializerNamespaces Namespaces
+ {
+ get{ return namespaces; }
+ set{ namespaces = value; }
+ }
+
+ internal void error(ValidationEventHandler handle,string message)
+ {
+ errorCount++;
+ ValidationHandler.RaiseValidationError(handle,this,message);
+ }
+ internal void warn(ValidationEventHandler handle,string message)
+ {
+ errorCount++;
+ ValidationHandler.RaiseValidationWarning(handle,this,message);
+ }
+ internal static void error(ValidationEventHandler handle, string message, Exception innerException)
+ {
+ ValidationHandler.RaiseValidationError(handle,message, innerException);
+ }
+ internal static void warn(ValidationEventHandler handle, string message, Exception innerException)
+ {
+ ValidationHandler.RaiseValidationWarning(handle,message, innerException);
+ }
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaObjectCollection.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaObjectCollection.cs
new file mode 100755
index 00000000000..874c5c13830
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaObjectCollection.cs
@@ -0,0 +1,88 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Collections;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaObjectCollection.
+ /// </summary>
+ public class XmlSchemaObjectCollection : System.Collections.CollectionBase
+ {
+ private XmlSchemaObject parent;
+
+ public XmlSchemaObjectCollection()
+ {
+ }
+ public XmlSchemaObjectCollection(XmlSchemaObject parent)
+ {
+ this.parent = parent;
+ }
+
+ // Properties
+ public virtual XmlSchemaObject this[ int index ]
+ {
+ get
+ {
+ return (XmlSchemaObject) this.List[index];
+ }
+ set
+ {
+ this.List[index] = value;
+ }
+ }
+
+ // Methods
+ public int Add(XmlSchemaObject item)
+ {
+ return this.List.Add(item);
+ }
+
+ public bool Contains(XmlSchemaObject item)
+ {
+ return this.List.Contains(item);
+ }
+
+ public void CopyTo(XmlSchemaObject[] array, int index)
+ {
+ this.List.CopyTo(array,index);
+ }
+
+ public new XmlSchemaObjectEnumerator GetEnumerator ()
+ {
+ return new XmlSchemaObjectEnumerator(this.List);
+ }
+
+ public int IndexOf(XmlSchemaObject item)
+ {
+ return this.List.IndexOf(item);
+ }
+
+ public void Insert(int index, XmlSchemaObject item)
+ {
+ this.List.Insert(index, item);
+ }
+
+ protected override void OnClear()
+ {
+ }
+
+ protected override void OnInsert(int index,object item)
+ {
+ }
+
+ protected override void OnRemove(int index,object item)
+ {
+ }
+
+ protected override void OnSet(int index,object oldValue,object newValue)
+ {
+ }
+
+ public void Remove(XmlSchemaObject item)
+ {
+ this.List.Remove(item);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaObjectEnumerator.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaObjectEnumerator.cs
new file mode 100755
index 00000000000..6c2af9513d5
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaObjectEnumerator.cs
@@ -0,0 +1,49 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Collections;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaObjectEnumerator.
+ /// </summary>
+ public sealed class XmlSchemaObjectEnumerator : IEnumerator
+ {
+ private IEnumerator ienum;
+ internal XmlSchemaObjectEnumerator(IList list)
+ {
+ this.ienum = list.GetEnumerator();
+ }
+ // Properties
+ public XmlSchemaObject Current
+ {
+ get
+ {
+ return (XmlSchemaObject) ienum.Current;
+ }
+ }
+ // Methods
+ public bool MoveNext()
+ {
+ return ienum.MoveNext();
+ }
+ public void Reset()
+ {
+ ienum.Reset();
+ }
+ //Explicit Interface implementation
+ bool IEnumerator.MoveNext()
+ {
+ return ienum.MoveNext();
+ }
+ void IEnumerator.Reset()
+ {
+ ienum.Reset();
+ }
+ object IEnumerator.Current
+ {
+ get{return (XmlSchema) ienum.Current;}
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaObjectTable.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaObjectTable.cs
new file mode 100755
index 00000000000..16461b9875c
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaObjectTable.cs
@@ -0,0 +1,51 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Collections;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaObjectTable.
+ /// </summary>
+ public class XmlSchemaObjectTable
+ {
+ private Hashtable table;
+
+ internal XmlSchemaObjectTable()
+ {
+ table = new Hashtable();
+ }
+ public int Count
+ {
+ get{ return table.Count; }
+ }
+ public XmlSchemaObject this[XmlQualifiedName name]
+ {
+ get{ return (XmlSchemaObject) table[name]; }
+ }
+ public ICollection Names
+ {
+ get{ return table.Keys; }
+ }
+ public ICollection Values
+ {
+ get{ return table.Values;}
+ }
+
+ public bool Contains(XmlQualifiedName name)
+ {
+ return table.Contains(name);
+ }
+ public IDictionaryEnumerator GetEnumerator()
+ {
+ return table.GetEnumerator();
+ }
+
+ internal void Add(XmlQualifiedName name, XmlSchemaObject value)
+ {
+ table.Add(name,value);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaParticle.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaParticle.cs
new file mode 100755
index 00000000000..119c335b3c0
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaParticle.cs
@@ -0,0 +1,98 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaParticle.
+ /// </summary>
+ public abstract class XmlSchemaParticle : XmlSchemaAnnotated
+ {
+ decimal minOccurs, maxOccurs;
+ string minstr, maxstr;
+
+ protected XmlSchemaParticle()
+ {
+ minOccurs = decimal.One;
+ maxOccurs = decimal.One;
+ }
+
+ #region Attributes
+
+ [System.Xml.Serialization.XmlAttribute("minOccurs")]
+ public string MinOccursString
+ {
+ get{ return minstr; }
+ set
+ {
+ decimal val = decimal.Parse(value);
+ if(val >= 0 && (val == Decimal.Truncate(val)))
+ {
+ minOccurs = val;
+ minstr = val.ToString();
+ }
+ else
+ {
+ throw new XmlSchemaException
+ ("MinOccursString must be a non-negative number",null);
+ }
+ }
+ }
+
+ [System.Xml.Serialization.XmlAttribute("maxOccurs")]
+ public string MaxOccursString
+ {
+ get{ return maxstr; }
+ set
+ {
+ if(value == "unbounded")
+ {
+ maxstr = value;
+ maxOccurs = decimal.MaxValue;
+ }
+ else
+ {
+ decimal val = decimal.Parse(value);
+ if(val >= 0 && (val == Decimal.Truncate(val)))
+ {
+ maxOccurs = val;
+ maxstr = val.ToString();
+ }
+ else
+ {
+ throw new XmlSchemaException
+ ("MaxOccurs must be a non-negative integer",null);
+ }
+ }
+ }
+ }
+
+ #endregion
+
+ #region XmlIgnore
+
+ [XmlIgnore]
+ public decimal MinOccurs
+ {
+ get{ return minOccurs; }
+ set
+ {
+ MinOccursString = value.ToString();
+ }
+ }
+
+ [XmlIgnore]
+ public decimal MaxOccurs
+ {
+ get{ return maxOccurs; }
+ set
+ {
+ MaxOccursString = value.ToString();
+ }
+ }
+
+ #endregion
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaPatternFacet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaPatternFacet.cs
new file mode 100755
index 00000000000..da2effbb380
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaPatternFacet.cs
@@ -0,0 +1,87 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaPatternFacet.
+ /// </summary>
+ public class XmlSchemaPatternFacet : XmlSchemaFacet
+ {
+ private static string xmlname = "pattern";
+
+ public XmlSchemaPatternFacet()
+ {
+ }
+ //<pattern
+ // id = ID
+ // value = anySimpleType
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</pattern>
+ internal static XmlSchemaPatternFacet Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaPatternFacet pattern = new XmlSchemaPatternFacet();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaPatternFacet.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ pattern.LineNumber = reader.LineNumber;
+ pattern.LinePosition = reader.LinePosition;
+ pattern.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ pattern.Id = reader.Value;
+ }
+ else if(reader.Name == "value")
+ {
+ pattern.Value = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,pattern);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return pattern;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaPatternFacet.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ pattern.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return pattern;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaReader.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaReader.cs
new file mode 100755
index 00000000000..fc4375a9767
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaReader.cs
@@ -0,0 +1,358 @@
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// A wrapper around XmlReader
+ /// </summary>
+ public class XmlSchemaReader : XmlReader, IXmlLineInfo
+ {
+ XmlReader reader;
+ ValidationEventHandler handler;
+ bool hasLineInfo;
+ public XmlSchemaReader(XmlReader reader,ValidationEventHandler handler)
+ {
+ this.reader = reader;
+ this.handler = handler;
+ if(reader is IXmlLineInfo)
+ {
+ IXmlLineInfo info = (IXmlLineInfo)reader;
+ hasLineInfo = info.HasLineInfo();
+ }
+ }
+
+ /// <summary>
+ /// Returns the Namespace:LocalName for the object
+ /// </summary>
+ public string FullName
+ {
+ get { return NamespaceURI + ":" + LocalName; }
+ }
+
+ public void RaiseInvalidElementError()
+ {
+ string errstr = "Element "+FullName + " is invalid in this context.\n";
+ if(hasLineInfo)
+ errstr += "The error occured on ("+((IXmlLineInfo)reader).LineNumber
+ +","+((IXmlLineInfo)reader).LinePosition+")";
+ XmlSchemaObject.error(handler, errstr, null);
+ SkipToEnd();
+ }
+ /// <summary>
+ /// Reads till the next Element or EndElement. Also checks that the Namespace of the element is
+ /// Schema's Namespace.
+ /// </summary>
+ /// <returns></returns>
+ public bool ReadNextElement()
+ {
+ MoveToElement();
+ while(Read())
+ {
+ if(NodeType == XmlNodeType.Element || NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.NamespaceURI != XmlSchema.Namespace)
+ {
+ RaiseInvalidElementError();
+ }
+ else
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /// <summary>
+ /// Skips to the end of the current element
+ /// </summary>
+ public void SkipToEnd()
+ {
+ MoveToElement();
+ if(IsEmptyElement || NodeType != XmlNodeType.Element)
+ return;
+ if(NodeType == XmlNodeType.Element)
+ {
+ int depth = Depth;
+ while(Read())
+ {
+ if(Depth == depth)
+ break;
+ }
+ }
+ return;
+ }
+
+ #region LineInfo
+ public bool HasLineInfo()
+ {
+ return hasLineInfo;
+ }
+ public int LineNumber
+ {
+ get { return hasLineInfo?((IXmlLineInfo)reader).LineNumber: 0; }
+ }
+ public int LinePosition
+ {
+ get { return hasLineInfo?((IXmlLineInfo)reader).LinePosition: 0; }
+ }
+ #endregion
+
+ #region Delegates
+ public override int AttributeCount
+ {
+ get { return reader.AttributeCount; }
+ }
+ public override string BaseURI
+ {
+ get { return reader.BaseURI; }
+ }
+ public override bool CanResolveEntity
+ {
+ get { return reader.CanResolveEntity; }
+ }
+ public override int Depth
+ {
+ get { return reader.Depth; }
+ }
+ public override bool EOF
+ {
+ get { return reader.EOF; }
+ }
+ public override bool HasAttributes
+ {
+ get { return reader.HasAttributes; }
+ }
+ public override bool HasValue
+ {
+ get { return reader.HasValue; }
+ }
+ public override bool IsDefault
+ {
+ get { return reader.IsDefault; }
+ }
+ public override bool IsEmptyElement
+ {
+ get { return reader.IsEmptyElement; }
+ }
+ public override string this[ int i ]
+ {
+ get { return reader[i]; }
+ }
+ public override string this[ string name ]
+ {
+ get { return reader[name]; }
+ }
+ public override string this[ string name, string namespaceURI ]
+ {
+ get { return reader[name,namespaceURI]; }
+ }
+ public override string LocalName
+ {
+ get { return reader.LocalName; }
+ }
+ public override string Name
+ {
+ get { return reader.Name; }
+ }
+ public override string NamespaceURI
+ {
+ get { return reader.NamespaceURI; }
+ }
+ public override XmlNameTable NameTable
+ {
+ get { return reader.NameTable; }
+ }
+ public override XmlNodeType NodeType
+ {
+ get { return reader.NodeType; }
+ }
+ public override string Prefix
+ {
+ get { return reader.Prefix; }
+ }
+ public override char QuoteChar
+ {
+ get { return reader.QuoteChar; }
+ }
+ public override ReadState ReadState
+ {
+ get { return reader.ReadState; }
+ }
+ public override string Value
+ {
+ get { return reader.Value; }
+ }
+ public override string XmlLang
+ {
+ get { return reader.XmlLang; }
+ }
+ public override XmlSpace XmlSpace
+ {
+ get { return reader.XmlSpace; }
+ }
+
+ public override void Close()
+ {
+ reader.Close();
+ }
+
+ public override bool Equals(object obj)
+ {
+ return reader.Equals(obj);
+ }
+
+ public override string GetAttribute(int i)
+ {
+ return reader.GetAttribute(i);
+ }
+
+ public override string GetAttribute(string name)
+ {
+ return reader.GetAttribute(name);
+ }
+
+ public override string GetAttribute(string name, string namespaceURI)
+ {
+ return reader.GetAttribute(name, namespaceURI);
+ }
+
+ public override int GetHashCode()
+ {
+ return reader.GetHashCode();
+ }
+
+ public override bool IsStartElement()
+ {
+ return reader.IsStartElement();
+ }
+
+ public override bool IsStartElement(string localname, string ns)
+ {
+ return reader.IsStartElement(localname, ns);
+ }
+
+ public override bool IsStartElement(string name)
+ {
+ return reader.IsStartElement(name);
+ }
+
+ public override string LookupNamespace(string prefix)
+ {
+ return reader.LookupNamespace(prefix);
+ }
+
+ public override void MoveToAttribute(int i)
+ {
+ reader.MoveToAttribute(i);
+ }
+
+ public override bool MoveToAttribute(string name)
+ {
+ return reader.MoveToAttribute(name);
+ }
+
+ public override bool MoveToAttribute(string name, string ns)
+ {
+ return reader.MoveToAttribute(name,ns);
+ }
+
+ public override System.Xml.XmlNodeType MoveToContent()
+ {
+ return reader.MoveToContent();
+ }
+
+ public override bool MoveToElement()
+ {
+ return reader.MoveToElement();
+ }
+
+ public override bool MoveToFirstAttribute()
+ {
+ return reader.MoveToFirstAttribute();
+ }
+
+ public override bool MoveToNextAttribute()
+ {
+ return reader.MoveToNextAttribute();
+ }
+
+ public override bool Read()
+ {
+ return reader.Read();
+ }
+
+ public override bool ReadAttributeValue()
+ {
+ return reader.ReadAttributeValue();
+ }
+
+ public override string ReadElementString()
+ {
+ return reader.ReadElementString();
+ }
+
+ public override string ReadElementString(string localname, string ns)
+ {
+ return reader.ReadElementString(localname, ns);
+ }
+
+ public override string ReadElementString(string name)
+ {
+ return reader.ReadElementString(name);
+ }
+
+ public override void ReadEndElement()
+ {
+ reader.ReadEndElement();
+ }
+
+ public override string ReadInnerXml()
+ {
+ return reader.ReadInnerXml();
+ }
+
+ public override string ReadOuterXml()
+ {
+ return reader.ReadOuterXml();
+ }
+
+ public override void ReadStartElement()
+ {
+ reader.ReadStartElement();
+ }
+
+ public override void ReadStartElement(string localname, string ns)
+ {
+ reader.ReadStartElement(localname, ns);
+ }
+
+ public override void ReadStartElement(string name)
+ {
+ reader.ReadStartElement(name);
+ }
+
+ public override string ReadString()
+ {
+ return reader.ReadString();
+ }
+
+ public override void ResolveEntity()
+ {
+ reader.ResolveEntity();
+ }
+
+ public override void Skip()
+ {
+ reader.Skip();
+ }
+
+ public override string ToString()
+ {
+ return reader.ToString();
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaRedefine.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaRedefine.cs
new file mode 100755
index 00000000000..bd573ec94ab
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaRedefine.cs
@@ -0,0 +1,151 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaRedefine.
+ /// </summary>
+ public class XmlSchemaRedefine : XmlSchemaExternal
+ {
+ private XmlSchemaObjectTable attributeGroups;
+ private XmlSchemaObjectTable groups;
+ private XmlSchemaObjectCollection items;
+ private XmlSchemaObjectTable schemaTypes;
+ private static string xmlname = "redefine";
+
+ public XmlSchemaRedefine()
+ {
+ attributeGroups = new XmlSchemaObjectTable();
+ groups = new XmlSchemaObjectTable();
+ items = new XmlSchemaObjectCollection(this);
+ schemaTypes = new XmlSchemaObjectTable();
+ }
+
+ [XmlElement("annotation",typeof(XmlSchemaAnnotation),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("simpleType",typeof(XmlSchemaSimpleType),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("complexType",typeof(XmlSchemaComplexType),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("group",typeof(XmlSchemaGroup),Namespace="http://www.w3.org/2001/XMLSchema")]
+ //NOTE: AttributeGroup and not AttributeGroupRef
+ [XmlElement("attributeGroup",typeof(XmlSchemaAttributeGroup),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection Items
+ {
+ get{ return items; }
+ }
+
+ [XmlIgnore]
+ public XmlSchemaObjectTable AttributeGroups
+ {
+ get{ return attributeGroups; }
+ }
+
+ [XmlIgnore]
+ public XmlSchemaObjectTable SchemaTypes
+ {
+ get{ return schemaTypes; }
+ }
+
+ [XmlIgnore]
+ public XmlSchemaObjectTable Groups
+ {
+ get{ return groups; }
+ }
+//<redefine
+// id = ID
+// schemaLocation = anyURI
+// {any attributes with non-schema namespace . . .}>
+// Content: (annotation | (simpleType | complexType | group | attributeGroup))*
+//</redefine>
+ internal static XmlSchemaRedefine Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaRedefine redefine = new XmlSchemaRedefine();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaRedefine.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ redefine.LineNumber = reader.LineNumber;
+ redefine.LinePosition = reader.LinePosition;
+ redefine.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ redefine.Id = reader.Value;
+ }
+ else if(reader.Name == "schemaLocation")
+ {
+ redefine.SchemaLocation = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for redefine",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,redefine);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return redefine;
+
+ //(annotation | (simpleType | complexType | group | attributeGroup))*
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaRedefine.Read, name="+reader.Name,null);
+ break;
+ }
+ if(reader.LocalName == "annotation")
+ {
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ redefine.items.Add(annotation);
+ continue;
+ }
+ if(reader.LocalName == "simpleType")
+ {
+ XmlSchemaSimpleType simpleType = XmlSchemaSimpleType.Read(reader,h);
+ if(simpleType != null)
+ redefine.items.Add(simpleType);
+ continue;
+ }
+ if(reader.LocalName == "complexType")
+ {
+ XmlSchemaComplexType complexType = XmlSchemaComplexType.Read(reader,h);
+ if(complexType != null)
+ redefine.items.Add(complexType);
+ continue;
+ }
+ if(reader.LocalName == "group")
+ {
+ XmlSchemaGroup group = XmlSchemaGroup.Read(reader,h);
+ if(group != null)
+ redefine.items.Add(group);
+ continue;
+ }
+ if(reader.LocalName == "attributeGroup")
+ {
+ XmlSchemaAttributeGroup attributeGroup = XmlSchemaAttributeGroup.Read(reader,h);
+ if(attributeGroup != null)
+ redefine.items.Add(attributeGroup);
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return redefine;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSequence.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSequence.cs
new file mode 100755
index 00000000000..769ab66f2b7
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSequence.cs
@@ -0,0 +1,202 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaSequence.
+ /// </summary>
+ public class XmlSchemaSequence : XmlSchemaGroupBase
+ {
+ private XmlSchemaObjectCollection items;
+ private static string xmlname = "sequence";
+
+ public XmlSchemaSequence()
+ {
+ items = new XmlSchemaObjectCollection();
+ }
+
+ [XmlElement("element",typeof(XmlSchemaElement),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("group",typeof(XmlSchemaGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("choice",typeof(XmlSchemaChoice),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("sequence",typeof(XmlSchemaSequence),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("any",typeof(XmlSchemaAny),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public override XmlSchemaObjectCollection Items
+ {
+ get{ return items; }
+ }
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ //FIXME: Should we reset the values
+ if(MinOccurs > MaxOccurs)
+ error(h,"minOccurs must be less than or equal to maxOccurs");
+
+ XmlSchemaUtil.CompileID(Id, this, info.IDCollection, h);
+
+ foreach(XmlSchemaObject obj in Items)
+ {
+ if(obj is XmlSchemaElement)
+ {
+ errorCount += ((XmlSchemaElement)obj).Compile(h,info);
+ }
+ else if(obj is XmlSchemaGroupRef)
+ {
+ errorCount += ((XmlSchemaGroupRef)obj).Compile(h,info);
+ }
+ else if(obj is XmlSchemaChoice)
+ {
+ errorCount += ((XmlSchemaChoice)obj).Compile(h,info);
+ }
+ else if(obj is XmlSchemaSequence)
+ {
+ errorCount += ((XmlSchemaSequence)obj).Compile(h,info);
+ }
+ else if(obj is XmlSchemaAny)
+ {
+ errorCount += ((XmlSchemaAny)obj).Compile(h,info);
+ }
+ }
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+ //<sequence
+ // id = ID
+ // maxOccurs = (nonNegativeInteger | unbounded) : 1
+ // minOccurs = nonNegativeInteger : 1
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, (element | group | choice | sequence | any)*)
+ //</sequence>
+ internal static XmlSchemaSequence Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaSequence sequence = new XmlSchemaSequence();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaSequence.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ sequence.LineNumber = reader.LineNumber;
+ sequence.LinePosition = reader.LinePosition;
+ sequence.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ sequence.Id = reader.Value;
+ }
+ else if(reader.Name == "maxOccurs")
+ {
+ try
+ {
+ sequence.MaxOccursString = reader.Value;
+ }
+ catch(Exception e)
+ {
+ error(h,reader.Value + " is an invalid value for maxOccurs",e);
+ }
+ }
+ else if(reader.Name == "minOccurs")
+ {
+ try
+ {
+ sequence.MinOccursString = reader.Value;
+ }
+ catch(Exception e)
+ {
+ error(h,reader.Value + " is an invalid value for minOccurs",e);
+ }
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for sequence",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,sequence);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return sequence;
+
+ // Content: (annotation?, (element | group | choice | sequence | any)*)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaSequence.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ sequence.Annotation = annotation;
+ continue;
+ }
+ if(level <=2)
+ {
+ if(reader.LocalName == "element")
+ {
+ level = 2;
+ XmlSchemaElement element = XmlSchemaElement.Read(reader,h);
+ if(element != null)
+ sequence.items.Add(element);
+ continue;
+ }
+ if(reader.LocalName == "group")
+ {
+ level = 2;
+ XmlSchemaGroupRef group = XmlSchemaGroupRef.Read(reader,h);
+ if(group != null)
+ sequence.items.Add(group);
+ continue;
+ }
+ if(reader.LocalName == "choice")
+ {
+ level = 2;
+ XmlSchemaChoice choice = XmlSchemaChoice.Read(reader,h);
+ if(choice != null)
+ sequence.items.Add(choice);
+ continue;
+ }
+ if(reader.LocalName == "sequence")
+ {
+ level = 2;
+ XmlSchemaSequence seq = XmlSchemaSequence.Read(reader,h);
+ if(seq != null)
+ sequence.items.Add(seq);
+ continue;
+ }
+ if(reader.LocalName == "any")
+ {
+ level = 2;
+ XmlSchemaAny any = XmlSchemaAny.Read(reader,h);
+ if(any != null)
+ sequence.items.Add(any);
+ continue;
+ }
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return sequence;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContent.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContent.cs
new file mode 100755
index 00000000000..2c2fce3f933
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContent.cs
@@ -0,0 +1,146 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaSimpleContent.
+ /// </summary>
+ public class XmlSchemaSimpleContent : XmlSchemaContentModel
+ {
+ private XmlSchemaContent content;
+ private static string xmlname = "simpleContent";
+ public XmlSchemaSimpleContent()
+ {
+ }
+
+ [XmlElement("restriction",typeof(XmlSchemaSimpleContentRestriction),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("extension",typeof(XmlSchemaSimpleContentExtension),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public override XmlSchemaContent Content
+ {
+ get{ return content; }
+ set{ content = value; }
+ }
+
+ ///<remarks>
+ /// 1. Content must be present and one of restriction or extention
+ ///</remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ if(Content == null)
+ {
+ error(h, "Content must be present in a simpleContent");
+ }
+ else
+ {
+ if(Content is XmlSchemaSimpleContentRestriction)
+ {
+ XmlSchemaSimpleContentRestriction xscr = (XmlSchemaSimpleContentRestriction) Content;
+ errorCount += xscr.Compile(h,info);
+ }
+ else if(Content is XmlSchemaSimpleContentExtension)
+ {
+ XmlSchemaSimpleContentExtension xsce = (XmlSchemaSimpleContentExtension) Content;
+ errorCount += xsce.Compile(h,info);
+ }
+ else
+ error(h,"simpleContent can't have any value other than restriction or extention");
+ }
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+ //<simpleContent
+ // id = ID
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, (restriction | extension))
+ //</simpleContent>
+ internal static XmlSchemaSimpleContent Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaSimpleContent simple = new XmlSchemaSimpleContent();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaComplexContent.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ simple.LineNumber = reader.LineNumber;
+ simple.LinePosition = reader.LinePosition;
+ simple.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ simple.Id = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for simpleContent",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,simple);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return simple;
+ //Content: (annotation?, (restriction | extension))
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaSimpleContent.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ simple.Annotation = annotation;
+ continue;
+ }
+ if(level <=2)
+ {
+ if(reader.LocalName == "restriction")
+ {
+ level = 3;
+ XmlSchemaSimpleContentRestriction restriction = XmlSchemaSimpleContentRestriction.Read(reader,h);
+ if(restriction != null)
+ simple.content = restriction;
+ continue;
+ }
+ if(reader.LocalName == "extension")
+ {
+ level = 3;
+ XmlSchemaSimpleContentExtension extension = XmlSchemaSimpleContentExtension.Read(reader,h);
+ if(extension != null)
+ simple.content = extension;
+ continue;
+ }
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return simple;
+ }
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContentExtension.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContentExtension.cs
new file mode 100755
index 00000000000..09d10f25ef6
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContentExtension.cs
@@ -0,0 +1,190 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaSimpleContentExtension.
+ /// </summary>
+ public class XmlSchemaSimpleContentExtension : XmlSchemaContent
+ {
+
+ private XmlSchemaAnyAttribute any;
+ private XmlSchemaObjectCollection attributes;
+ private XmlQualifiedName baseTypeName;
+ private static string xmlname = "extension";
+
+ public XmlSchemaSimpleContentExtension()
+ {
+ baseTypeName = XmlQualifiedName.Empty;
+ attributes = new XmlSchemaObjectCollection();
+ }
+
+ [System.Xml.Serialization.XmlAttribute("base")]
+ public XmlQualifiedName BaseTypeName
+ {
+ get{ return baseTypeName; }
+ set{ baseTypeName = value; }
+ }
+
+ [XmlElement("attribute",typeof(XmlSchemaAttribute),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("attributeGroup",typeof(XmlSchemaAttributeGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection Attributes
+ {
+ get{ return attributes; }
+ }
+
+ [XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaAnyAttribute AnyAttribute
+ {
+ get{ return any; }
+ set{ any = value; }
+ }
+
+ ///<remarks>
+ /// 1. Base must be present and a QName
+ ///</remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ if(BaseTypeName == null || BaseTypeName.IsEmpty)
+ {
+ error(h, "base must be present and a QName");
+ }
+ else if(!XmlSchemaUtil.CheckQName(BaseTypeName))
+ error(h,"BaseTypeName must be a QName");
+
+ if(this.AnyAttribute != null)
+ {
+ errorCount += AnyAttribute.Compile(h,info);
+ }
+
+ foreach(XmlSchemaObject obj in Attributes)
+ {
+ if(obj is XmlSchemaAttribute)
+ {
+ XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;
+ errorCount += attr.Compile(h,info);
+ }
+ else if(obj is XmlSchemaAttributeGroupRef)
+ {
+ XmlSchemaAttributeGroupRef atgrp = (XmlSchemaAttributeGroupRef) obj;
+ errorCount += atgrp.Compile(h,info);
+ }
+ else
+ error(h,obj.GetType() +" is not valid in this place::SimpleConentExtension");
+ }
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+ //<extension
+ //base = QName
+ //id = ID
+ //{any attributes with non-schema namespace . . .}>
+ //Content: (annotation?, ((attribute | attributeGroup)*, anyAttribute?))
+ //</extension>
+ internal static XmlSchemaSimpleContentExtension Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaSimpleContentExtension extension = new XmlSchemaSimpleContentExtension();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaAttributeGroup.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ extension.LineNumber = reader.LineNumber;
+ extension.LinePosition = reader.LinePosition;
+ extension.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "base")
+ {
+ Exception innerex;
+ extension.baseTypeName= XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for base attribute",innerex);
+ }
+ else if(reader.Name == "id")
+ {
+ extension.Id = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for extension in this context",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,extension);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return extension;
+
+ //Content: 1.annotation?, 2.(attribute | attributeGroup)*, 3.anyAttribute?
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaSimpleContentExtension.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ extension.Annotation = annotation;
+ continue;
+ }
+ if(level <= 2)
+ {
+ if(reader.LocalName == "attribute")
+ {
+ level = 2;
+ XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader,h);
+ if(attr != null)
+ extension.Attributes.Add(attr);
+ continue;
+ }
+ if(reader.LocalName == "attributeGroup")
+ {
+ level = 2;
+ XmlSchemaAttributeGroupRef attr = XmlSchemaAttributeGroupRef.Read(reader,h);
+ if(attr != null)
+ extension.attributes.Add(attr);
+ continue;
+ }
+ }
+ if(level <= 3 && reader.LocalName == "anyAttribute")
+ {
+ level = 4;
+ XmlSchemaAnyAttribute anyattr = XmlSchemaAnyAttribute.Read(reader,h);
+ if(anyattr != null)
+ extension.AnyAttribute = anyattr;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return extension;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContentRestriction.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContentRestriction.cs
new file mode 100755
index 00000000000..f908b8788ed
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleContentRestriction.cs
@@ -0,0 +1,337 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaSimpleContentRestriction.
+ /// </summary>
+ public class XmlSchemaSimpleContentRestriction : XmlSchemaContent
+ {
+
+ private XmlSchemaAnyAttribute any;
+ private XmlSchemaObjectCollection attributes;
+ private XmlSchemaSimpleType baseType;
+ private XmlQualifiedName baseTypeName;
+ private XmlSchemaObjectCollection facets;
+ private static string xmlname = "restriction";
+
+ public XmlSchemaSimpleContentRestriction()
+ {
+ baseTypeName = XmlQualifiedName.Empty;
+ attributes = new XmlSchemaObjectCollection();
+ facets = new XmlSchemaObjectCollection();
+ }
+
+ [System.Xml.Serialization.XmlAttribute("base")]
+ public XmlQualifiedName BaseTypeName
+ {
+ get{ return baseTypeName; }
+ set{ baseTypeName = value; }
+ }
+
+ [XmlElement("simpleType",Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaSimpleType BaseType
+ {
+ get{ return baseType; }
+ set{ baseType = value; }
+ }
+
+ [XmlElement("minExclusive",typeof(XmlSchemaMinExclusiveFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("minInclusive",typeof(XmlSchemaMinInclusiveFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("maxExclusive",typeof(XmlSchemaMaxExclusiveFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("maxInclusive",typeof(XmlSchemaMaxInclusiveFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("totalDigits",typeof(XmlSchemaTotalDigitsFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("fractionDigits",typeof(XmlSchemaFractionDigitsFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("length",typeof(XmlSchemaLengthFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("minLength",typeof(XmlSchemaMinLengthFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("maxLength",typeof(XmlSchemaMaxLengthFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("enumeration",typeof(XmlSchemaEnumerationFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("whiteSpace",typeof(XmlSchemaWhiteSpaceFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("pattern",typeof(XmlSchemaPatternFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection Facets
+ {
+ get{ return facets; }
+ }
+
+ [XmlElement("attribute",typeof(XmlSchemaAttribute),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("attributeGroup",typeof(XmlSchemaAttributeGroupRef),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection Attributes
+ {
+ get{ return attributes; }
+ }
+
+ [XmlElement("anyAttribute",Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaAnyAttribute AnyAttribute
+ {
+ get{ return any; }
+ set{ any = value; }
+ }
+
+ ///<remarks>
+ /// 1. Base must be present and a QName
+ ///</remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ if(BaseTypeName == null || BaseTypeName.IsEmpty)
+ {
+ error(h, "base must be present and a QName");
+ }
+ else if(!XmlSchemaUtil.CheckQName(BaseTypeName))
+ error(h,"BaseTypeName must be a QName");
+
+ if(BaseType != null)
+ {
+ errorCount += BaseType.Compile(h,info);
+ }
+
+ if(this.AnyAttribute != null)
+ {
+ errorCount += AnyAttribute.Compile(h,info);
+ }
+
+ foreach(XmlSchemaObject obj in Attributes)
+ {
+ if(obj is XmlSchemaAttribute)
+ {
+ XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;
+ errorCount += attr.Compile(h,info);
+ }
+ else if(obj is XmlSchemaAttributeGroupRef)
+ {
+ XmlSchemaAttributeGroupRef atgrp = (XmlSchemaAttributeGroupRef) obj;
+ errorCount += atgrp.Compile(h,info);
+ }
+ else
+ error(h,obj.GetType() +" is not valid in this place::SimpleContentRestriction");
+ }
+
+ //TODO: Compile Facets: Looks like they are a part of datatypes. So we'll do them with the datatypes
+
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+
+ //<restriction
+ //base = QName
+ //id = ID
+ //{any attributes with non-schema namespace . . .}>
+ //Content: (annotation?, (simpleType?, (minExclusive | minInclusive | maxExclusive | maxInclusive | totalDigits | fractionDigits | length | minLength | maxLength | enumeration | whiteSpace | pattern)*)?, ((attribute | attributeGroup)*, anyAttribute?))
+ //</restriction>
+ internal static XmlSchemaSimpleContentRestriction Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaSimpleContentRestriction restriction = new XmlSchemaSimpleContentRestriction();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaComplexContentRestriction.Read, name="+reader.Name,null);
+ reader.SkipToEnd();
+ return null;
+ }
+
+ restriction.LineNumber = reader.LineNumber;
+ restriction.LinePosition = reader.LinePosition;
+ restriction.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "base")
+ {
+ Exception innerex;
+ restriction.baseTypeName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for base attribute",innerex);
+ }
+ else if(reader.Name == "id")
+ {
+ restriction.Id = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for restriction",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,restriction);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return restriction;
+
+ //Content: 1.annotation?,
+ // 2.simpleType?,
+ // 3.(minExclusive |...| enumeration | whiteSpace | pattern)*,
+ // 4.(attribute | attributeGroup)*,
+ // 5.anyAttribute?
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaSimpleContentRestriction.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ restriction.Annotation = annotation;
+ continue;
+ }
+ if(level <=2 && reader.LocalName == "simpleType")
+ {
+ level = 3;
+ XmlSchemaSimpleType stype = XmlSchemaSimpleType.Read(reader,h);
+ if(stype != null)
+ restriction.baseType = stype;
+ continue;
+ }
+ if(level <= 3)
+ {
+ if(reader.LocalName == "minExclusive")
+ {
+ level = 3;
+ XmlSchemaMinExclusiveFacet minex = XmlSchemaMinExclusiveFacet.Read(reader,h);
+ if(minex != null)
+ restriction.facets.Add(minex);
+ continue;
+ }
+ else if(reader.LocalName == "minInclusive")
+ {
+ level = 3;
+ XmlSchemaMinInclusiveFacet mini = XmlSchemaMinInclusiveFacet.Read(reader,h);
+ if(mini != null)
+ restriction.facets.Add(mini);
+ continue;
+ }
+ else if(reader.LocalName == "maxExclusive")
+ {
+ level = 3;
+ XmlSchemaMaxExclusiveFacet maxex = XmlSchemaMaxExclusiveFacet.Read(reader,h);
+ if(maxex != null)
+ restriction.facets.Add(maxex);
+ continue;
+ }
+ else if(reader.LocalName == "maxInclusive")
+ {
+ level = 3;
+ XmlSchemaMaxInclusiveFacet maxi = XmlSchemaMaxInclusiveFacet.Read(reader,h);
+ if(maxi != null)
+ restriction.facets.Add(maxi);
+ continue;
+ }
+ else if(reader.LocalName == "totalDigits")
+ {
+ level = 3;
+ XmlSchemaTotalDigitsFacet total = XmlSchemaTotalDigitsFacet.Read(reader,h);
+ if(total != null)
+ restriction.facets.Add(total);
+ continue;
+ }
+ else if(reader.LocalName == "fractionDigits")
+ {
+ level = 3;
+ XmlSchemaFractionDigitsFacet fraction = XmlSchemaFractionDigitsFacet.Read(reader,h);
+ if(fraction != null)
+ restriction.facets.Add(fraction);
+ continue;
+ }
+ else if(reader.LocalName == "length")
+ {
+ level = 3;
+ XmlSchemaLengthFacet length = XmlSchemaLengthFacet.Read(reader,h);
+ if(length != null)
+ restriction.facets.Add(length);
+ continue;
+ }
+ else if(reader.LocalName == "minLength")
+ {
+ level = 3;
+ XmlSchemaMinLengthFacet minlen = XmlSchemaMinLengthFacet.Read(reader,h);
+ if(minlen != null)
+ restriction.facets.Add(minlen);
+ continue;
+ }
+ else if(reader.LocalName == "maxLength")
+ {
+ level = 3;
+ XmlSchemaMaxLengthFacet maxlen = XmlSchemaMaxLengthFacet.Read(reader,h);
+ if(maxlen != null)
+ restriction.facets.Add(maxlen);
+ continue;
+ }
+ else if(reader.LocalName == "enumeration")
+ {
+ level = 3;
+ XmlSchemaEnumerationFacet enumeration = XmlSchemaEnumerationFacet.Read(reader,h);
+ if(enumeration != null)
+ restriction.facets.Add(enumeration);
+ continue;
+ }
+ else if(reader.LocalName == "whiteSpace")
+ {
+ level = 3;
+ XmlSchemaWhiteSpaceFacet ws = XmlSchemaWhiteSpaceFacet.Read(reader,h);
+ if(ws != null)
+ restriction.facets.Add(ws);
+ continue;
+ }
+ else if(reader.LocalName == "pattern")
+ {
+ level = 3;
+ XmlSchemaPatternFacet pattern = XmlSchemaPatternFacet.Read(reader,h);
+ if(pattern != null)
+ restriction.facets.Add(pattern);
+ continue;
+ }
+ }
+ if(level <= 4)
+ {
+ if(reader.LocalName == "attribute")
+ {
+ level = 4;
+ XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader,h);
+ if(attr != null)
+ restriction.Attributes.Add(attr);
+ continue;
+ }
+ if(reader.LocalName == "attributeGroup")
+ {
+ level = 4;
+ XmlSchemaAttributeGroupRef attr = XmlSchemaAttributeGroupRef.Read(reader,h);
+ if(attr != null)
+ restriction.attributes.Add(attr);
+ continue;
+ }
+ }
+ if(level <= 5 && reader.LocalName == "anyAttribute")
+ {
+ level = 6;
+ XmlSchemaAnyAttribute anyattr = XmlSchemaAnyAttribute.Read(reader,h);
+ if(anyattr != null)
+ restriction.AnyAttribute = anyattr;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return restriction;
+ }
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleType.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleType.cs
new file mode 100755
index 00000000000..81007f59a63
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleType.cs
@@ -0,0 +1,237 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaSimpleType.
+ /// </summary>
+ public class XmlSchemaSimpleType : XmlSchemaType
+ {
+ private XmlSchemaSimpleTypeContent content;
+ //compilation vars
+ internal bool islocal = true; // Assuming local means we have to specify islocal=false only in XmlSchema
+ private static string xmlname = "simpleType";
+
+ public XmlSchemaSimpleType()
+ {
+ }
+
+ [XmlElement("restriction",typeof(XmlSchemaSimpleTypeRestriction),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("list",typeof(XmlSchemaSimpleTypeList),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("union",typeof(XmlSchemaSimpleTypeUnion),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaSimpleTypeContent Content
+ {
+ get{ return content; }
+ set{ content = value; }
+ }
+
+ /// <remarks>
+ /// For a simple Type:
+ /// 1. Content must be present
+ /// 2. id if present, must have be a valid ID
+ /// a) If the simpletype is local
+ /// 1- are from <xs:complexType name="simpleType"> and <xs:complexType name="localSimpleType">
+ /// 1. name is prohibited
+ /// 2. final is prohibited
+ /// b) If the simpletype is toplevel
+ /// 1- are from <xs:complexType name="simpleType"> and <xs:complexType name="topLevelSimpleType">
+ /// 1. name is required, type must be NCName
+ /// 2. Content is required
+ /// 3. final can have values : #all | (list | union | restriction)
+ /// 4. If final is set, finalResolved is same as final (but within the values of b.3)
+ /// 5. If final is not set, the finalDefault of the schema (ie. only #all and restriction)
+ /// 6. Base type is:
+ /// 4.1 If restriction is chosen,the base type of restriction or elements
+ /// 4.2 otherwise simple ur-type
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ errorCount = 0;
+
+ if(this.islocal) // a
+ {
+ if(this.Name != null) // a.1
+ error(h,"Name is prohibited in a local simpletype");
+ if(this.Final != XmlSchemaDerivationMethod.None) //a.2
+ error(h,"Final is prohibited in a local simpletype");
+ }
+ else //b
+ {
+ if(this.Name == null) //b.1
+ error(h,"Name is required in top level simpletype");
+ else if(!XmlSchemaUtil.CheckNCName(this.Name)) // b.1.2
+ error(h,"name attribute of a simpleType must be NCName");
+ else
+ this.qName = new XmlQualifiedName(this.Name,info.TargetNamespace);
+
+ //NOTE: Although the FinalResolved can be Empty, it is not a valid value for Final
+ //DEVIATION: If an error occurs, the finaldefault is always consulted. This deviates
+ // from the way MS implementation works.
+ switch(this.Final) //b.3, b.4
+ {
+ case XmlSchemaDerivationMethod.All:
+ this.finalResolved = XmlSchemaDerivationMethod.All;
+ break;
+ case XmlSchemaDerivationMethod.List:
+ this.finalResolved = XmlSchemaDerivationMethod.List;
+ break;
+ case XmlSchemaDerivationMethod.Union:
+ this.finalResolved = XmlSchemaDerivationMethod.Union;
+ break;
+ case XmlSchemaDerivationMethod.Restriction:
+ this.finalResolved = XmlSchemaDerivationMethod.Restriction;
+ break;
+ default:
+ error(h,"The value of final attribute is not valid for simpleType");
+ goto case XmlSchemaDerivationMethod.None;
+ // use assignment from finaldefault on schema.
+ case XmlSchemaDerivationMethod.None: // b.5
+ if(info.FinalDefault == XmlSchemaDerivationMethod.All)
+ finalResolved = XmlSchemaDerivationMethod.All;
+ else
+ finalResolved = info.FinalDefault & (XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.List |
+ XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Union );
+ break;
+ }
+ }
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ if(this.Content == null) //a.3,b.2
+ error(h,"Content is required in a simpletype");
+ else if(Content is XmlSchemaSimpleTypeRestriction)
+ {
+ errorCount += ((XmlSchemaSimpleTypeRestriction)Content).Compile(h,info);
+ }
+ else if(Content is XmlSchemaSimpleTypeList)
+ {
+ errorCount += ((XmlSchemaSimpleTypeList)Content).Compile(h,info);
+ }
+ else if(Content is XmlSchemaSimpleTypeUnion)
+ {
+ errorCount += ((XmlSchemaSimpleTypeUnion)Content).Compile(h,info);
+ }
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ if(isCompiled)
+ return errorCount;
+
+ return errorCount;
+ }
+
+ //<simpleType
+ // final = (#all | (list | union | restriction))
+ // id = ID
+ // name = NCName
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, (restriction | list | union))
+ //</simpleType>
+ internal static XmlSchemaSimpleType Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaSimpleType stype = new XmlSchemaSimpleType();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaGroup.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ stype.LineNumber = reader.LineNumber;
+ stype.LinePosition = reader.LinePosition;
+ stype.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "final")
+ {
+ Exception innerex;
+ stype.Final = XmlSchemaUtil.ReadDerivationAttribute(reader, out innerex, "final");
+ if(innerex != null)
+ error(h, "some invalid values not a valid value for final", innerex);
+ }
+ else if(reader.Name == "id")
+ {
+ stype.Id = reader.Value;
+ }
+ else if(reader.Name == "name")
+ {
+ stype.Name = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for simpleType",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,stype);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return stype;
+
+ // Content: (annotation?, (restriction | list | union))
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaSimpleType.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ stype.Annotation = annotation;
+ continue;
+ }
+ if(level <= 2)
+ {
+ if(reader.LocalName == "restriction")
+ {
+ level = 3;
+ XmlSchemaSimpleTypeRestriction restriction = XmlSchemaSimpleTypeRestriction.Read(reader,h);
+ if(restriction != null)
+ stype.content = restriction;
+ continue;
+ }
+ if(reader.LocalName == "list")
+ {
+ level = 3;
+ XmlSchemaSimpleTypeList list = XmlSchemaSimpleTypeList.Read(reader,h);
+ if(list != null)
+ stype.content = list;
+ continue;
+ }
+ if(reader.LocalName == "union")
+ {
+ level = 3;
+ XmlSchemaSimpleTypeUnion union = XmlSchemaSimpleTypeUnion.Read(reader,h);
+ if(union != null)
+ stype.content = union;
+ continue;
+ }
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return stype;
+ }
+
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeContent.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeContent.cs
new file mode 100755
index 00000000000..6068361768c
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeContent.cs
@@ -0,0 +1,17 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaSimpleTypeContent.
+ /// </summary>
+ public abstract class XmlSchemaSimpleTypeContent : XmlSchemaAnnotated
+ {
+ protected XmlSchemaSimpleTypeContent()
+ {
+ }
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeList.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeList.cs
new file mode 100755
index 00000000000..dea8741a540
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeList.cs
@@ -0,0 +1,152 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaSimpleTypeList.
+ /// </summary>
+ public class XmlSchemaSimpleTypeList : XmlSchemaSimpleTypeContent
+ {
+ private XmlSchemaSimpleType itemType;
+ private XmlQualifiedName itemTypeName;
+ private static string xmlname = "list";
+
+ public XmlSchemaSimpleTypeList()
+ {
+ this.ItemTypeName = XmlQualifiedName.Empty;
+ }
+
+ [System.Xml.Serialization.XmlAttribute("itemType")]
+ public XmlQualifiedName ItemTypeName
+ {
+ get{ return itemTypeName; }
+ set
+ {
+ itemTypeName = value;
+ }
+ }
+
+ [XmlElement("simpleType",Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaSimpleType ItemType
+ {
+ get{ return itemType; }
+ set
+ {
+ itemType = value;
+ }
+ }
+ /// <remarks>
+ /// 1. One of itemType or a <simpleType> must be present, but not both.
+ /// 2. id must be of type ID
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ errorCount = 0;
+
+ if(ItemType != null && !ItemTypeName.IsEmpty)
+ error(h, "both itemType and simpletype can't be present");
+ if(ItemType == null && ItemTypeName.IsEmpty)
+ error(h, "one of itemType or simpletype must be present");
+ if(ItemType != null)
+ {
+ errorCount += ItemType.Compile(h,info);
+ }
+ if(!XmlSchemaUtil.CheckQName(ItemTypeName))
+ error(h,"BaseTypeName must be a XmlQualifiedName");
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+ //<list
+ // id = ID
+ // itemType = QName
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, (simpleType?))
+ //</list>
+ internal static XmlSchemaSimpleTypeList Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaSimpleTypeList list = new XmlSchemaSimpleTypeList();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaSimpleTypeList.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ list.LineNumber = reader.LineNumber;
+ list.LinePosition = reader.LinePosition;
+ list.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ list.Id = reader.Value;
+ }
+ else if(reader.Name == "itemType")
+ {
+ Exception innerex;
+ list.ItemTypeName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for itemType attribute",innerex);
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for list",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,list);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return list;
+ // Content: annotation?, simpleType?
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaSimpleTypeList.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ list.Annotation = annotation;
+ continue;
+ }
+ if(level <= 2 && reader.LocalName == "simpleType")
+ {
+ level = 3;
+ XmlSchemaSimpleType stype = XmlSchemaSimpleType.Read(reader,h);
+ if(stype != null)
+ list.itemType = stype;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return list;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeRestriction.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeRestriction.cs
new file mode 100755
index 00000000000..b3f78b77129
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeRestriction.cs
@@ -0,0 +1,267 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaSimpleTypeRestriction.
+ /// </summary>
+ public class XmlSchemaSimpleTypeRestriction : XmlSchemaSimpleTypeContent
+ {
+ private XmlSchemaSimpleType baseType;
+ private XmlQualifiedName baseTypeName;
+ private XmlSchemaObjectCollection facets;
+ private static string xmlname = "restriction";
+
+ public XmlSchemaSimpleTypeRestriction()
+ {
+ baseTypeName = XmlQualifiedName.Empty;
+ facets = new XmlSchemaObjectCollection();
+ }
+
+ [System.Xml.Serialization.XmlAttribute("base")]
+ public XmlQualifiedName BaseTypeName
+ {
+ get{ return baseTypeName; }
+ set{ baseTypeName = value; }
+ }
+
+ [XmlElement("simpleType",Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaSimpleType BaseType
+ {
+ get{ return baseType; }
+ set{ baseType = value; }
+ }
+
+ [XmlElement("minExclusive",typeof(XmlSchemaMinExclusiveFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("minInclusive",typeof(XmlSchemaMinInclusiveFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("maxExclusive",typeof(XmlSchemaMaxExclusiveFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("maxInclusive",typeof(XmlSchemaMaxInclusiveFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("totalDigits",typeof(XmlSchemaTotalDigitsFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("fractionDigits",typeof(XmlSchemaFractionDigitsFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("length",typeof(XmlSchemaLengthFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("minLength",typeof(XmlSchemaMinLengthFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("maxLength",typeof(XmlSchemaMaxLengthFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("enumeration",typeof(XmlSchemaEnumerationFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("whiteSpace",typeof(XmlSchemaWhiteSpaceFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ [XmlElement("pattern",typeof(XmlSchemaPatternFacet),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection Facets
+ {
+ get{ return facets; }
+ }
+
+ /// <remarks>
+ /// 1. One of base or simpletype must be present but not both
+ /// 2. id must be a valid ID
+ /// 3. base must be a valid QName *NO CHECK REQUIRED*
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ errorCount = 0;
+
+ if(this.baseType != null && !this.BaseTypeName.IsEmpty)
+ error(h, "both base and simpletype can't be set");
+ if(this.baseType == null && this.BaseTypeName.IsEmpty)
+ error(h, "one of basetype or simpletype must be present");
+ if(this.baseType != null)
+ {
+ errorCount += this.baseType.Compile(h,info);
+ }
+ if(!XmlSchemaUtil.CheckQName(BaseTypeName))
+ error(h,"BaseTypeName must be a XmlQualifiedName");
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+ //<restriction
+ // base = QName
+ // id = ID
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, (simpleType?, (minExclusive | minInclusive | maxExclusive | maxInclusive | totalDigits | fractionDigits | length | minLength | maxLength | enumeration | whiteSpace | pattern)*))
+ //</restriction>
+ internal static XmlSchemaSimpleTypeRestriction Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaSimpleTypeRestriction.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ restriction.LineNumber = reader.LineNumber;
+ restriction.LinePosition = reader.LinePosition;
+ restriction.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ restriction.Id = reader.Value;
+ }
+ else if(reader.Name == "base")
+ {
+ Exception innerex;
+ restriction.baseTypeName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for base attribute",innerex);
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for restriction",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,restriction);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return restriction;
+
+ // Content: annotation?, simpleType?, (minExclusive |. .. | pattern)*
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaSimpleTypeRestriction.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ restriction.Annotation = annotation;
+ continue;
+ }
+ if(level <= 2 && reader.LocalName == "simpleType")
+ {
+ level = 3;
+ XmlSchemaSimpleType stype = XmlSchemaSimpleType.Read(reader,h);
+ if(stype != null)
+ restriction.baseType = stype;
+ continue;
+ }
+ if(level <= 3)
+ {
+ if(reader.LocalName == "minExclusive")
+ {
+ level = 3;
+ XmlSchemaMinExclusiveFacet minex = XmlSchemaMinExclusiveFacet.Read(reader,h);
+ if(minex != null)
+ restriction.facets.Add(minex);
+ continue;
+ }
+ else if(reader.LocalName == "minInclusive")
+ {
+ level = 3;
+ XmlSchemaMinInclusiveFacet mini = XmlSchemaMinInclusiveFacet.Read(reader,h);
+ if(mini != null)
+ restriction.facets.Add(mini);
+ continue;
+ }
+ else if(reader.LocalName == "maxExclusive")
+ {
+ level = 3;
+ XmlSchemaMaxExclusiveFacet maxex = XmlSchemaMaxExclusiveFacet.Read(reader,h);
+ if(maxex != null)
+ restriction.facets.Add(maxex);
+ continue;
+ }
+ else if(reader.LocalName == "maxInclusive")
+ {
+ level = 3;
+ XmlSchemaMaxInclusiveFacet maxi = XmlSchemaMaxInclusiveFacet.Read(reader,h);
+ if(maxi != null)
+ restriction.facets.Add(maxi);
+ continue;
+ }
+ else if(reader.LocalName == "totalDigits")
+ {
+ level = 3;
+ XmlSchemaTotalDigitsFacet total = XmlSchemaTotalDigitsFacet.Read(reader,h);
+ if(total != null)
+ restriction.facets.Add(total);
+ continue;
+ }
+ else if(reader.LocalName == "fractionDigits")
+ {
+ level = 3;
+ XmlSchemaFractionDigitsFacet fraction = XmlSchemaFractionDigitsFacet.Read(reader,h);
+ if(fraction != null)
+ restriction.facets.Add(fraction);
+ continue;
+ }
+ else if(reader.LocalName == "length")
+ {
+ level = 3;
+ XmlSchemaLengthFacet length = XmlSchemaLengthFacet.Read(reader,h);
+ if(length != null)
+ restriction.facets.Add(length);
+ continue;
+ }
+ else if(reader.LocalName == "minLength")
+ {
+ level = 3;
+ XmlSchemaMinLengthFacet minlen = XmlSchemaMinLengthFacet.Read(reader,h);
+ if(minlen != null)
+ restriction.facets.Add(minlen);
+ continue;
+ }
+ else if(reader.LocalName == "maxLength")
+ {
+ level = 3;
+ XmlSchemaMaxLengthFacet maxlen = XmlSchemaMaxLengthFacet.Read(reader,h);
+ if(maxlen != null)
+ restriction.facets.Add(maxlen);
+ continue;
+ }
+ else if(reader.LocalName == "enumeration")
+ {
+ level = 3;
+ XmlSchemaEnumerationFacet enumeration = XmlSchemaEnumerationFacet.Read(reader,h);
+ if(enumeration != null)
+ restriction.facets.Add(enumeration);
+ continue;
+ }
+ else if(reader.LocalName == "whiteSpace")
+ {
+ level = 3;
+ XmlSchemaWhiteSpaceFacet ws = XmlSchemaWhiteSpaceFacet.Read(reader,h);
+ if(ws != null)
+ restriction.facets.Add(ws);
+ continue;
+ }
+ else if(reader.LocalName == "pattern")
+ {
+ level = 3;
+ XmlSchemaPatternFacet pattern = XmlSchemaPatternFacet.Read(reader,h);
+ if(pattern != null)
+ restriction.facets.Add(pattern);
+ continue;
+ }
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return restriction;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeUnion.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeUnion.cs
new file mode 100755
index 00000000000..f6279ad6bf3
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaSimpleTypeUnion.cs
@@ -0,0 +1,175 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaSimpleTypeUnion.
+ /// </summary>
+ public class XmlSchemaSimpleTypeUnion : XmlSchemaSimpleTypeContent
+ {
+ private XmlSchemaObjectCollection baseTypes;
+ private XmlQualifiedName[] memberTypes;
+ private static string xmlname = "union";
+
+ public XmlSchemaSimpleTypeUnion()
+ {
+ baseTypes = new XmlSchemaObjectCollection();
+ }
+
+ [XmlElement("simpleType",typeof(XmlSchemaSimpleType),Namespace="http://www.w3.org/2001/XMLSchema")]
+ public XmlSchemaObjectCollection BaseTypes
+ {
+ get{ return baseTypes; }
+ }
+
+ [System.Xml.Serialization.XmlAttribute("memberTypes")]
+ public XmlQualifiedName[] MemberTypes
+ {
+ get{ return memberTypes; }
+ set{ memberTypes = value; }
+ }
+ /// <remarks>
+ /// 1. Circular union type definition is disallowed. (WTH is this?)
+ /// 2. id must be a valid ID
+ /// </remarks>
+ [MonoTODO]
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ errorCount = 0;
+
+ int count = BaseTypes.Count;
+
+ foreach(XmlSchemaObject obj in baseTypes)
+ {
+ if(obj != null && obj is XmlSchemaSimpleType)
+ {
+ XmlSchemaSimpleType stype = (XmlSchemaSimpleType) obj;
+ errorCount += stype.Compile(h,info);
+ }
+ else
+ {
+ error(h, "baseTypes can't have objects other than a simpletype");
+ }
+ }
+
+ if(memberTypes!=null)
+ {
+ for(int i=0; i< memberTypes.Length; i++)
+ {
+ if(memberTypes[i] == null || !XmlSchemaUtil.CheckQName(MemberTypes[i]))
+ {
+ warn(h,"Invalid membertype");
+ memberTypes[i] = XmlQualifiedName.Empty;
+ }
+ else
+ {
+ count += MemberTypes.Length;
+ }
+ }
+ }
+
+ if(count == 0)
+ error(h, "Atleast one simpletype or membertype must be present");
+
+ XmlSchemaUtil.CompileID(Id,this,info.IDCollection,h);
+
+ return errorCount;
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+ //<union
+ // id = ID
+ // memberTypes = List of QName
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, (simpleType*))
+ //</union>
+ internal static XmlSchemaSimpleTypeUnion Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaSimpleTypeUnion union = new XmlSchemaSimpleTypeUnion();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaSimpleTypeUnion.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ union.LineNumber = reader.LineNumber;
+ union.LinePosition = reader.LinePosition;
+ union.SourceUri = reader.BaseURI;
+
+ //Read Attributes
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ union.Id = reader.Value;
+ }
+ else if(reader.Name == "memberTypes")
+ {
+ Exception innerEx;
+ string[] names = XmlSchemaUtil.SplitList(reader.Value);
+ union.memberTypes = new XmlQualifiedName[names.Length];
+ for(int i=0;i<names.Length;i++)
+ {
+ union.memberTypes[i] = XmlSchemaUtil.ToQName(reader,names[i],out innerEx);
+ if(innerEx != null)
+ error(h,"'"+names[i] + "' is not a valid memberType",innerEx);
+ }
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for union",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,union);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return union;
+
+ // Content: annotation?, simpleType*
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaSimpleTypeUnion.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ union.Annotation = annotation;
+ continue;
+ }
+ if(level <=2 && reader.LocalName == "simpleType")
+ {
+ level = 2;
+ XmlSchemaSimpleType stype = XmlSchemaSimpleType.Read(reader,h);
+ if(stype != null)
+ union.baseTypes.Add(stype);
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return union;
+ }
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaTotalDigitsFacet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaTotalDigitsFacet.cs
new file mode 100755
index 00000000000..d7ef688b549
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaTotalDigitsFacet.cs
@@ -0,0 +1,96 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaTotalDigitsFacet.
+ /// </summary>
+ public class XmlSchemaTotalDigitsFacet : XmlSchemaNumericFacet
+ {
+ private static string xmlname = "totalDigits";
+
+ public XmlSchemaTotalDigitsFacet()
+ {
+ }
+ //<totalDigits
+ // fixed = boolean : false
+ // id = ID
+ // value = positiveInteger
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</totalDigits>
+ internal static XmlSchemaTotalDigitsFacet Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaTotalDigitsFacet td = new XmlSchemaTotalDigitsFacet();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaTotalDigitsFacet.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ td.LineNumber = reader.LineNumber;
+ td.LinePosition = reader.LinePosition;
+ td.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ td.Id = reader.Value;
+ }
+ else if(reader.Name == "fixed")
+ {
+ Exception innerex;
+ td.IsFixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for fixed attribute",innerex);
+ }
+ else if(reader.Name == "value")
+ {
+ td.Value = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,td);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return td;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaTotalDigitsFacet.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ td.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return td;
+ }
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaType.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaType.cs
new file mode 100755
index 00000000000..e1a24b97c17
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaType.cs
@@ -0,0 +1,81 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+using System.ComponentModel;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaType.
+ /// </summary>
+ public class XmlSchemaType : XmlSchemaAnnotated
+ {
+ private object baseSchemaType;
+ private XmlSchemaDatatype datatype;
+ private XmlSchemaDerivationMethod derivedBy;
+ private XmlSchemaDerivationMethod final;
+ internal XmlSchemaDerivationMethod finalResolved;
+ private bool isMixed;
+ private string name;
+ internal XmlQualifiedName qName;
+
+ public XmlSchemaType()
+ {
+ final = XmlSchemaDerivationMethod.None;
+ qName = XmlQualifiedName.Empty;
+ }
+
+ #region Attributes
+ [System.Xml.Serialization.XmlAttribute("name")]
+ public string Name
+ {
+ get{ return name; }
+ set{ name = value; }
+ }
+ [DefaultValue(XmlSchemaDerivationMethod.None)]
+ [System.Xml.Serialization.XmlAttribute("final")]
+ public XmlSchemaDerivationMethod Final
+ {
+ get{ return final; }
+ set{ final = value; }
+ }
+ [XmlIgnore]
+ public XmlQualifiedName QualifiedName
+ {
+ get{ return qName; }
+ }
+ [XmlIgnore]
+ public XmlSchemaDerivationMethod FinalResolved
+ {
+ get{ return finalResolved; }
+ }
+ [XmlIgnore]
+ public object BaseSchemaType
+ {
+ get{ return baseSchemaType; }
+ }
+ [XmlIgnore]
+ public XmlSchemaDerivationMethod DerivedBy
+ {
+ get{ return derivedBy; }
+ }
+ [XmlIgnore]
+ public XmlSchemaDatatype Datatype
+ {
+ get{ return datatype; }
+ }
+ #endregion
+
+ #region XmlIgnore
+ [XmlIgnore]
+ public virtual bool IsMixed
+ {
+ get{ return isMixed; }
+ set{ isMixed = value; }
+ }
+ #endregion
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaUnique.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaUnique.cs
new file mode 100755
index 00000000000..bb8fd7a6e0d
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaUnique.cs
@@ -0,0 +1,126 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaUnique.
+ /// </summary>
+ public class XmlSchemaUnique : XmlSchemaIdentityConstraint
+ {
+ private static string xmlname = "unique";
+
+ public XmlSchemaUnique()
+ {
+ }
+ /// <remarks>
+ /// 1. name must be present
+ /// 2. selector and field must be present
+ /// </remarks>
+ [MonoTODO]
+ internal new int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ return base.Compile(h,info);
+ }
+
+ [MonoTODO]
+ internal int Validate(ValidationEventHandler h)
+ {
+ return errorCount;
+ }
+
+ internal new void error(ValidationEventHandler handle, string message)
+ {
+ errorCount++;
+ ValidationHandler.RaiseValidationError(handle, this, message);
+ }
+ //<unique
+ // id = ID
+ // name = NCName
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?, (selector, field+))
+ //</unique>
+ internal static XmlSchemaUnique Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaUnique unique = new XmlSchemaUnique();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaUnique.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ unique.LineNumber = reader.LineNumber;
+ unique.LinePosition = reader.LinePosition;
+ unique.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ unique.Id = reader.Value;
+ }
+ else if(reader.Name == "name")
+ {
+ unique.Name = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for unique",null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,unique);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return unique;
+
+ // Content: annotation?, selector, field+
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaUnion.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ unique.Annotation = annotation;
+ continue;
+ }
+ if(level <= 2 && reader.LocalName == "selector")
+ {
+ level = 3;
+ XmlSchemaXPath selector = XmlSchemaXPath.Read(reader,h,"selector");
+ if(selector != null)
+ unique.Selector = selector;
+ continue;
+ }
+ if(level <= 3 && reader.LocalName == "field")
+ {
+ level = 3;
+ if(unique.Selector == null)
+ error(h,"selector must be defined before field declarations",null);
+ XmlSchemaXPath field = XmlSchemaXPath.Read(reader,h,"field");
+ if(field != null)
+ unique.Fields.Add(field);
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return unique;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaUse.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaUse.cs
new file mode 100755
index 00000000000..8015edd8ed2
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaUse.cs
@@ -0,0 +1,22 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaUse.
+ /// </summary>
+ public enum XmlSchemaUse
+ {
+ [XmlIgnore]
+ None = 0x00000000,
+ [XmlEnum("optional")]
+ Optional = 0x00000001,
+ [XmlEnum("prohibited")]
+ Prohibited = 0x00000002,
+ [XmlEnum("required")]
+ Required = 0x00000003,
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaUtil.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaUtil.cs
new file mode 100755
index 00000000000..dc6a7c6a64d
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaUtil.cs
@@ -0,0 +1,299 @@
+using System;
+using System.Xml;
+using System.Collections;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// All Methods in this class should use XmlConvert. Some Methods are not present in the
+ /// MS Implementation. We should provide them.
+ /// </summary>
+ internal class XmlSchemaUtil
+ {
+ private XmlSchemaUtil()
+ {}
+
+ public static void CompileID(string id, XmlSchemaObject xso, Hashtable idCollection, ValidationEventHandler h)
+ {
+ //check if the string conforms to http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#ID
+ // 1. ID must be a NCName
+ // 2. ID must be unique in the schema
+ if(id == null)
+ return;
+ if(!CheckNCName(id))
+ xso.error(h,id+" is not a valid id attribute");
+ else if(idCollection.ContainsKey(id))
+ xso.error(h,"Duplicate id attribute "+id);
+ else
+ idCollection.Add(id,xso);
+ }
+
+ [MonoTODO]
+ public static bool CheckAnyUri(string uri)
+ {
+ return true;
+ }
+
+ public static bool CheckToken(string token)
+ {
+ //check if the string conforms to http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#token
+ return true;
+ }
+
+ public static bool CheckNormalizedString(string token)
+ {
+ return true;
+ }
+
+ public static bool CheckLanguage(string lang)
+ {
+ //check if the string conforms to http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#language
+ return true;
+ }
+ public static bool CheckNCName(string name)
+ {
+ //check if the string conforms to http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#NCName
+ try
+ {
+ XmlConvert.VerifyNCName(name);
+ return true;
+ }
+ catch(Exception ex)
+ {
+ return false;
+ }
+ }
+
+ public static bool CheckQName(XmlQualifiedName qname)
+ {
+ return true;
+ }
+ public static bool IsValidQName(string qname)
+ {
+ foreach(string part in qname.Split(new char[]{':'},2))
+ {
+ if(!CheckNCName(part))
+ return false;
+ }
+ return true;
+ }
+
+ //FIXME: First remove all the multiple instances of whitespace and then return the strings.
+ //The current method returns empty strings if there are two or more consecutive whitespaces.
+ public static string[] SplitList(string list)
+ {
+ if(list == null || list == string.Empty)
+ return new String[0];
+
+ string[] listarr = list.Split(new char[]{' ','\t','\n'});
+ int pos=0;
+ int i = 0;
+ for(i=0;i<listarr.Length;i++)
+ {
+ if(listarr[i] != null && listarr[i] != String.Empty)
+ {
+ listarr[pos++] = listarr[i];
+ }
+ }
+ if(pos == i)
+ return listarr;
+ string[] retarr = new String[pos];
+ if(pos!=0)
+ Array.Copy(listarr, retarr, pos);
+ return retarr;
+ }
+
+ public static void ReadUnhandledAttribute(XmlReader reader, XmlSchemaObject xso)
+ {
+ if(reader.Prefix == "xmlns")
+ xso.Namespaces.Add(reader.LocalName, reader.Value);
+ else if(reader.Name == "xmlns")
+ xso.Namespaces.Add("",reader.Value);
+ else
+ {
+ if(xso.unhandledAttributeList == null)
+ xso.unhandledAttributeList = new System.Collections.ArrayList();
+ XmlAttribute attr = new XmlDocument().CreateAttribute(reader.LocalName,reader.NamespaceURI);
+ attr.Value = reader.Value;
+ xso.unhandledAttributeList.Add(attr);
+ }
+ }
+
+ public static bool ReadBoolAttribute(XmlReader reader, out Exception innerExcpetion)
+ {
+ innerExcpetion = null;
+ try
+ {
+ bool val = XmlConvert.ToBoolean(reader.Value);
+ return val;
+ }
+ catch(Exception ex)
+ {
+ innerExcpetion = ex;
+ return false;
+ }
+ }
+ public static decimal ReadDecimalAttribute(XmlReader reader, out Exception innerExcpetion)
+ {
+ innerExcpetion = null;
+ try
+ {
+ decimal val = XmlConvert.ToDecimal(reader.Value);
+ return val;
+ }
+ catch(Exception ex)
+ {
+ innerExcpetion = ex;
+ return decimal.Zero;
+ }
+ }
+
+ // Is some value is read, return it.
+ // If no values return empty.
+ // If exception, return none
+ public static XmlSchemaDerivationMethod ReadDerivationAttribute(XmlReader reader, out Exception innerExcpetion, string name)
+ {
+ innerExcpetion = null;
+ try
+ {
+ string list = reader.Value;
+ string warn = "";
+ XmlSchemaDerivationMethod val = 0;
+
+ if(list.IndexOf("#all") != -1 && list.Trim() != "#all")
+ {
+ innerExcpetion = new Exception(list+" is not a valid value for "+ name +". #all if present must be the only value");
+ return XmlSchemaDerivationMethod.All;
+ }
+ foreach(string xsdm in XmlSchemaUtil.SplitList(list))
+ {
+ switch(xsdm)
+ {
+ case "":
+ val |= XmlSchemaDerivationMethod.Empty; break;
+ case "#all":
+ val |= XmlSchemaDerivationMethod.All; break;
+ case "substitution":
+ val |= XmlSchemaDerivationMethod.Substitution; break;
+ case "extension":
+ val |= XmlSchemaDerivationMethod.Extension; break;
+ case "restriction":
+ val |= XmlSchemaDerivationMethod.Restriction; break;
+ case "list":
+ val |= XmlSchemaDerivationMethod.List; break;
+ case "union":
+ val |= XmlSchemaDerivationMethod.Union; break;
+ default:
+ warn += xsdm + " "; break;
+ }
+ }
+ if(warn != "")
+ innerExcpetion = new Exception(warn + "is/are not valid values for " + name);
+ return val;
+ }
+ catch(Exception ex)
+ {
+ innerExcpetion = ex;
+ return XmlSchemaDerivationMethod.None;
+ }
+ }
+
+ public static XmlSchemaForm ReadFormAttribute(XmlReader reader, out Exception innerExcpetion)
+ {
+ innerExcpetion = null;
+ XmlSchemaForm val = XmlSchemaForm.None;
+ switch(reader.Value)
+ {
+ case "qualified":
+ val = XmlSchemaForm.Qualified; break;
+ case "unqualified":
+ val = XmlSchemaForm.Unqualified; break;
+ default:
+ innerExcpetion = new Exception("only qualified or unqulified is a valid value"); break;
+ }
+ return val;
+ }
+
+ public static XmlSchemaContentProcessing ReadProcessingAttribute(XmlReader reader, out Exception innerExcpetion)
+ {
+ innerExcpetion = null;
+ XmlSchemaContentProcessing val = XmlSchemaContentProcessing.None;
+ switch(reader.Value)
+ {
+ case "lax":
+ val = XmlSchemaContentProcessing.Lax; break;
+ case "strict":
+ val = XmlSchemaContentProcessing.Strict; break;
+ case "skip":
+ val = XmlSchemaContentProcessing.Skip; break;
+ default:
+ innerExcpetion = new Exception("only lax , strict or skip are valid values for processContents");
+ break;
+ }
+ return val;
+ }
+
+ public static XmlSchemaUse ReadUseAttribute(XmlReader reader, out Exception innerExcpetion)
+ {
+ innerExcpetion = null;
+ XmlSchemaUse val = XmlSchemaUse.None;
+ switch(reader.Value)
+ {
+ case "optional":
+ val = XmlSchemaUse.Optional; break;
+ case "prohibited":
+ val = XmlSchemaUse.Prohibited; break;
+ case "required":
+ val = XmlSchemaUse.Required; break;
+ default:
+ innerExcpetion = new Exception("only optional , prohibited or required are valid values for use");
+ break;
+ }
+ return val;
+ }
+ public static XmlQualifiedName ReadQNameAttribute(XmlReader reader, out Exception innerEx)
+ {
+ return ToQName(reader, reader.Value, out innerEx);
+ }
+
+ //While Creating a XmlQualifedName, we should check:
+ // 1. If a prefix is present, its namespace should be resolvable.
+ // 2. If a prefix is not present, and if the defaultNamespace is set,
+ public static XmlQualifiedName ToQName(XmlReader reader, string qnamestr, out Exception innerEx)
+ {
+
+ string ns;
+ string name;
+ XmlQualifiedName qname;
+ innerEx = null;
+
+ if(!IsValidQName(qnamestr))
+ {
+ innerEx = new Exception(qnamestr + " is an invalid QName. Either name or namespace is not a NCName");
+ return XmlQualifiedName.Empty;
+ }
+
+ string[] values = qnamestr.Split(new char[]{':'},2);
+
+ if(values.Length == 2)
+ {
+ ns = reader.LookupNamespace(values[0]);
+ if(ns == null)
+ {
+ innerEx = new Exception("Namespace Prefix '"+values[0]+"could not be resolved");
+ return XmlQualifiedName.Empty;
+ }
+ name = values[1];
+ }
+ else
+ {
+ //Default Namespace
+ ns = reader.LookupNamespace("");
+ name = values[0];
+ }
+
+ qname = new XmlQualifiedName(name,ns);
+ return qname;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaWhiteSpaceFacet.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaWhiteSpaceFacet.cs
new file mode 100755
index 00000000000..df39caba223
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaWhiteSpaceFacet.cs
@@ -0,0 +1,97 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaWhiteSpaceFacet.
+ /// </summary>
+ public class XmlSchemaWhiteSpaceFacet : XmlSchemaFacet
+ {
+ private static string xmlname = "whiteSpace";
+
+ public XmlSchemaWhiteSpaceFacet()
+ {
+ }
+ // <whiteSpace
+ // fixed = boolean : false
+ // id = ID
+ // value = (collapse | preserve | replace)
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ // </whiteSpace>
+ internal static XmlSchemaWhiteSpaceFacet Read(XmlSchemaReader reader, ValidationEventHandler h)
+ {
+ XmlSchemaWhiteSpaceFacet ws = new XmlSchemaWhiteSpaceFacet();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
+ {
+ error(h,"Should not happen :1: XmlSchemaWhiteSpaceFacet.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ ws.LineNumber = reader.LineNumber;
+ ws.LinePosition = reader.LinePosition;
+ ws.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ ws.Id = reader.Value;
+ }
+ else if(reader.Name == "fixed")
+ {
+ Exception innerex;
+ ws.IsFixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
+ if(innerex != null)
+ error(h, reader.Value + " is not a valid value for fixed attribute",innerex);
+ }
+ else if(reader.Name == "value")
+ {
+ ws.Value = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for "+xmlname,null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,ws);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return ws;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != xmlname)
+ error(h,"Should not happen :2: XmlSchemaWhiteSpaceFacet.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ ws.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return ws;
+ }
+
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaXPath.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaXPath.cs
new file mode 100755
index 00000000000..8f7447e0f53
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaXPath.cs
@@ -0,0 +1,104 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+using System.Xml.Serialization;
+using System.ComponentModel;
+using System.Xml;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSchemaXPath.
+ /// </summary>
+ public class XmlSchemaXPath : XmlSchemaAnnotated
+ {
+ private string xpath;
+
+ public XmlSchemaXPath()
+ {
+ }
+ [DefaultValue(null)]
+ [System.Xml.Serialization.XmlAttribute("xpath")]
+ public string XPath
+ {
+ get{ return xpath; }
+ set{ xpath = value; }
+ }
+
+ internal int Compile(ValidationEventHandler h, XmlSchemaInfo info)
+ {
+ XmlSchemaUtil.CompileID(Id, this, info.IDCollection, h);
+ return errorCount;
+ }
+
+ //<selector
+ // id = ID
+ // xpath = a subset of XPath expression, see below
+ // {any attributes with non-schema namespace . . .}>
+ // Content: (annotation?)
+ //</selector>
+ internal static XmlSchemaXPath Read(XmlSchemaReader reader, ValidationEventHandler h,string name)
+ {
+ XmlSchemaXPath path = new XmlSchemaXPath();
+ reader.MoveToElement();
+
+ if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != name)
+ {
+ error(h,"Should not happen :1: XmlSchemaComplexContentRestriction.Read, name="+reader.Name,null);
+ reader.Skip();
+ return null;
+ }
+
+ path.LineNumber = reader.LineNumber;
+ path.LinePosition = reader.LinePosition;
+ path.SourceUri = reader.BaseURI;
+
+ while(reader.MoveToNextAttribute())
+ {
+ if(reader.Name == "id")
+ {
+ path.Id = reader.Value;
+ }
+ else if(reader.Name == "xpath")
+ {
+ path.xpath = reader.Value;
+ }
+ else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
+ {
+ error(h,reader.Name + " is not a valid attribute for "+name,null);
+ }
+ else
+ {
+ XmlSchemaUtil.ReadUnhandledAttribute(reader,path);
+ }
+ }
+
+ reader.MoveToElement();
+ if(reader.IsEmptyElement)
+ return path;
+
+ // Content: (annotation?)
+ int level = 1;
+ while(reader.ReadNextElement())
+ {
+ if(reader.NodeType == XmlNodeType.EndElement)
+ {
+ if(reader.LocalName != name)
+ error(h,"Should not happen :2: XmlSchemaXPath.Read, name="+reader.Name,null);
+ break;
+ }
+ if(level <= 1 && reader.LocalName == "annotation")
+ {
+ level = 2; //Only one annotation
+ XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
+ if(annotation != null)
+ path.Annotation = annotation;
+ continue;
+ }
+ reader.RaiseInvalidElementError();
+ }
+ return path;
+ }
+
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSeverityType.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSeverityType.cs
new file mode 100755
index 00000000000..f16d15967e8
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Schema/XmlSeverityType.cs
@@ -0,0 +1,15 @@
+// Author: Dwivedi, Ajay kumar
+// Adwiv@Yahoo.com
+using System;
+
+namespace System.Xml.Schema
+{
+ /// <summary>
+ /// Summary description for XmlSeverityType.
+ /// </summary>
+ public enum XmlSeverityType
+ {
+ Error = 0x00000000,
+ Warning = 0x00000001,
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/AssemblyInfo.cs b/mcs/class/System.XML/System.Xml.Serialization/AssemblyInfo.cs
new file mode 100644
index 00000000000..177a4f0e70a
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/AssemblyInfo.cs
@@ -0,0 +1,58 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+//
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+//
+[assembly: AssemblyTitle("")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+//
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+
+[assembly: AssemblyVersion("1.0.*")]
+
+//
+// In order to sign your assembly you must specify a key to use. Refer to the
+// Microsoft .NET Framework documentation for more information on assembly signing.
+//
+// Use the attributes below to control which key is used for signing.
+//
+// Notes:
+// (*) If no key is specified, the assembly is not signed.
+// (*) KeyName refers to a key that has been installed in the Crypto Service
+// Provider (CSP) on your machine. KeyFile refers to a file which contains
+// a key.
+// (*) If the KeyFile and the KeyName values are both specified, the
+// following processing occurs:
+// (1) If the KeyName can be found in the CSP, that key is used.
+// (2) If the KeyName does not exist and the KeyFile does exist, the key
+// in the KeyFile is installed into the CSP and used.
+// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
+// When specifying the KeyFile, the location of the KeyFile should be
+// relative to the project output directory which is
+// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
+// located in the project directory, you would specify the AssemblyKeyFile
+// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
+// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
+// documentation for more information on this.
+//
+[assembly: AssemblyDelaySign(false)]
+[assembly: AssemblyKeyFile("")]
+[assembly: AssemblyKeyName("")]
diff --git a/mcs/class/System.XML/System.Xml.Serialization/ChangeLog b/mcs/class/System.XML/System.Xml.Serialization/ChangeLog
new file mode 100755
index 00000000000..3b1d98de2dd
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/ChangeLog
@@ -0,0 +1,143 @@
+2003-01-16 Ajay kumar Dwivedi <adwiv@yahoo.com>
+ * XmlSerializer.cs: Array serialization for 1D arrays works
+ * TypeTranslator: Added for translations`
+
+2002-09-19 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * XmlCustomFormatter.cs: finished.
+ * XmlSerializationReader.cs: implemented some more methods.
+
+2002-09-18 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * XmlSerializationReader.cs: implemented a few methods.
+
+ * XmlAnyElementAttribute.cs:
+ * XmlArrayAttribute.cs:
+ * XmlChoiceIdentifierAttribute.cs:
+ * XmlElementAttribute.cs:
+ * XmlMemberMapping.cs:
+ * XmlMembersMapping.cs: class status based fixes.
+
+2002-09-13 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * CodeIdentifiers.cs:
+ * XmlSchemaExporter.cs:
+ * XmlSchemaImporter.cs:
+ * XmlSchemas.cs:
+ * XmlSerializationWriteCallback.cs:
+ * XmlSerializationWriter.cs:
+ * XmlSerializer.cs:
+ * XmlSerializerNamespaces.cs: some class status based fixed and
+ implemented a couple of methods.
+
+ * SoapSchemaExporter.cs: stubbed out.
+
+2002-08-24 Tim Coleman <tim@timcoleman.com>
+ * SoapCodeExporter.cs:
+ Fix return value of ExportTypeMapping.
+ * XmlCustomFormatter.cs:
+ Change methods to be internal instead of public.
+ * XmlSerializationWriter.cs:
+ Modify GetPrimitiveTypeName to build on linux.
+ Modify GetQualifiedName to return an incrementing prefix
+ instead of the same one all the time (still need to manage
+ conflicts)
+ Modify WriteElementString to only do special stuff is XsiType
+ is not defined.
+ Modify WriteTypedPrimitive to use FromXmlQualifiedName if it's
+ an XmlQualifiedName.
+
+2002-08-22 Tim Coleman <tim@timcoleman.com>
+ * XmlSerializationReader.cs:
+ Some implementation
+ * XmlSerializationWriter.cs:
+ More implementation
+ * XmlCustomFormatter.cs:
+ Implemented this class.
+
+2002-08-20 Tim Coleman <tim@timcoleman.com>
+ * XmlSerializationWriter.cs:
+ Some implementation.
+
+2002-08-19 Tim Coleman <tim@timcoleman.com>
+ * XmlSerializer.cs:
+ New stubs added.
+ * XmlSerializationWriter.cs:
+ New stubs added.
+
+2002-08-14 Tim Coleman <tim@timcoleman.com>
+ * XmlSerializer.cs:
+ More reformatting of source code so I can
+ better understand what it does.
+
+2002-08-06 Tim Coleman <tim@timcoleman.com>
+ * XmlSerializer.cs:
+ Some reformatting of code for readability.
+ Modify to correctly serialize ICollection objects
+ such as the BindingCollection of a ServiceDescription
+ for example.
+
+2002-08-03 Tim Coleman <tim@timcoleman.com>
+ * XmlSerializer.cs:
+ Changed Implements() to check based on name rather
+ than FullName. FullName was never working correctly.
+
+2002-07-26 Tim Coleman <tim@timcoleman.com>
+ * XmlSerializer.cs:
+ The constructor now looks for an XmlRootAttribute attribute
+ if one is not passed in. Various changes to make it emit
+ proper XML, such as handling an element without a namespace
+ prefix, and using WriteEndDocument where it should be.
+
+2002-07-24 Tim Coleman <tim@timcoleman.com>
+ * CodeIdentifier.cs:
+ * IXmlSerializable.cs:
+ * XmlSerializationCollectionFixupCallback.cs:
+ * XmlSerializationFixupCallback.cs:
+ * XmlSerializationReadCallback.cs:
+ * XmlSerializationReader.cs:
+ * XmlSerializationWriteCallback.cs:
+ Add new classes.
+ * XmlSchemas.cs
+ * CodeIdentifiers.cs:
+ Implement some of these classes
+ * XmlCodeExporter.cs:
+ Fix return type of a function
+
+2002-07-24 Tim Coleman <tim@timcoleman.com>
+ * SoapReflectionImporter.cs:
+ New class added to build
+ System.Web.Services.Description.ServiceDescription.cs
+
+2002-07-22 Tim Coleman <tim@timcoleman.com>
+ * CodeIdentifiers.cs:
+ * SoapCodeExporter.cs:
+ * SoapSchemaExporter.cs:
+ * XmlCodeExporter.cs:
+ * XmlMemberMapping.cs:
+ * XmlMembersMapping.cs:
+ * XmlReflectionImporter.cs:
+ * XmlReflectionMember.cs:
+ * XmlSchemaExporter.cs:
+ * XmlSchemaImporter.cs:
+ * XmlSchemas.cs:
+ New stubbs added to aid in the linux build of
+ System.Web.Services.
+
+2002-07-05 Ajay kumar Dwivedi <adwiv@yahoo.com>
+
+ * XmlSeriailizer: Serialize method can serialize XmlSchema perfectly.
+
+ * XmlSerializerNamespaces: Reverted to use of a single Hashtable.
+
+2002-07-02 Ajay kumar Dwivedi <adwiv@yahoo.com>
+
+ * XmlSeriailizer: Updated Serialize() method.
+
+2002-06-27 Ajay kumar Dwivedi <adwiv@yahoo.com>
+ * XmlSerializer: Serialize() method Partially Implemented.
+
+2002-06-20 Ajay kumar Dwivedi <adwiv@yahoo.com>
+
+ * Soap & XmlOverrides: Implemented using TypeMember as key with
+ suggestions from Rafael.
diff --git a/mcs/class/System.XML/System.Xml.Serialization/CodeIdentifier.cs b/mcs/class/System.XML/System.Xml.Serialization/CodeIdentifier.cs
new file mode 100644
index 00000000000..94a532b402b
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/CodeIdentifier.cs
@@ -0,0 +1,50 @@
+//
+// System.Xml.Serialization.CodeIdentifier.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System;
+
+namespace System.Xml.Serialization {
+ public class CodeIdentifier {
+
+ public CodeIdentifier ()
+ {
+ }
+
+ public static string MakeCamel (string identifier)
+ {
+ string validIdentifier = MakeValid (identifier);
+ return (Char.ToLower (validIdentifier[0]) + validIdentifier.Substring (1));
+ }
+
+ public static string MakePascal (string identifier)
+ {
+ string validIdentifier = MakeValid (identifier);
+ return (Char.ToUpper (validIdentifier[0]) + validIdentifier.Substring (1));
+ }
+
+ public static string MakeValid (string identifier)
+ {
+ if (identifier == null)
+ throw new NullReferenceException ();
+ if (identifier.Length == 0)
+ return identifier;
+
+ string output = "";
+
+ if (Char.IsNumber (identifier[0]))
+ output = "Item";
+
+ foreach (char c in identifier)
+ if (Char.IsLetterOrDigit (c) || c == '_')
+ output += c;
+
+ return output;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/CodeIdentifiers.cs b/mcs/class/System.XML/System.Xml.Serialization/CodeIdentifiers.cs
new file mode 100644
index 00000000000..0cd713946c8
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/CodeIdentifiers.cs
@@ -0,0 +1,110 @@
+//
+// System.Xml.Serialization.CodeIdentifiers
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System;
+using System.Collections;
+
+namespace System.Xml.Serialization {
+ public class CodeIdentifiers {
+
+ #region Fields
+
+ bool useCamelCasing;
+ Hashtable table = new Hashtable ();
+ Hashtable reserved = new Hashtable ();
+
+ #endregion
+
+ #region Constructors
+
+ public CodeIdentifiers ()
+ {
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public bool UseCamelCasing {
+ get { return useCamelCasing; }
+ set { useCamelCasing = value; }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ public void Add (string identifier, object value)
+ {
+ table.Add (identifier, value);
+ }
+
+ public void AddReserved (string identifier)
+ {
+ reserved.Add (identifier, identifier);
+ }
+
+ public string AddUnique (string identifier, object value)
+ {
+ string unique = MakeUnique (identifier);
+ Add (unique, value);
+ return unique;
+ }
+
+ public void Clear ()
+ {
+ table.Clear ();
+ }
+
+ public bool IsInUse (string identifier)
+ {
+ return (table.ContainsKey (identifier) || reserved.ContainsKey (identifier));
+ }
+
+ public string MakeRightCase (string identifier)
+ {
+ if (UseCamelCasing)
+ return CodeIdentifier.MakeCamel (identifier);
+ else
+ return CodeIdentifier.MakePascal (identifier);
+ }
+
+ public string MakeUnique (string identifier)
+ {
+ string uniqueIdentifier = identifier;
+ int i = 1;
+
+ while (IsInUse (uniqueIdentifier)) {
+ uniqueIdentifier = String.Format ("{0}{1}", identifier, i.ToString ());
+ i += 1;
+ }
+
+ return uniqueIdentifier;
+ }
+
+ public void Remove (string identifier)
+ {
+ table.Remove (identifier);
+ }
+
+ public void RemoveReserved (string identifier)
+ {
+ reserved.Remove (identifier);
+ }
+
+ public object ToArray (Type type)
+ {
+ Array list = Array.CreateInstance (type, table.Count);
+ table.CopyTo (list, 0);
+ return list;
+ }
+
+ #endregion // Methods
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/IXmlSerializable.cs b/mcs/class/System.XML/System.Xml.Serialization/IXmlSerializable.cs
new file mode 100644
index 00000000000..3aa7f785e69
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/IXmlSerializable.cs
@@ -0,0 +1,19 @@
+//
+// System.Xml.Serialization.IXmlSerializable.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System.Xml.Schema;
+
+namespace System.Xml.Serialization {
+ public interface IXmlSerializable {
+
+ XmlSchema GetSchema ();
+ void ReadXml (XmlReader reader);
+ void WriteXml (XmlWriter writer);
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/SchemaTypes.cs b/mcs/class/System.XML/System.Xml.Serialization/SchemaTypes.cs
new file mode 100644
index 00000000000..5110eb15910
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/SchemaTypes.cs
@@ -0,0 +1,23 @@
+//
+// System.Xml.Serialization.SchemaTypes
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+namespace System.Xml.Serialization
+{
+ internal enum SchemaTypes {
+ NotSet = 0,
+ Primitive,
+ Enum,
+ Array,
+ Class,
+ DataSet,
+ XmlNode,
+ Void
+ }
+}
+
diff --git a/mcs/class/System.XML/System.Xml.Serialization/SoapAttributeAttribute.cs b/mcs/class/System.XML/System.Xml.Serialization/SoapAttributeAttribute.cs
new file mode 100644
index 00000000000..71311673741
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/SoapAttributeAttribute.cs
@@ -0,0 +1,61 @@
+//
+// SoapAttributeAttribute.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for SoapAttributeAttribute.
+ /// </summary>
+ [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field
+ | AttributeTargets.Parameter | AttributeTargets.ReturnValue)]
+ public class SoapAttributeAttribute : Attribute
+ {
+ private string attrName;
+ private string dataType;
+ private string ns;
+
+ public SoapAttributeAttribute ()
+ {
+ }
+
+ public SoapAttributeAttribute (string attrName)
+ {
+ AttributeName = attrName;
+ }
+
+ public string AttributeName {
+ get {
+ return attrName;
+ }
+ set {
+ attrName = value;
+ }
+ }
+
+ public string DataType {
+ get {
+ return dataType;
+ }
+ set {
+ dataType = value;
+ }
+ }
+
+ public string Namespace {
+ get {
+ return ns;
+ }
+ set {
+ ns = value;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/SoapAttributeOverrides.cs b/mcs/class/System.XML/System.Xml.Serialization/SoapAttributeOverrides.cs
new file mode 100644
index 00000000000..dcbbca6bcb7
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/SoapAttributeOverrides.cs
@@ -0,0 +1,72 @@
+//
+// SoapAttributeOverrides.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System;
+using System.Collections;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ ///
+ /// </summary>
+ public class SoapAttributeOverrides
+ {
+ /// <summary>
+ /// This class requires to store SoapAttrributes indexed by a key containg
+ /// both Type and Member Name. There are 3 approaches to this IMO.
+ /// 1. Make the key as "FullTypeName..MemberName", with ".." seperating Type and Member.
+ /// 2. Use a jagged 2D hashtable. The main hashtable is indexed by Type and each value
+ /// contains another hashtable which is indexed by member names. (Too many hashtables)
+ /// 3. Use a new class which emcompasses the Type and MemberName. An implementation is there
+ /// in TypeMember class in this namespace. (Too many instantiations of the class needed)
+ ///
+ /// Method 1 is the most elegent, but I am not sure if the seperator is language insensitive.
+ /// What if someone writes a language which allows . in the member names.
+ /// </summary>
+ ///
+ private Hashtable overrides;
+
+ public SoapAttributeOverrides ()
+ {
+ overrides = new Hashtable();
+ }
+
+ public SoapAttributes this [Type type]
+ {
+ get { return this [type, string.Empty]; }
+ }
+
+ public SoapAttributes this [Type type, string member]
+ {
+ get
+ {
+ return (SoapAttributes) overrides[GetKey(type,member)];
+ }
+ }
+
+ public void Add (Type type, SoapAttributes attributes)
+ {
+ Add(type, string.Empty, attributes);
+ }
+
+ public void Add (Type type, string member, SoapAttributes attributes)
+ {
+ if(overrides[GetKey(type, member)] != null)
+ throw new Exception("The attributes for the given type and Member already exist in the collection");
+
+ overrides.Add(GetKey(type,member), attributes);
+ }
+
+ private TypeMember GetKey(Type type, string member)
+ {
+ return new TypeMember(type, member);
+ }
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/SoapAttributes.cs b/mcs/class/System.XML/System.Xml.Serialization/SoapAttributes.cs
new file mode 100644
index 00000000000..786ca2921f3
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/SoapAttributes.cs
@@ -0,0 +1,88 @@
+//
+// SoapAttributes.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System.Reflection;
+using System;
+using System.ComponentModel;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for SoapAttributes.
+ /// </summary>
+ public class SoapAttributes
+ {
+ private SoapAttributeAttribute soapAttribute;
+ private object soapDefaultValue;
+ private SoapElementAttribute soapElement;
+ private SoapEnumAttribute soapEnum;
+ private bool soapIgnore;
+ private SoapTypeAttribute soapType;
+
+ public SoapAttributes ()
+ {
+ }
+
+ public SoapAttributes (ICustomAttributeProvider provider)
+ {
+ object[] attributes = provider.GetCustomAttributes(false);
+ foreach(object obj in attributes)
+ {
+ if(obj is SoapAttributeAttribute)
+ soapAttribute = (SoapAttributeAttribute) obj;
+ else if(obj is DefaultValueAttribute)
+ soapDefaultValue = obj;
+ else if(obj is SoapElementAttribute)
+ soapElement = (SoapElementAttribute) obj;
+ else if(obj is SoapEnumAttribute)
+ soapEnum = (SoapEnumAttribute) obj;
+ else if(obj is SoapIgnoreAttribute)
+ soapIgnore = true;
+ else if(obj is SoapTypeAttribute)
+ soapType = (SoapTypeAttribute) obj;
+ }
+ }
+
+ public SoapAttributeAttribute SoapAttribute
+ {
+ get { return soapAttribute; }
+ set { soapAttribute = value; }
+ }
+
+ public object SoapDefaultValue
+ {
+ get { return soapDefaultValue; }
+ set { soapDefaultValue = value; }
+ }
+
+ public SoapElementAttribute SoapElement
+ {
+ get { return soapElement; }
+ set { soapElement = value; }
+ }
+
+ public SoapEnumAttribute SoapEnum
+ {
+ get { return soapEnum; }
+ set { soapEnum = value; }
+ }
+
+ public bool SoapIgnore
+ {
+ get { return soapIgnore; }
+ set { soapIgnore = value; }
+ }
+
+ public SoapTypeAttribute SoapType
+ {
+ get { return soapType; }
+ set { soapType = value; }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/SoapCodeExporter.cs b/mcs/class/System.XML/System.Xml.Serialization/SoapCodeExporter.cs
new file mode 100644
index 00000000000..6c25de9e392
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/SoapCodeExporter.cs
@@ -0,0 +1,75 @@
+//
+// System.Xml.Serialization.SoapCodeExporter
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System.CodeDom;
+
+namespace System.Xml.Serialization {
+ public class SoapCodeExporter {
+
+ #region Fields
+
+ CodeNamespace codeNamespace;
+ CodeCompileUnit codeCompileUnit;
+ CodeAttributeDeclarationCollection includeMetadata;
+
+ #endregion
+
+ #region Constructors
+
+ public SoapCodeExporter (CodeNamespace codeNamespace)
+ {
+ includeMetadata = new CodeAttributeDeclarationCollection ();
+ this.codeNamespace = codeNamespace;
+ }
+
+ public SoapCodeExporter (CodeNamespace codeNamespace, CodeCompileUnit codeCompileUnit)
+ : this (codeNamespace)
+ {
+ this.codeCompileUnit = codeCompileUnit;
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public CodeAttributeDeclarationCollection IncludeMetadata {
+ get { return includeMetadata; }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public void AddMappingMetadata (CodeAttributeDeclarationCollection metadata, XmlMemberMapping member)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void AddMappingMetadata (CodeAttributeDeclarationCollection metadata, XmlMemberMapping member, bool forceUseMemberName)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void ExportMembersMapping (XmlMembersMapping xmlMembersMapping)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void ExportTypeMapping (XmlTypeMapping xmlTypeMapping)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/SoapElementAttribute.cs b/mcs/class/System.XML/System.Xml.Serialization/SoapElementAttribute.cs
new file mode 100644
index 00000000000..fbb6527e821
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/SoapElementAttribute.cs
@@ -0,0 +1,60 @@
+//
+// SoapElementAttribute.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for SoapElementAttribute.
+ /// </summary>
+ [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field
+ | AttributeTargets.Parameter | AttributeTargets.ReturnValue)]
+ public class SoapElementAttribute : Attribute
+ {
+ private string dataType;
+ private string elementName;
+ private bool isNullable;
+
+ public SoapElementAttribute ()
+ {
+ }
+ public SoapElementAttribute (string elementName)
+ {
+ ElementName = elementName;
+ }
+
+ public string DataType {
+ get {
+ return dataType;
+ }
+ set {
+ dataType = value;
+ }
+ }
+
+ public string ElementName {
+ get {
+ return elementName;
+ }
+ set {
+ elementName = value;
+ }
+ }
+
+ public bool IsNullable {
+ get {
+ return isNullable;
+ }
+ set {
+ isNullable = value;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/SoapEnumAttribute.cs b/mcs/class/System.XML/System.Xml.Serialization/SoapEnumAttribute.cs
new file mode 100644
index 00000000000..fba4f311126
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/SoapEnumAttribute.cs
@@ -0,0 +1,40 @@
+//
+// SoapEnumAttribute.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for SoapEnumAttribute.
+ /// </summary>
+ [AttributeUsage(AttributeTargets.Field)]
+ public class SoapEnumAttribute : Attribute
+ {
+ private string name;
+
+ public SoapEnumAttribute ()
+ {
+ }
+
+ public SoapEnumAttribute (string name)
+ {
+ Name = name;
+ }
+
+ public string Name {
+ get {
+ return name;
+ }
+ set {
+ name = value;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/SoapIgnoreAttribute.cs b/mcs/class/System.XML/System.Xml.Serialization/SoapIgnoreAttribute.cs
new file mode 100644
index 00000000000..52798f1dd30
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/SoapIgnoreAttribute.cs
@@ -0,0 +1,25 @@
+//
+// SoapIgnoreAttribute.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for SoapIgnoreAttribute.
+ /// </summary>
+ [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field
+ | AttributeTargets.Parameter | AttributeTargets.ReturnValue)]
+ public class SoapIgnoreAttribute : Attribute
+ {
+ public SoapIgnoreAttribute ()
+ {
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/SoapIncludeAttribute.cs b/mcs/class/System.XML/System.Xml.Serialization/SoapIncludeAttribute.cs
new file mode 100644
index 00000000000..aaf3e29d03c
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/SoapIncludeAttribute.cs
@@ -0,0 +1,38 @@
+//
+// SoapIncludeAttribute.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for SoapIncludeAttribute.
+ /// </summary>
+ [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct |
+ AttributeTargets.Method)]
+ public class SoapIncludeAttribute : Attribute
+ {
+ private Type type;
+
+ public SoapIncludeAttribute( Type type)
+ {
+ Type = type;
+ }
+
+ public Type Type
+ {
+ get {
+ return type;
+ }
+ set {
+ type = value;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/SoapReflectionImporter.cs b/mcs/class/System.XML/System.Xml.Serialization/SoapReflectionImporter.cs
new file mode 100644
index 00000000000..11c2b5926c2
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/SoapReflectionImporter.cs
@@ -0,0 +1,90 @@
+//
+// System.Xml.Serialization.SoapReflectionImporter
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System.Reflection;
+using System.Xml;
+
+namespace System.Xml.Serialization {
+ public class SoapReflectionImporter {
+
+ #region Constructors
+
+ [MonoTODO]
+ public SoapReflectionImporter ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public SoapReflectionImporter (SoapAttributeOverrides attributeOverrides)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public SoapReflectionImporter (string defaultNamespace)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public SoapReflectionImporter (SoapAttributeOverrides attributeOverrides, string defaultNamespace)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Constructors
+
+ #region Methods
+
+ [MonoTODO]
+ public XmlMembersMapping ImportMembersMapping (string elementName, string ns, XmlReflectionMember[] members)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public XmlMembersMapping ImportMembersMapping (string elementName, string ns, XmlReflectionMember[] members, bool hasWrapperElement, bool writeAccessors)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public XmlMembersMapping ImportMembersMapping (string elementName, string ns, XmlReflectionMember[] members, bool hasWrapperElement, bool writeAccessors, bool validate)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public XmlTypeMapping ImportTypeMapping (Type type)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public XmlTypeMapping ImportTypeMapping (Type type, string defaultNamespace)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void IncludeType (Type type)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void IncludeTypes (ICustomAttributeProvider provider)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/SoapSchemaExporter.cs b/mcs/class/System.XML/System.Xml.Serialization/SoapSchemaExporter.cs
new file mode 100644
index 00000000000..f11cbe45d47
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/SoapSchemaExporter.cs
@@ -0,0 +1,42 @@
+//
+// System.Xml.Serialization.SoapSchemaExporter
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (c) 2002 Ximian, Inc. (http://www.ximian.com)
+//
+
+using System;
+
+namespace System.Xml.Serialization
+{
+ public class SoapSchemaExporter
+ {
+ [MonoTODO]
+ public SoapSchemaExporter (XmlSchemas schemas)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void ExportMembersMapping (XmlMembersMapping xmlMembersMapping)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void ExportMembersMapping (XmlMembersMapping xmlMembersMapping,
+ bool exportEnclosingType)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void ExportTypeMapping (XmlTypeMapping xmlTypeMapping)
+ {
+ throw new NotImplementedException ();
+ }
+ }
+}
+
diff --git a/mcs/class/System.XML/System.Xml.Serialization/SoapSchemaImporter.cs b/mcs/class/System.XML/System.Xml.Serialization/SoapSchemaImporter.cs
new file mode 100644
index 00000000000..baafb07716d
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/SoapSchemaImporter.cs
@@ -0,0 +1,71 @@
+//
+// System.Xml.Serialization.SoapSchemaImporter
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System.Xml;
+
+namespace System.Xml.Serialization {
+ public class SoapSchemaImporter {
+
+ #region Fields
+
+ XmlSchemas schemas;
+ CodeIdentifiers typeIdentifiers;
+
+ #endregion
+
+ #region Constructors
+
+ public SoapSchemaImporter (XmlSchemas schemas)
+ {
+ this.schemas = schemas;
+ }
+
+ public SoapSchemaImporter (XmlSchemas schemas, CodeIdentifiers typeIdentifiers)
+ : this (schemas)
+ {
+ this.typeIdentifiers = typeIdentifiers;
+ }
+
+ #endregion // Constructors
+
+ #region Methods
+
+ [MonoTODO]
+ public XmlTypeMapping ImportDerivedTypeMapping (XmlQualifiedName name, Type baseType, bool baseTypeCanBeIndirect)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public XmlMembersMapping ImportMembersMapping (string name, string ns, SoapSchemaMember member)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public XmlMembersMapping ImportMembersMapping (string name, string ns, SoapSchemaMember[] members)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public XmlMembersMapping ImportMembersMapping (string name, string ns, SoapSchemaMember[] members, bool hasWrapperElement)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public XmlMembersMapping ImportMembersMapping (string name, string ns, SoapSchemaMember[] members, bool hasWrapperElement, Type baseType, bool baseTypeCanBeIndirect)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/SoapSchemaMember.cs b/mcs/class/System.XML/System.Xml.Serialization/SoapSchemaMember.cs
new file mode 100644
index 00000000000..733d59c57e8
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/SoapSchemaMember.cs
@@ -0,0 +1,44 @@
+//
+// System.Xml.Serialization.SoapSchemaMember
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System.Xml;
+
+namespace System.Xml.Serialization {
+ public class SoapSchemaMember {
+
+ #region Fields
+
+ string memberName;
+ XmlQualifiedName memberType;
+
+ #endregion
+
+ #region Constructors
+
+ public SoapSchemaMember ()
+ {
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public string MemberName {
+ get { return memberName; }
+ set { memberName = value; }
+ }
+
+ public XmlQualifiedName MemberType {
+ get { return memberType; }
+ set { memberType = value; }
+ }
+
+ #endregion // Properties
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/SoapTypeAttribute.cs b/mcs/class/System.XML/System.Xml.Serialization/SoapTypeAttribute.cs
new file mode 100644
index 00000000000..d6e68934cc6
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/SoapTypeAttribute.cs
@@ -0,0 +1,59 @@
+//
+// SoapTypeAttribute.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for SoapTypeAttribute.
+ /// </summary>
+ [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct |
+ AttributeTargets.Enum | AttributeTargets.Interface)]
+ public class SoapTypeAttribute : Attribute
+ {
+ private string ns;
+ private string typeName;
+ private bool includeInSchema = true;
+
+ public SoapTypeAttribute ()
+ {
+ }
+ public SoapTypeAttribute (string typeName)
+ {
+ TypeName = typeName;
+ }
+ public SoapTypeAttribute (string typeName, string ns)
+ {
+ TypeName = typeName;
+ Namespace = ns;
+ }
+
+ public bool IncludeInSchema
+ {
+ get { return includeInSchema; }
+ set { includeInSchema = value; }
+ }
+
+ public string Namespace {
+ get { return ns;
+ }
+ set { ns = value;
+ }
+ }
+ public string TypeName {
+ get { return typeName;
+ }
+ set { typeName = value;
+ }
+ }
+
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/TypeData.cs b/mcs/class/System.XML/System.Xml.Serialization/TypeData.cs
new file mode 100644
index 00000000000..ee9223b0b59
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/TypeData.cs
@@ -0,0 +1,82 @@
+//
+// System.Xml.Serialization.TypeData
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System;
+
+namespace System.Xml.Serialization
+{
+ internal class TypeData
+ {
+ Type type;
+ string elementName;
+ SchemaTypes sType;
+
+ public TypeData (Type type, string elementName, bool isPrimitive)
+ {
+ this.type = type;
+ this.elementName = elementName;
+ if (isPrimitive)
+ sType = SchemaTypes.Primitive;
+ else
+ sType = SchemaTypes.NotSet;
+ }
+
+ private SchemaTypes GetSchemaType ()
+ {
+ if (type.IsEnum)
+ return SchemaTypes.Enum;
+ else if (type.IsArray)
+ return SchemaTypes.Array;
+ /*else if (type == typeof (System.Data.DataSet))
+ return SchemaTypes.DataSet;*/
+ else if (type == typeof (System.Xml.XmlNode))
+ return SchemaTypes.XmlNode;
+ return SchemaTypes.Class;
+ }
+
+ public string ElementName
+ {
+ get {
+ return elementName;
+ }
+ }
+
+ public string TypeName
+ {
+ get {
+ return type.Name;
+ }
+ }
+
+ public Type Type
+ {
+ get {
+ return type;
+ }
+ }
+
+ public string FullTypeName
+ {
+ get {
+ return type.FullName.Replace ('+', '.');
+ }
+ }
+
+ public SchemaTypes SchemaType
+ {
+ get {
+ if (sType == SchemaTypes.NotSet)
+ sType = GetSchemaType ();
+
+ return sType;
+ }
+ }
+ }
+}
+
diff --git a/mcs/class/System.XML/System.Xml.Serialization/TypeMember.cs b/mcs/class/System.XML/System.Xml.Serialization/TypeMember.cs
new file mode 100755
index 00000000000..854e31cb511
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/TypeMember.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// TypeMember is immutable class which is used as a key in a Hashtable.
+ /// </summary>
+
+ internal sealed class TypeMember
+ {
+ Type type;
+ string member;
+ internal TypeMember(Type type, string member)
+ {
+ this.type = type;
+ this.member = member;
+ }
+
+ public override int GetHashCode()
+ {
+ return unchecked (type.GetHashCode() + member.GetHashCode());
+ }
+
+ public override bool Equals(object obj)
+ {
+ if(obj is TypeMember)
+ return TypeMember.Equals(this,(TypeMember)obj);
+
+ return false;
+ }
+
+ public static bool Equals(TypeMember tm1, TypeMember tm2)
+ {
+ if(Object.ReferenceEquals(tm1,tm2))
+ return true;
+ if(Object.ReferenceEquals(tm1,null) || Object.ReferenceEquals(tm2,null))
+ return false;
+ if(tm1.type == tm2.type && tm1.member == tm2.member)
+ return true;
+ return false;
+ }
+
+ public static bool operator==(TypeMember tm1, TypeMember tm2)
+ {
+ return TypeMember.Equals(tm1,tm2);
+ }
+
+ public static bool operator!=(TypeMember tm1, TypeMember tm2)
+ {
+ return !TypeMember.Equals(tm1,tm2);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/TypeTranslator.cs b/mcs/class/System.XML/System.Xml.Serialization/TypeTranslator.cs
new file mode 100644
index 00000000000..7988b342e50
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/TypeTranslator.cs
@@ -0,0 +1,53 @@
+//
+// System.Xml.Serialization.TypeTranslator
+//
+// Authors:
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System;
+using System.Collections;
+
+namespace System.Xml.Serialization
+{
+ internal class TypeTranslator
+ {
+ static Hashtable primitives;
+
+ static TypeTranslator ()
+ {
+ primitives = new Hashtable ();
+ primitives.Add (typeof (bool), "boolean");
+ primitives.Add (typeof (short), "short");
+ primitives.Add (typeof (ushort), "unsignedShort");
+ primitives.Add (typeof (int), "int");
+ primitives.Add (typeof (uint), "unsignedInt");
+ primitives.Add (typeof (long), "long");
+ primitives.Add (typeof (ulong), "unsignedLong");
+ primitives.Add (typeof (float), "float");
+ primitives.Add (typeof (double), "double");
+ primitives.Add (typeof (DateTime), "dateTime"); // TODO: timeInstant, Xml date, xml time
+ primitives.Add (typeof (Guid), "guid");
+ primitives.Add (typeof (Decimal), "decimal");
+ primitives.Add (typeof (XmlQualifiedName), "QName");
+ primitives.Add (typeof (string), "string");
+ primitives.Add (typeof (byte), "unsignedByte");
+ primitives.Add (typeof (sbyte), "byte");
+ primitives.Add (typeof (char), "char");
+ primitives.Add (typeof (object), "anyType");
+ }
+
+ private TypeTranslator ()
+ {
+ }
+
+ static public TypeData GetTypeData (Type type)
+ {
+ string name = primitives [type] as string;
+ return new TypeData (type, (name == null) ? type.Name : name, name != null);
+ }
+ }
+}
+
diff --git a/mcs/class/System.XML/System.Xml.Serialization/UnreferencedObjectEventArgs.cs b/mcs/class/System.XML/System.Xml.Serialization/UnreferencedObjectEventArgs.cs
new file mode 100644
index 00000000000..b501cb5fea0
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/UnreferencedObjectEventArgs.cs
@@ -0,0 +1,35 @@
+//
+// UnreferencedObjectEventArgs.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for UnreferencedObjectEventArgs.
+ /// </summary>
+ public class UnreferencedObjectEventArgs : EventArgs
+ {
+ private object unreferencedObject;
+ private string unreferencedId;
+
+ public UnreferencedObjectEventArgs(object o, string id)
+ {
+ unreferencedObject = o;
+ unreferencedId = id;
+ }
+
+ public string UnreferencedId {
+ get{ return unreferencedId; }
+ }
+ public object UnreferencedObject {
+ get{ return unreferencedObject; }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/UnreferencedObjectEventHandler.cs b/mcs/class/System.XML/System.Xml.Serialization/UnreferencedObjectEventHandler.cs
new file mode 100755
index 00000000000..5344f05a746
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/UnreferencedObjectEventHandler.cs
@@ -0,0 +1,16 @@
+//
+// UnreferencedObjectEventHandler.cs:
+//
+// Author:
+// Miguel de Icaza (miguel@ximian.com)
+//
+// (C) 2002 Ximian, Inc.
+//
+using System;
+
+namespace System.Xml.Serialization {
+
+ [Serializable]
+ public delegate void UnreferencedObjectEventHandler (object sender, UnreferencedObjectEventArgs e);
+}
+
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlAnyAttributeAttribute.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlAnyAttributeAttribute.cs
new file mode 100644
index 00000000000..c34e70448d6
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlAnyAttributeAttribute.cs
@@ -0,0 +1,28 @@
+//
+// XmlAnyAttribute.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for XmlAnyAttributeAttribute.
+ /// </summary>
+ ///
+ [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field
+ | AttributeTargets.Parameter | AttributeTargets.ReturnValue)]
+ public class XmlAnyAttributeAttribute : Attribute
+ {
+
+ public XmlAnyAttributeAttribute()
+ {
+
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlAnyElementAttribute.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlAnyElementAttribute.cs
new file mode 100644
index 00000000000..255be7ea96c
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlAnyElementAttribute.cs
@@ -0,0 +1,66 @@
+//
+// filename.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for XmlAnyElementAttribute.
+ /// </summary>
+ ///
+ [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field
+ | AttributeTargets.Parameter | AttributeTargets.ReturnValue)]
+ public class XmlAnyElementAttribute : Attribute
+ {
+ private string elementName;
+ private string ns;
+ private int order;
+
+ public XmlAnyElementAttribute ()
+ {
+ }
+
+ public XmlAnyElementAttribute (string name)
+ {
+ elementName = name;
+ }
+
+ public XmlAnyElementAttribute (string name, string ns)
+ {
+ elementName = name;
+ Namespace = ns;
+ }
+
+ public string Name {
+ get {
+ return elementName;
+ }
+ set {
+ elementName = value;
+ }
+ }
+ public string Namespace {
+ get {
+ return ns;
+ }
+ set {
+ ns = value;
+ }
+ }
+ /// <summary>
+ /// Specifies Order in which Memberswill be serialized as Elements.
+ /// </summary>
+ internal int Order
+ {
+ get{ return order; }
+ set{ order = value; }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlAnyElementAttributes.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlAnyElementAttributes.cs
new file mode 100644
index 00000000000..86242fe7097
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlAnyElementAttributes.cs
@@ -0,0 +1,66 @@
+//
+// XmlAnyElementAttributes.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System.Xml;
+using System.Xml.Serialization;
+using System.Collections;
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for XmlAnyElementAttributes.
+ /// </summary>
+ public class XmlAnyElementAttributes : CollectionBase
+ {
+
+ public XmlAnyElementAttribute this[int index]
+ {
+ get
+ {
+ return (XmlAnyElementAttribute)List[index];
+ }
+ set
+ {
+ List[index] = value;
+ }
+ }
+
+ public int Add(XmlAnyElementAttribute attribute)
+ {
+ return List.Add(attribute);
+ }
+
+ public bool Contains(XmlAnyElementAttribute attribute)
+ {
+ return List.Contains(attribute);
+ }
+
+ public int IndexOf(XmlAnyElementAttribute attribute)
+ {
+ return List.IndexOf(attribute);
+ }
+
+ public void Insert(int index, XmlAnyElementAttribute attribute)
+ {
+ List.Insert(index, attribute);
+ }
+
+ public void Remove(XmlAnyElementAttribute attribute)
+ {
+ List.Remove(attribute);
+ }
+
+ public void CopyTo(XmlAnyElementAttribute[] array,int index)
+ {
+ List.CopyTo(array, index);
+ }
+ }
+
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlArrayAttribute.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlArrayAttribute.cs
new file mode 100644
index 00000000000..d0b67ab636d
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlArrayAttribute.cs
@@ -0,0 +1,90 @@
+//
+// XmlArrayAttribute.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System.Xml.Schema;
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for XmlArrayAttribute.
+ /// </summary>
+ [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field
+ | AttributeTargets.Parameter | AttributeTargets.ReturnValue)]
+ public class XmlArrayAttribute : Attribute
+ {
+ private string elementName;
+ private XmlSchemaForm form;
+ private bool isNullable;
+ private string ns;
+ private int order;
+
+ public XmlArrayAttribute()
+ {
+ }
+
+ public XmlArrayAttribute(string elementName)
+ {
+ ElementName = elementName;
+ }
+
+ public string ElementName
+ {
+ get
+ {
+ return elementName;
+ }
+ set
+ {
+ elementName = value;
+ }
+ }
+ public XmlSchemaForm Form
+ {
+ get
+ {
+ return form;
+ }
+ set
+ {
+ form = value;
+ }
+ }
+ public bool IsNullable
+ {
+ get
+ {
+ return isNullable;
+ }
+ set
+ {
+ isNullable = value;
+ }
+ }
+ public string Namespace
+ {
+ get
+ {
+ return ns;
+ }
+ set
+ {
+ ns = value;
+ }
+ }
+ /// <summary>
+ /// Specifies Order in which Memberswill be serialized as Elements.
+ /// </summary>
+ internal int Order
+ {
+ get{ return order; }
+ set{ order = value; }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlArrayItemAttribute.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlArrayItemAttribute.cs
new file mode 100644
index 00000000000..354af362b76
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlArrayItemAttribute.cs
@@ -0,0 +1,85 @@
+//
+// XmlArrayItemAttribute.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System.Xml.Schema;
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for XmlArrayItemAttribute.
+ /// </summary>
+ [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field
+ | AttributeTargets.Parameter | AttributeTargets.ReturnValue)]
+ public class XmlArrayItemAttribute : Attribute
+ {
+ private string dataType;
+ private string elementName;
+ private XmlSchemaForm form;
+ private string ns;
+ private bool isNullable;
+ private int nestingLevel;
+ private Type type;
+ private int order;
+
+ public XmlArrayItemAttribute ()
+ {
+ }
+ public XmlArrayItemAttribute (string elementName)
+ {
+ ElementName = elementName;
+ }
+ public XmlArrayItemAttribute (Type type)
+ {
+ Type = type;
+ }
+ public XmlArrayItemAttribute (string elementName, Type type)
+ {
+ ElementName = elementName;
+ Type = type;
+ }
+
+ public string DataType {
+ get { return dataType; }
+ set { dataType = value; }
+ }
+ public string ElementName {
+ get { return elementName; }
+ set { elementName = value; }
+ }
+ public XmlSchemaForm Form {
+ get { return form; }
+ set { form = value; }
+ }
+ public string Namespace {
+ get { return ns; }
+ set { ns = value; }
+ }
+ public bool IsNullable {
+ get { return isNullable; }
+ set { isNullable = value; }
+ }
+ public Type Type {
+ get { return type; }
+ set { type = value; }
+ }
+ public int NestingLevel {
+ get { return nestingLevel; }
+ set { nestingLevel = value; }
+ }
+ /// <summary>
+ /// Specifies Order in which Memberswill be serialized as Elements.
+ /// </summary>
+ public int Order
+ {
+ get{ return order; }
+ set{ order = value; }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlArrayItemAttributes.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlArrayItemAttributes.cs
new file mode 100644
index 00000000000..51528209a41
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlArrayItemAttributes.cs
@@ -0,0 +1,61 @@
+//
+// XmlArrayItemAttributes.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System.Xml.Serialization;
+using System.Collections;
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for XmlArrayItemAttributes.
+ /// </summary>
+ public class XmlArrayItemAttributes : CollectionBase
+ {
+
+ public XmlArrayItemAttribute this [int index] {
+ get {
+ return (XmlArrayItemAttribute)List [index];
+ }
+ set {
+ List [index] = value;
+ }
+ }
+
+ public int Add (XmlArrayItemAttribute attribute)
+ {
+ return List.Add(attribute);
+ }
+
+ public bool Contains(XmlArrayItemAttribute attribute)
+ {
+ return List.Contains(attribute);
+ }
+
+ public void CopyTo(XmlArrayItemAttribute[] array, int index)
+ {
+ List.CopyTo(array, index);
+ }
+
+ public int IndexOf(XmlArrayItemAttribute attribute)
+ {
+ return List.IndexOf(attribute);
+ }
+
+ public void Insert(int index, XmlArrayItemAttribute attribute)
+ {
+ List.Insert(index, attribute);
+ }
+
+ public void Remove(XmlArrayItemAttribute attribute)
+ {
+ List.Remove(attribute);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlAttributeAttribute.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlAttributeAttribute.cs
new file mode 100644
index 00000000000..e23ff75890c
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlAttributeAttribute.cs
@@ -0,0 +1,95 @@
+//
+// XmlAttributeAttribute.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System.Xml.Schema;
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for XmlAttributeAttribute.
+ /// </summary>
+ [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field
+ | AttributeTargets.Parameter | AttributeTargets.ReturnValue)]
+ public class XmlAttributeAttribute : Attribute
+ {
+ private string attributeName;
+ private string dataType;
+ private Type type;
+ private XmlSchemaForm form;
+ private string ns;
+
+ public XmlAttributeAttribute ()
+ {
+ }
+
+ public XmlAttributeAttribute (string attributeName)
+ {
+ AttributeName = attributeName;
+ }
+
+ public XmlAttributeAttribute (Type type)
+ {
+ Type = type;
+ }
+
+ public XmlAttributeAttribute (string attributeName, Type type)
+ {
+ AttributeName = attributeName;
+ Type = type;
+ }
+
+ public string AttributeName {
+ get {
+ return attributeName;
+ }
+ set {
+ attributeName = value;
+ }
+ }
+ public string DataType {
+ get {
+ return dataType;
+ }
+ set {
+ dataType = value;
+ }
+ }
+ public XmlSchemaForm Form {
+ get {
+ return form;
+ }
+ set {
+ if(Namespace != null)
+ form = value;
+ }
+ }
+ public string Namespace {
+ get {
+ return ns;
+ }
+ set {
+ ns = value;
+ }
+ }
+
+ public Type Type
+ {
+ get
+ {
+ return type;
+ }
+ set
+ {
+ type = value;
+ }
+ }
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlAttributeEventArgs.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlAttributeEventArgs.cs
new file mode 100644
index 00000000000..e39c6811573
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlAttributeEventArgs.cs
@@ -0,0 +1,49 @@
+//
+// XmlAttributeEventArgs.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System.Xml;
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for XmlAttributeEventArgs.
+ /// </summary>
+ public class XmlAttributeEventArgs : EventArgs
+ {
+ private XmlAttribute attr;
+ private int lineNumber;
+ private int linePosition;
+ private object obj;
+
+ internal XmlAttributeEventArgs(XmlAttribute attr, int lineNum, int linePos, object source)
+ {
+ this.attr = attr;
+ this.lineNumber = lineNum;
+ this.linePosition = linePos;
+ this.obj = source;
+ }
+
+ public XmlAttribute Attr {
+ get { return attr; }
+ }
+
+ public int LineNumber {
+ get { return lineNumber; }
+ }
+
+ public int LinePosition {
+ get { return linePosition; }
+ }
+
+ public object ObjectBeingDeserialized {
+ get{ return obj; }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlAttributeEventHandler.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlAttributeEventHandler.cs
new file mode 100755
index 00000000000..35a0f2d5474
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlAttributeEventHandler.cs
@@ -0,0 +1,16 @@
+//
+// XmlAttributeEventHandler.cs:
+//
+// Author:
+// Miguel de Icaza (miguel@ximian.com)
+//
+// (C) 2002 Ximian, Inc.
+//
+using System;
+
+namespace System.Xml.Serialization {
+
+ [Serializable]
+ public delegate void XmlAttributeEventHandler (object sender, XmlAttributeEventArgs e);
+}
+
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlAttributeOverrides.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlAttributeOverrides.cs
new file mode 100644
index 00000000000..75c6112c794
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlAttributeOverrides.cs
@@ -0,0 +1,60 @@
+//
+// XmlAttributeOverrides.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System;
+using System.Collections;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for XmlAttributeOverrides.
+ /// </summary>
+ public class XmlAttributeOverrides
+ {
+
+ private Hashtable overrides;
+
+ public XmlAttributeOverrides ()
+ {
+ overrides = new Hashtable();
+ }
+
+ public XmlAttributes this [Type type]
+ {
+ get { return this [type, string.Empty]; }
+ }
+
+ public XmlAttributes this [Type type, string member]
+ {
+ get
+ {
+ return (XmlAttributes) overrides[GetKey(type,member)];
+ }
+ }
+
+ public void Add (Type type, XmlAttributes attributes)
+ {
+ Add(type, string.Empty, attributes);
+ }
+
+ public void Add (Type type, string member, XmlAttributes attributes)
+ {
+ if(overrides[GetKey(type, member)] != null)
+ throw new Exception("The attributes for the given type and Member already exist in the collection");
+
+ overrides.Add(GetKey(type,member), attributes);
+ }
+
+ private TypeMember GetKey(Type type, string member)
+ {
+ return new TypeMember(type, member);
+ }
+
+ }
+} \ No newline at end of file
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlAttributes.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlAttributes.cs
new file mode 100644
index 00000000000..a9f22b5c0b9
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlAttributes.cs
@@ -0,0 +1,439 @@
+//
+// XmlAttributes.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System.Reflection;
+using System;
+using System.ComponentModel;
+using System.Collections;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for XmlAttributes.
+ /// </summary>
+ public class XmlAttributes
+ {
+ private XmlAnyAttributeAttribute xmlAnyAttribute;
+ private XmlAnyElementAttributes xmlAnyElements;
+ private XmlArrayAttribute xmlArray;
+ private XmlArrayItemAttributes xmlArrayItems;
+ private XmlAttributeAttribute xmlAttribute;
+ private XmlChoiceIdentifierAttribute xmlChoiceIdentifier;
+ private object xmlDefaultValue;
+ private XmlElementAttributes xmlElements;
+ private XmlEnumAttribute xmlEnum;
+ private bool xmlIgnore;
+ private bool xmlns;
+ private XmlRootAttribute xmlRoot;
+ private XmlTextAttribute xmlText;
+ private XmlTypeAttribute xmlType;
+
+ private MemberInfo minfo;
+ private FieldInfo finfo;
+ private PropertyInfo pinfo;
+ internal ArrayList XmlIncludes;
+ //internal string ElementName;
+
+ //The element Order in serialization.
+ internal int order;
+ internal bool isAttribute;
+ internal static XmlAttributes.XmlAttributesComparer attrComparer;
+
+ //Sorting Order of Elements: XmlNs, XmlAttributes, XmlElement
+ internal class XmlAttributesComparer : IComparer
+ {
+ public int Compare(object x,object y)
+ {
+ if(x is XmlAttributes && y is XmlAttributes)
+ {
+ XmlAttributes attx = (XmlAttributes)x;
+ XmlAttributes atty = (XmlAttributes)y;
+ if(attx.xmlns)
+ return -1;
+ if(atty.xmlns)
+ return 1;
+ if(attx.isAttribute)
+ return -1;
+ if(atty.isAttribute)
+ return 1;
+ int diff = attx.order - atty.order;
+ if(diff == 0)
+ return 0;
+ if(diff > 0)
+ return 1;
+ if(diff < 0)
+ return -1;
+ }
+ if(x == null)
+ return -1;
+ if(y == null)
+ return 1;
+ throw new Exception("Should never occur. XmlAttributesComparer.Compare");
+ }
+ }
+
+ public XmlAttributes ()
+ {
+ xmlAnyElements = new XmlAnyElementAttributes ();
+ xmlArrayItems = new XmlArrayItemAttributes ();
+ xmlElements = new XmlElementAttributes ();
+ XmlIncludes = new ArrayList();
+ }
+
+ static XmlAttributes ()
+ {
+ attrComparer = new XmlAttributes.XmlAttributesComparer();
+ }
+
+ public XmlAttributes (ICustomAttributeProvider provider)
+ {
+ object[] attributes = provider.GetCustomAttributes(false);
+ foreach(object obj in attributes)
+ {
+ if(obj is XmlAnyAttributeAttribute)
+ xmlAnyAttribute = (XmlAnyAttributeAttribute) obj;
+ else if(obj is XmlAnyElementAttribute)
+ xmlAnyElements.Add((XmlAnyElementAttribute) obj);
+ else if(obj is XmlArrayAttribute)
+ xmlArray = (XmlArrayAttribute) obj;
+ else if(obj is XmlArrayItemAttribute)
+ xmlArrayItems.Add((XmlArrayItemAttribute) obj);
+ else if(obj is XmlAttributeAttribute)
+ xmlAttribute = (XmlAttributeAttribute) obj;
+ else if(obj is XmlChoiceIdentifierAttribute)
+ xmlChoiceIdentifier = (XmlChoiceIdentifierAttribute) obj;
+ else if(obj is DefaultValueAttribute)
+ xmlDefaultValue = obj;
+ else if(obj is XmlElementAttribute )
+ xmlElements.Add((XmlElementAttribute ) obj);
+ else if(obj is XmlEnumAttribute)
+ xmlEnum = (XmlEnumAttribute) obj;
+ else if(obj is XmlIgnoreAttribute)
+ xmlIgnore = true;
+ else if(obj is XmlNamespaceDeclarationsAttribute)
+ xmlns = true;
+ else if(obj is XmlRootAttribute)
+ xmlRoot = (XmlRootAttribute) obj;
+ else if(obj is XmlTextAttribute)
+ xmlText = (XmlTextAttribute) obj;
+ else if(obj is XmlTypeAttribute)
+ xmlType = (XmlTypeAttribute) obj;
+ }
+ }
+
+ #region public properties
+ public XmlAnyAttributeAttribute XmlAnyAttribute
+ {
+ get
+ {
+ return xmlAnyAttribute;
+ }
+ set
+ {
+ xmlAnyAttribute = value;
+ }
+ }
+ public XmlAnyElementAttributes XmlAnyElements
+ {
+ get
+ {
+ return xmlAnyElements;
+ }
+ }
+ public XmlArrayAttribute XmlArray
+ {
+ get
+ {
+ return xmlArray;
+ }
+ set
+ {
+ xmlArray = value;
+ }
+ }
+ public XmlArrayItemAttributes XmlArrayItems
+ {
+ get
+ {
+ return xmlArrayItems;
+ }
+ }
+ public XmlAttributeAttribute XmlAttribute
+ {
+ get
+ {
+ return xmlAttribute;
+ }
+ set
+ {
+ xmlAttribute = value;
+ }
+ }
+ public XmlChoiceIdentifierAttribute XmlChoiceIdentifier
+ {
+ get
+ {
+ return xmlChoiceIdentifier;
+ }
+ }
+ public object XmlDefaultValue
+ {
+ get
+ {
+ return xmlDefaultValue;
+ }
+ set
+ {
+ xmlDefaultValue = value;
+ }
+ }
+ public XmlElementAttributes XmlElements
+ {
+ get
+ {
+ return xmlElements;
+ }
+ }
+ public XmlEnumAttribute XmlEnum
+ {
+ get
+ {
+ return xmlEnum;
+ }
+ set
+ {
+ xmlEnum = value;
+ }
+ }
+ public bool XmlIgnore
+ {
+ get
+ {
+ return xmlIgnore;
+ }
+ set
+ {
+ xmlIgnore = value;
+ }
+ }
+ public bool Xmlns
+ {
+ get
+ {
+ return xmlns;
+ }
+ set
+ {
+ xmlns = value;
+ }
+ }
+ public XmlRootAttribute XmlRoot
+ {
+ get
+ {
+ return xmlRoot;}
+ set
+ {
+ xmlRoot = value;
+ }
+ }
+ public XmlTextAttribute XmlText
+ {
+ get
+ {
+ return xmlText;
+ }
+ set
+ {
+ xmlText = value;
+ }
+ }
+ public XmlTypeAttribute XmlType
+ {
+ get
+ {
+ return xmlType;
+ }
+ set
+ {
+ xmlType = value;
+ }
+ }
+ #endregion
+
+ #region internal properties
+ internal MemberInfo MemberInfo
+ {
+ get { return minfo; }
+ set { minfo = value; }
+ }
+
+ internal FieldInfo FieldInfo
+ {
+ get { return finfo; }
+ set { finfo = value; }
+ }
+
+ internal PropertyInfo PropertyInfo
+ {
+ get { return pinfo; }
+ set { pinfo = value; }
+ }
+ #endregion
+
+ //Only permissible attributes for a class type are: XmlRoot and XmlInclude
+ internal static XmlAttributes FromClass(Type classType)
+ {
+ XmlAttributes XmlAttr = new XmlAttributes();
+ object[] attributes = classType.GetCustomAttributes(false);
+ foreach(object obj in attributes)
+ {
+ if(obj is XmlRootAttribute)
+ XmlAttr.xmlRoot = (XmlRootAttribute) obj;
+ else if(obj is XmlIncludeAttribute)
+ XmlAttr.XmlIncludes.Add(obj);
+ }
+ return XmlAttr;
+ }
+
+ internal static XmlAttributes FromField(MemberInfo member, FieldInfo finfo)
+ {
+ XmlAttributes XmlAttr = new XmlAttributes();
+ object[] attributes = member.GetCustomAttributes(false);
+ XmlAttr.AddMemberAttributes(attributes);
+
+ XmlAttr.minfo = member;
+ XmlAttr.finfo = finfo;
+
+ return XmlAttr;
+ }
+
+
+ internal static XmlAttributes FromProperty(MemberInfo member, PropertyInfo pinfo)
+ {
+
+ XmlAttributes XmlAttr = new XmlAttributes();
+ object[] attributes = member.GetCustomAttributes(false);
+ XmlAttr.AddMemberAttributes(attributes);
+
+ XmlAttr.minfo = member;
+ XmlAttr.pinfo = pinfo;
+ return XmlAttr;
+ }
+
+ internal void AddMemberAttributes(object[] attributes)
+ {
+ foreach(object obj in attributes)
+ {
+ if(obj is XmlAnyAttributeAttribute)
+ {
+ xmlAnyAttribute = (XmlAnyAttributeAttribute) obj;
+ isAttribute = true;
+ }
+ else if(obj is XmlAttributeAttribute)
+ {
+ xmlAttribute = (XmlAttributeAttribute) obj;
+ isAttribute = true;
+ }
+ else if(obj is XmlNamespaceDeclarationsAttribute)
+ {
+ xmlns = true;
+ isAttribute = true;
+ }
+ else if(obj is XmlAnyElementAttribute)
+ {
+ xmlAnyElements.Add((XmlAnyElementAttribute) obj);
+ order = ((XmlAnyElementAttribute) obj).Order;
+ }
+ else if(obj is XmlArrayAttribute)
+ {
+ xmlArray = (XmlArrayAttribute) obj;
+ order = ((XmlArrayAttribute) obj).Order;
+ }
+ else if(obj is XmlArrayItemAttribute)
+ {
+ xmlArrayItems.Add((XmlArrayItemAttribute) obj);
+ order = ((XmlArrayItemAttribute) obj).Order;
+ }
+ else if(obj is XmlChoiceIdentifierAttribute)
+ {
+ xmlChoiceIdentifier = (XmlChoiceIdentifierAttribute) obj;
+ order = ((XmlChoiceIdentifierAttribute) obj).Order;
+ }
+ else if(obj is XmlTextAttribute)
+ {
+ xmlText = (XmlTextAttribute) obj;
+ order = ((XmlTextAttribute) obj).Order;
+ }
+ else if(obj is XmlElementAttribute )
+ {
+ xmlElements.Add((XmlElementAttribute ) obj);
+ order = ((XmlElementAttribute ) obj).Order;
+ }
+ else if(obj is DefaultValueAttribute)
+ {
+ xmlDefaultValue = ((DefaultValueAttribute ) obj).Value;
+ }
+ else if(obj is XmlEnumAttribute)
+ {
+ xmlEnum = (XmlEnumAttribute) obj;
+ }
+ else if(obj is XmlIgnoreAttribute)
+ {
+ xmlIgnore = true;
+ }
+ else if(obj is XmlRootAttribute)
+ {
+ throw new Exception("should never happen. XmlRoot on a member");
+ }
+ else if(obj is XmlTypeAttribute)
+ {
+ xmlType = (XmlTypeAttribute) obj;
+ }
+ }
+ }
+
+ internal string GetAttributeName(Type type, string defaultName)
+ {
+ if(XmlAttribute != null && XmlAttribute.AttributeName != null && XmlAttribute.AttributeName != "")
+ return XmlAttribute.AttributeName;
+ return defaultName;
+ }
+
+ internal string GetElementName(Type type, string defaultName)
+ {
+ foreach(XmlElementAttribute elem in XmlElements)
+ {
+ if(elem.Type == type && elem.ElementName != null && elem.ElementName != "")
+ return elem.ElementName;
+ else if(elem.Type == null && elem.ElementName != null && elem.ElementName != "")
+ return elem.ElementName;
+ }
+ return defaultName;
+ }
+
+ internal string GetAttributeNamespace(Type type)
+ {
+ if(XmlAttribute != null)
+ return XmlAttribute.Namespace;
+ return null;
+ }
+ internal string GetElementNamespace(Type type)
+ {
+ foreach(XmlElementAttribute elem in XmlElements)
+ {
+ if(elem.Type == type )
+ return elem.Namespace;
+ else if(elem.Type == null)
+ return elem.Namespace;
+ }
+ return null;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlChoiceIdentifierAttribute.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlChoiceIdentifierAttribute.cs
new file mode 100644
index 00000000000..6b84f761e02
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlChoiceIdentifierAttribute.cs
@@ -0,0 +1,51 @@
+//
+// XmlChoiceIdentifierAttribute.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for XmlChoiceIdentifierAttribute.
+ /// </summary>
+ [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field
+ | AttributeTargets.Parameter | AttributeTargets.ReturnValue)]
+ public class XmlChoiceIdentifierAttribute : Attribute
+ {
+ private string memberName;
+ private int order;
+
+ public XmlChoiceIdentifierAttribute ()
+ {
+ }
+ public XmlChoiceIdentifierAttribute (string name)
+ {
+ MemberName = name;
+ }
+
+ public string MemberName {
+ get {
+ return memberName;
+ }
+ set {
+ memberName = value;
+ }
+ }
+
+ /// <summary>
+ /// Specifies Order in which Memberswill be serialized as Elements.
+ /// </summary>
+ internal int Order
+ {
+ get{ return order; }
+ set{ order = value; }
+ }
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlCodeExporter.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlCodeExporter.cs
new file mode 100644
index 00000000000..d6ead00212f
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlCodeExporter.cs
@@ -0,0 +1,81 @@
+//
+// System.Xml.Serialization.XmlCodeExporter
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System.CodeDom;
+
+namespace System.Xml.Serialization {
+ public class XmlCodeExporter {
+
+ #region Fields
+
+ CodeNamespace codeNamespace;
+ CodeCompileUnit codeCompileUnit;
+ CodeAttributeDeclarationCollection includeMetadata;
+
+ #endregion
+
+ #region Constructors
+
+ public XmlCodeExporter (CodeNamespace codeNamespace)
+ {
+ includeMetadata = new CodeAttributeDeclarationCollection ();
+ this.codeNamespace = codeNamespace;
+ }
+
+ public XmlCodeExporter (CodeNamespace codeNamespace, CodeCompileUnit codeCompileUnit)
+ : this (codeNamespace)
+ {
+ this.codeCompileUnit = codeCompileUnit;
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public CodeAttributeDeclarationCollection IncludeMetadata {
+ get { return includeMetadata; }
+ }
+
+ #endregion Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public void AddMappingMetadata (CodeAttributeDeclarationCollection metadata, XmlMemberMapping member, string ns)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void AddMappingMetadata (CodeAttributeDeclarationCollection metadata, XmlTypeMapping member, string ns)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void AddMappingMetadata (CodeAttributeDeclarationCollection metadata, XmlMemberMapping member, string ns, bool forceUseMemberName)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void ExportMembersMapping (XmlMembersMapping xmlMembersMapping)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void ExportTypeMapping (XmlTypeMapping xmlTypeMapping)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlCustomFormatter.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlCustomFormatter.cs
new file mode 100644
index 00000000000..90f710fac73
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlCustomFormatter.cs
@@ -0,0 +1,133 @@
+//
+// System.Xml.Serialization.XmlCustomFormatter.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System;
+using System.Text;
+using System.Xml;
+
+namespace System.Xml.Serialization {
+ internal class XmlCustomFormatter {
+
+ #region Methods
+
+ [MonoTODO]
+ internal static byte[] FromByteArrayBase64 (byte[] value)
+ {
+ throw new NotImplementedException ();
+ }
+
+ internal static string FromByteArrayHex (byte[] value)
+ {
+ StringBuilder output = new StringBuilder ();
+ foreach (byte val in value)
+ output.Append (val.ToString ("X2"));
+ return output.ToString ();
+ }
+
+ internal static string FromChar (char value)
+ {
+ return ((int) value).ToString ();
+ }
+
+ internal static string FromDate (DateTime value)
+ {
+ return XmlConvert.ToString (value, "yyyy-MM-dd");
+ }
+
+ internal static string FromDateTime (DateTime value)
+ {
+ return XmlConvert.ToString (value, "yyyy-MM-ddTHH:mm:ss.fffffffzzz");
+ }
+
+ internal static string FromTime (DateTime value)
+ {
+ return XmlConvert.ToString (value, "HH:mm:ss.fffffffzzz");
+ }
+
+ internal static string FromEnum (long value, string[] values, long[] ids)
+ {
+ int length = ids.Length;
+
+ for (int i = 0; i < length; i ++) {
+ if (ids[i] == value)
+ if (i >= values.Length)
+ return String.Empty;
+ else
+ return values[i].ToString ();
+ }
+ return value.ToString ();
+ }
+
+ internal static string FromXmlName (string name)
+ {
+ return XmlConvert.EncodeName (name);
+ }
+
+ internal static string FromXmlNCName (string ncName)
+ {
+ return XmlConvert.EncodeLocalName (ncName);
+ }
+
+ internal static string FromXmlNmToken (string nmToken)
+ {
+ return XmlConvert.EncodeNmToken (nmToken);
+ }
+
+ internal static string FromXmlNmTokens (string nmTokens)
+ {
+ StringBuilder output = new StringBuilder ();
+ string [] tokens = nmTokens.Split (' ');
+ foreach (string token in tokens)
+ output.Append (FromXmlNmToken (token));
+ return output.ToString ();
+ }
+
+ internal static char ToChar (string value)
+ {
+ return (char) XmlConvert.ToUInt16 (value);
+ }
+
+ internal static DateTime ToDate (string value)
+ {
+ return ToDateTime (value);
+ }
+
+ internal static DateTime ToDateTime (string value)
+ {
+ return XmlConvert.ToDateTime (value);
+ }
+
+ internal static DateTime ToTime (string value)
+ {
+ return ToDateTime (value);
+ }
+
+ internal static string ToXmlName (string value)
+ {
+ return XmlConvert.DecodeName (value);
+ }
+
+ internal static string ToXmlNCName (string value)
+ {
+ return ToXmlName (value);
+ }
+
+ internal static string ToXmlNmToken (string value)
+ {
+ return ToXmlName (value);
+ }
+
+ internal static string ToXmlNmTokens (string value)
+ {
+ return ToXmlName (value);
+ }
+
+ #endregion // Methods
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlElementAttribute.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlElementAttribute.cs
new file mode 100644
index 00000000000..f72e43bc347
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlElementAttribute.cs
@@ -0,0 +1,104 @@
+//
+// XmlElementAttribute.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System.Xml.Schema;
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for XmlElementAttribute.
+ /// </summary
+ [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field
+ | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple=true)]
+ public class XmlElementAttribute : Attribute
+ {
+ private string dataType;
+ private string elementName;
+ private XmlSchemaForm form;
+ private string ns;
+ private bool isNullable;
+ private Type type;
+ private int order;
+
+ public XmlElementAttribute ()
+ {
+ }
+ public XmlElementAttribute (string elementName)
+ {
+ ElementName = elementName;
+ }
+ public XmlElementAttribute (Type type)
+ {
+ Type = type;
+ }
+ public XmlElementAttribute (string elementName, Type type)
+ {
+ ElementName = elementName;
+ Type = type;
+ }
+
+ public string DataType {
+ get {
+ return dataType;
+ }
+ set {
+ dataType = value;
+ }
+ }
+ public string ElementName {
+ get {
+ return elementName;
+ }
+ set {
+ elementName = value;
+ }
+ }
+ public XmlSchemaForm Form {
+ get {
+ return form;
+ }
+ set {
+ form = value;
+ }
+ }
+ public string Namespace {
+ get {
+ return ns;
+ }
+ set {
+ ns = value;
+ }
+ }
+ public bool IsNullable {
+ get {
+ return isNullable;
+ }
+ set {
+ isNullable = value;
+ }
+ }
+ public Type Type {
+ get {
+ return type;
+ }
+ set {
+ type = value;
+ }
+ }
+ /// <summary>
+ /// Specifies Order in which Memberswill be serialized as Elements.
+ /// </summary>
+ internal int Order
+ {
+ get{ return order; }
+ set{ order = value; }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlElementAttributes.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlElementAttributes.cs
new file mode 100644
index 00000000000..b2a75c1d50c
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlElementAttributes.cs
@@ -0,0 +1,59 @@
+//
+// XmlElementAttributes.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System.Collections;
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for XmlElementAttributes.
+ /// </summary>
+ public class XmlElementAttributes : CollectionBase
+ {
+ public XmlElementAttribute this [int index] {
+ get {
+ return (XmlElementAttribute)List [index];
+ }
+ set {
+ List [index] = value;
+ }
+ }
+
+ public int Add (XmlElementAttribute attribute)
+ {
+ return List.Add (attribute);
+ }
+
+ public bool Contains(XmlElementAttribute attribute)
+ {
+ return List.Contains(attribute);
+ }
+
+ public int IndexOf(XmlElementAttribute attribute)
+ {
+ return List.IndexOf(attribute);
+ }
+
+ public void Insert(int index, XmlElementAttribute attribute)
+ {
+ List.Insert(index, attribute);
+ }
+
+ public void Remove(XmlElementAttribute attribute)
+ {
+ List.Remove(attribute);
+ }
+
+ public void CopyTo(XmlElementAttribute[] array,int index)
+ {
+ List.CopyTo(array, index);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlElementEventArgs.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlElementEventArgs.cs
new file mode 100644
index 00000000000..94655c0bb0c
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlElementEventArgs.cs
@@ -0,0 +1,53 @@
+//
+// XmlElementEventArgs.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System.Xml;
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for XmlElementEventArgs.
+ /// </summary>
+ public class XmlElementEventArgs : EventArgs
+ {
+ private XmlElement attr;
+ private int lineNumber;
+ private int linePosition;
+ private object obj;
+
+ internal XmlElementEventArgs(XmlElement attr, int lineNum, int linePos, object source)
+ {
+ this.attr = attr;
+ this.lineNumber = lineNum;
+ this.linePosition = linePos;
+ this.obj = source;
+ }
+
+ public XmlElement Element
+ {
+ get { return attr; }
+ }
+
+ public int LineNumber
+ {
+ get { return lineNumber; }
+ }
+
+ public int LinePosition
+ {
+ get { return linePosition; }
+ }
+
+ public object ObjectBeingDeserialized
+ {
+ get{ return obj; }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlElementEventHandler.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlElementEventHandler.cs
new file mode 100755
index 00000000000..be4dda7428a
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlElementEventHandler.cs
@@ -0,0 +1,16 @@
+//
+// XmlElementEventHandler.cs:
+//
+// Author:
+// Miguel de Icaza (miguel@ximian.com)
+//
+// (C) 2002 Ximian, Inc.
+//
+using System;
+
+namespace System.Xml.Serialization {
+
+ [Serializable]
+ public delegate void XmlElementEventHandler (object sender, XmlElementEventArgs e);
+}
+
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlEnumAttribute.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlEnumAttribute.cs
new file mode 100644
index 00000000000..e95087c09fb
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlEnumAttribute.cs
@@ -0,0 +1,41 @@
+//
+// XmlEnumAttribute.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for XmlEnumAttribute.
+ /// </summary>\
+ [AttributeUsage(AttributeTargets.Field)]
+ public class XmlEnumAttribute : Attribute
+ {
+ private string name;
+
+ public XmlEnumAttribute ()
+ {
+ }
+
+ public XmlEnumAttribute (string name)
+ {
+ Name = name;
+ }
+
+ public string Name {
+ get {
+ return name;
+ }
+ set {
+ name = value;
+ }
+ }
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlIgnoreAttribute.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlIgnoreAttribute.cs
new file mode 100644
index 00000000000..cb0fe82ba33
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlIgnoreAttribute.cs
@@ -0,0 +1,26 @@
+//
+// XmlIgnoreAttribute.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for XmlIgnoreAttribute.
+ /// </summary>
+ [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field
+ | AttributeTargets.Parameter | AttributeTargets.ReturnValue)]
+ public class XmlIgnoreAttribute : Attribute
+ {
+ public XmlIgnoreAttribute ()
+ {
+
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlIncludeAttribute.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlIncludeAttribute.cs
new file mode 100644
index 00000000000..e7eafcdf4cc
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlIncludeAttribute.cs
@@ -0,0 +1,37 @@
+//
+// XmlIncludeAttribute.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for XmlIncludeAttribute.
+ /// </summary>
+ [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct |
+ AttributeTargets.Method)]
+ public class XmlIncludeAttribute : Attribute
+ {
+ private Type type;
+
+ public XmlIncludeAttribute (Type type)
+ {
+ Type = type;
+ }
+
+ public Type Type {
+ get {
+ return type;
+ }
+ set {
+ type = value;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlMapping.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlMapping.cs
new file mode 100644
index 00000000000..a989e674218
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlMapping.cs
@@ -0,0 +1,23 @@
+//
+// XmlMapping.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for XmlMapping.
+ /// </summary>
+ public abstract class XmlMapping
+ {
+ internal XmlMapping ()
+ {
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlMemberMapping.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlMemberMapping.cs
new file mode 100644
index 00000000000..8c222aa8b82
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlMemberMapping.cs
@@ -0,0 +1,56 @@
+//
+// System.Xml.Serialization.XmlMemberMapping
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+namespace System.Xml.Serialization {
+ public class XmlMemberMapping {
+
+ internal XmlMemberMapping ()
+ {
+ }
+
+ #region Properties
+
+ public bool Any {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public string ElementName {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public string MemberName {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public string Namespace {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public string TypeFullName {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public string TypeName {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public string TypeNamespace {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlMembersMapping.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlMembersMapping.cs
new file mode 100644
index 00000000000..ebd9b6bc60d
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlMembersMapping.cs
@@ -0,0 +1,53 @@
+//
+// System.Xml.Serialization.XmlMembersMapping
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System.Reflection;
+
+namespace System.Xml.Serialization {
+ public class XmlMembersMapping : XmlMapping {
+
+ internal XmlMembersMapping ()
+ {
+ }
+
+ #region Properties
+
+ public int Count {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public string ElementName {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public XmlMemberMapping this [int index] {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public string Namespace {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public string TypeName {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public string TypeNamespace {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlNamespaceDeclarationsAttribute.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlNamespaceDeclarationsAttribute.cs
new file mode 100644
index 00000000000..4cc59b3cf00
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlNamespaceDeclarationsAttribute.cs
@@ -0,0 +1,26 @@
+//
+// XmlNamespaceDeclarationsAttribute.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for XmlNamespaceDeclarationsAttribute.
+ /// </summary>
+ [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field
+ | AttributeTargets.Parameter | AttributeTargets.ReturnValue)]
+ public class XmlNamespaceDeclarationsAttribute : Attribute
+ {
+ public XmlNamespaceDeclarationsAttribute ()
+ {
+
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlNodeEventArgs.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlNodeEventArgs.cs
new file mode 100644
index 00000000000..8064d6855f2
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlNodeEventArgs.cs
@@ -0,0 +1,82 @@
+//
+// XmlNodeEventArgs.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System.Xml;
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for XmlNodeEventArgs.
+ /// </summary>
+ public class XmlNodeEventArgs : EventArgs
+ {
+ private int linenumber;
+ private int lineposition ;
+ private string localname;
+ private string name;
+ private string nsuri;
+ private XmlNodeType nodetype;
+ private object source;
+ private string text;
+
+ internal XmlNodeEventArgs(int linenumber, int lineposition, string localname, string name, string nsuri,
+ XmlNodeType nodetype, object source, string text)
+ {
+ this.linenumber = linenumber;
+ this.lineposition = lineposition;
+ this.localname = localname;
+ this.name = name;
+ this.nsuri = nsuri;
+ this.nodetype = nodetype;
+ this.source = source;
+ this.text = text;
+ }
+
+ public int LineNumber
+ {
+ get { return linenumber; }
+ }
+
+ public int LinePosition
+ {
+ get { return lineposition; }
+ }
+
+ public string LocalName
+ {
+ get { return localname; }
+ }
+
+ public string Name
+ {
+ get { return name; }
+ }
+
+ public string NamespaceURI
+ {
+ get { return nsuri; }
+ }
+
+ public XmlNodeType NodeType
+ {
+ get { return nodetype; }
+ }
+
+ public object ObjectBeingDeserialized
+ {
+ get { return source; }
+ }
+
+ public string Text
+ {
+ get { return text; }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlNodeEventHandler.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlNodeEventHandler.cs
new file mode 100755
index 00000000000..4c1fdb5c92b
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlNodeEventHandler.cs
@@ -0,0 +1,16 @@
+//
+// XmlNodeEventHandler.cs:
+//
+// Author:
+// Miguel de Icaza (miguel@ximian.com)
+//
+// (C) 2002 Ximian, Inc.
+//
+using System;
+
+namespace System.Xml.Serialization {
+
+ [Serializable]
+ public delegate void XmlNodeEventHandler (object sender, XmlNodeEventArgs e);
+}
+
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs
new file mode 100644
index 00000000000..108a50b2929
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs
@@ -0,0 +1,128 @@
+//
+// System.Xml.Serialization.XmlReflectionImporter
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System.Reflection;
+
+namespace System.Xml.Serialization {
+ public class XmlReflectionImporter {
+
+ string defaultNamespace;
+ XmlAttributeOverrides attributeOverrides;
+
+ #region Constructors
+
+ public XmlReflectionImporter ()
+ : this (null, null)
+ {
+ }
+
+ public XmlReflectionImporter (string defaultNamespace)
+ : this (null, defaultNamespace)
+ {
+ }
+
+ public XmlReflectionImporter (XmlAttributeOverrides attributeOverrides)
+ : this (attributeOverrides, null)
+ {
+ }
+
+ public XmlReflectionImporter (XmlAttributeOverrides attributeOverrides, string defaultNamespace)
+ {
+ if (defaultNamespace == null)
+ this.defaultNamespace = String.Empty;
+ else
+ this.defaultNamespace = defaultNamespace;
+
+ if (attributeOverrides == null)
+ this.attributeOverrides = new XmlAttributeOverrides();
+ else
+ this.attributeOverrides = attributeOverrides;
+ }
+
+ #endregion // Constructors
+
+ #region Methods
+
+ [MonoTODO]
+ public XmlMembersMapping ImportMembersMapping (string elementName,
+ string ns,
+ XmlReflectionMember [] members,
+ bool hasWrapperElement)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public XmlTypeMapping ImportTypeMapping (Type type)
+ {
+ return ImportTypeMapping (type, null, null);
+ }
+
+ public XmlTypeMapping ImportTypeMapping (Type type, string defaultNamespace)
+ {
+ return ImportTypeMapping (type, null, defaultNamespace);
+ }
+
+ public XmlTypeMapping ImportTypeMapping (Type type, XmlRootAttribute group)
+ {
+ return ImportTypeMapping (type, group, null);
+ }
+
+ public XmlTypeMapping ImportTypeMapping (Type type, XmlRootAttribute group, string defaultNamespace)
+ {
+ if (type == null)
+ throw new ArgumentNullException ("type");
+
+ if (type == typeof (void))
+ throw new InvalidOperationException ("Type " + type.Name +
+ " may not be serialized.");
+
+ XmlAttributes atts = new XmlAttributes (type);
+ TypeData data = TypeTranslator.GetTypeData (type);
+ string elementName = data.ElementName;
+ string typeName = data.TypeName;
+ string typeFullName = data.FullTypeName;
+ string nameSpc = (defaultNamespace != null) ? defaultNamespace : this.defaultNamespace;
+ return new XmlTypeMapping (elementName, nameSpc, typeFullName, typeName);
+ }
+
+ private void ImportTypeMapping (TypeData data, string ns)
+ {
+ ImportTypeMapping (data.Type, null, ns);
+ }
+
+ public void IncludeType (Type type)
+ {
+ if (type == null)
+ throw new ArgumentNullException ("type");
+
+ TypeData data = TypeTranslator.GetTypeData (type);
+ ImportTypeMapping (data, defaultNamespace);
+ }
+
+ public void IncludeTypes (ICustomAttributeProvider provider)
+ {
+ if (provider == null)
+ throw new ArgumentNullException ("provider");
+
+ Type ixml = typeof (IXmlSerializable);
+ object [] customAttrs = provider.GetCustomAttributes (typeof (XmlIncludeAttribute), false);
+ foreach (XmlIncludeAttribute att in customAttrs) {
+ Type type = att.Type;
+ if (ixml.IsAssignableFrom (type)) {
+ string fmt = "Type {0} is derived from {1} and therefore cannot " +
+ "be used with attribute XmlInclude";
+ throw new InvalidOperationException (String.Format (fmt, type, ixml));
+ }
+ IncludeType (type);
+ }
+ }
+
+ #endregion // Methods
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionMember.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionMember.cs
new file mode 100644
index 00000000000..43ba1a82e9b
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionMember.cs
@@ -0,0 +1,66 @@
+//
+// System.Xml.Serialization.XmlReflectionMember
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+namespace System.Xml.Serialization {
+ public class XmlReflectionMember {
+
+ #region Fields
+
+ bool isReturnValue;
+ string memberName;
+ Type memberType;
+ bool overrideIsNullable;
+ SoapAttributes soapAttributes;
+ XmlAttributes xmlAttributes;
+
+ #endregion
+
+ #region Constructors
+
+ public XmlReflectionMember ()
+ {
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public bool IsReturnValue {
+ get { return isReturnValue; }
+ set { isReturnValue = value; }
+ }
+
+ public string MemberName {
+ get { return memberName; }
+ set { memberName = value; }
+ }
+
+ public Type MemberType {
+ get { return memberType; }
+ set { memberType = value; }
+ }
+
+ public bool OverrideIsNullable {
+ get { return overrideIsNullable; }
+ set { overrideIsNullable = value; }
+ }
+
+ public SoapAttributes SoapAttributes {
+ get { return soapAttributes; }
+ set { soapAttributes = value; }
+ }
+
+ public XmlAttributes XmlAttributes {
+ get { return xmlAttributes; }
+ set { xmlAttributes = value; }
+ }
+
+ #endregion // Properties
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlRootAttribute.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlRootAttribute.cs
new file mode 100644
index 00000000000..cc3a83c1b9f
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlRootAttribute.cs
@@ -0,0 +1,73 @@
+//
+// XmlRootAttribute.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for XmlRootAttribute.
+ /// </summary>
+ [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct |
+ AttributeTargets.Enum | AttributeTargets.Interface |
+ AttributeTargets.ReturnValue)]
+ public class XmlRootAttribute : Attribute
+ {
+ private string dataType;
+ private string elementName;
+ private bool isNullable;
+ private string ns;
+
+ public XmlRootAttribute ()
+ {
+
+ }
+ public XmlRootAttribute (string elementName)
+ {
+ ElementName = elementName;
+ }
+
+ public string DataType
+ {
+ get {
+ return dataType;
+ }
+ set {
+ dataType = value;
+ }
+ }
+ public string ElementName
+ {
+ get {
+ return elementName;
+ }
+ set {
+ elementName = value;
+ }
+ }
+ public bool IsNullable
+ {
+ get {
+ return isNullable;
+ }
+ set {
+ isNullable = value;
+ }
+ }
+ public string Namespace
+ {
+ get {
+ return ns;
+ }
+ set {
+ ns = value;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlSchemaExporter.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlSchemaExporter.cs
new file mode 100644
index 00000000000..991bbce1b3e
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlSchemaExporter.cs
@@ -0,0 +1,58 @@
+//
+// System.Xml.Serialization.XmlSchemaExporter
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System.Xml;
+
+namespace System.Xml.Serialization {
+ public class XmlSchemaExporter {
+
+ #region Fields
+
+ XmlSchemas schemas;
+
+ #endregion
+
+ #region Constructors
+
+ public XmlSchemaExporter (XmlSchemas schemas)
+ {
+ this.schemas = schemas;
+ }
+
+ #endregion // Constructors
+
+ #region Methods
+
+ [MonoTODO]
+ public string ExportAnyType (string ns)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void ExportMembersMapping (XmlMembersMapping xmlMembersMapping)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public XmlQualifiedName ExportTypeMapping (XmlMembersMapping xmlMembersMapping)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void ExportTypeMapping (XmlTypeMapping xmlTypeMapping)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs
new file mode 100644
index 00000000000..fd0df8faadc
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs
@@ -0,0 +1,91 @@
+//
+// System.Xml.Serialization.XmlSchemaImporter
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System.Xml;
+
+namespace System.Xml.Serialization {
+ public class XmlSchemaImporter {
+
+ #region Fields
+
+ XmlSchemas schemas;
+ CodeIdentifiers typeIdentifiers;
+
+ #endregion
+
+ #region Constructors
+
+ public XmlSchemaImporter (XmlSchemas schemas)
+ {
+ this.schemas = schemas;
+ }
+
+ public XmlSchemaImporter (XmlSchemas schemas, CodeIdentifiers typeIdentifiers)
+ : this (schemas)
+ {
+ this.typeIdentifiers = typeIdentifiers;
+ }
+
+ #endregion // Constructors
+
+ #region Methods
+
+ [MonoTODO]
+ public XmlMembersMapping ImportAnyType (XmlQualifiedName typeName, string elementName)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public XmlTypeMapping ImportDerivedTypeMapping (XmlQualifiedName name, Type baseType)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public XmlTypeMapping ImportDerivedTypeMapping (XmlQualifiedName name, bool baseTypeCanBeIndirect)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public XmlTypeMapping ImportDerivedTypeMapping (XmlQualifiedName name,
+ Type baseType,
+ bool baseTypeCanBeIndirect)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public XmlMembersMapping ImportMembersMapping (XmlQualifiedName name)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public XmlMembersMapping ImportMembersMapping (XmlQualifiedName[] names)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public XmlMembersMapping ImportMembersMapping (XmlQualifiedName[] names, Type baseType, bool baseTypeCanBeIndirect)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public XmlTypeMapping ImportTypeMapping (XmlQualifiedName name)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlSchemas.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlSchemas.cs
new file mode 100644
index 00000000000..0918f928489
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlSchemas.cs
@@ -0,0 +1,148 @@
+//
+// System.Xml.Serialization.XmlSchemas
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System.Collections;
+using System.Xml.Schema;
+
+namespace System.Xml.Serialization {
+ public class XmlSchemas : CollectionBase {
+
+ #region Fields
+
+ Hashtable table = new Hashtable ();
+
+ #endregion
+
+ #region Constructors
+
+ public XmlSchemas ()
+ {
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public XmlSchema this [int index] {
+ get {
+ if (index < 0 || index > Count)
+ throw new ArgumentOutOfRangeException ();
+
+ return (XmlSchema) List [index];
+ }
+ set { List [index] = value; }
+ }
+
+ public XmlSchema this [string ns] {
+ get { return (XmlSchema) table[ns]; }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ public int Add (XmlSchema schema)
+ {
+ Insert (Count, schema);
+ return (Count - 1);
+ }
+
+ public void Add (XmlSchemas schemas)
+ {
+ foreach (XmlSchema schema in schemas)
+ Add (schema);
+ }
+
+ public bool Contains (XmlSchema schema)
+ {
+ return List.Contains (schema);
+ }
+
+ public void CopyTo (XmlSchema[] array, int index)
+ {
+ List.CopyTo (array, index);
+ }
+
+ public object Find (XmlQualifiedName name, Type type)
+ {
+ XmlSchema schema = table [name.Namespace] as XmlSchema;
+ if (schema == null)
+ return null;
+
+ if (!schema.IsCompiled) {
+ try {
+ schema.Compile (null);
+ } catch {
+ throw new InvalidOperationException ("Error compiling XmlSchema " +
+ name.Namespace);
+ }
+ }
+
+ XmlSchemaObjectTable tbl = null;
+
+ if (type == typeof (XmlSchemaSimpleType) || type == typeof (XmlSchemaComplexType))
+ tbl = schema.SchemaTypes;
+ else if (type == typeof (XmlSchemaAttribute))
+ tbl = schema.Attributes;
+ else if (type == typeof (XmlSchemaAttributeGroup))
+ tbl = schema.AttributeGroups;
+ else if (type == typeof (XmlSchemaElement))
+ tbl = schema.Elements;
+ else if (type == typeof (XmlSchemaGroup))
+ tbl = schema.Groups;
+ else if (type == typeof (XmlSchemaNotation))
+ tbl = schema.Notations;
+
+ return (tbl != null) ? tbl [name] : null;
+ }
+
+ public int IndexOf (XmlSchema schema)
+ {
+ return List.IndexOf (schema);
+ }
+
+ public void Insert (int index, XmlSchema schema)
+ {
+ List.Insert (index, schema);
+ }
+
+ [MonoTODO]
+ public static bool IsDataSet (XmlSchema schema)
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected override void OnClear ()
+ {
+ table.Clear ();
+ }
+
+ protected override void OnInsert (int index, object value)
+ {
+ table [((XmlSchema) value).TargetNamespace] = value;
+ }
+
+ protected override void OnRemove (int index, object value)
+ {
+ table.Remove (value);
+ }
+
+ protected override void OnSet (int index, object oldValue, object newValue)
+ {
+ table [((XmlSchema) oldValue).TargetNamespace] = newValue;
+ }
+
+ public void Remove (XmlSchema schema)
+ {
+ List.Remove (schema);
+ }
+
+ #endregion // Methods
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationCollectionFixupCallback.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationCollectionFixupCallback.cs
new file mode 100644
index 00000000000..2fd79643126
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationCollectionFixupCallback.cs
@@ -0,0 +1,17 @@
+//
+// System.Xml.Serialization.XmlSerializationCollectionFixupCallback.cs:
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System;
+
+namespace System.Xml.Serialization {
+
+ [Serializable]
+ public delegate void XmlSerializationCollectionFixupCallback (object collection, object collectionItems);
+}
+
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationFixupCallback.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationFixupCallback.cs
new file mode 100644
index 00000000000..e1bf47a4fa5
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationFixupCallback.cs
@@ -0,0 +1,17 @@
+//
+// System.Xml.Serialization.XmlSerializationFixupCallback.cs:
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System;
+
+namespace System.Xml.Serialization {
+
+ [Serializable]
+ public delegate void XmlSerializationFixupCallback (object fixup);
+}
+
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationReadCallback.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationReadCallback.cs
new file mode 100644
index 00000000000..bd426ff0415
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationReadCallback.cs
@@ -0,0 +1,17 @@
+//
+// System.Xml.Serialization.XmlSerializationReadCallback.cs:
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System;
+
+namespace System.Xml.Serialization {
+
+ [Serializable]
+ public delegate object XmlSerializationReadCallback ();
+}
+
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationReader.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationReader.cs
new file mode 100644
index 00000000000..1ffff04a79b
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationReader.cs
@@ -0,0 +1,634 @@
+//
+// System.Xml.Serialization.XmlSerializationReader.cs
+//
+// Authors:
+// Tim Coleman (tim@timcoleman.com)
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// Copyright (C) Tim Coleman, 2002
+// (c) 2002 Ximian, Inc. (http://www.ximian.com)
+//
+
+using System;
+using System.Collections;
+using System.Xml;
+
+namespace System.Xml.Serialization {
+ public abstract class XmlSerializationReader {
+
+ #region Fields
+
+ XmlDocument document;
+ XmlReader reader;
+ ArrayList fixups;
+ ArrayList collFixups;
+ Hashtable readCallbacks;
+ Hashtable typesCallbacks;
+ ArrayList noIDTargets;
+ Hashtable targets;
+
+ string w3SchemaNS;
+ string w3SchemaNS2000;
+ string w3SchemaNS1999;
+ string w3InstanceNS;
+ string w3InstanceNS2000;
+ string w3InstanceNS1999;
+ string soapNS;
+ string schema;
+ string wsdlNS;
+ string wsdlArrayType;
+ string nullX;
+ string nil;
+ string typeX;
+ string arrayType;
+ string anyType;
+ #endregion
+
+ private void Initialize ()
+ {
+ w3SchemaNS = reader.NameTable.Add ("http://www.w3.org/2001/XMLSchema");
+ w3SchemaNS2000 = reader.NameTable.Add ("http://www.w3.org/2000/10/XMLSchema");
+ w3SchemaNS1999 = reader.NameTable.Add ("http://www.w3.org/1999/XMLSchema");
+ w3InstanceNS = reader.NameTable.Add ("http://www.w3.org/2001/XMLSchema-instance");
+ w3InstanceNS2000 = reader.NameTable.Add ("http://www.w3.org/2000/10/XMLSchema-instance");
+ w3InstanceNS1999 = reader.NameTable.Add ("http://www.w3.org/1999/XMLSchema-instance");
+ soapNS = reader.NameTable.Add ("http://schemas.xmlsoap.org/soap/encoding/");
+ schema = reader.NameTable.Add ("schema");
+ wsdlNS = reader.NameTable.Add ("http://schemas.xmlsoap.org/wsdl/");
+ wsdlArrayType = reader.NameTable.Add ("arrayType");
+ nullX = reader.NameTable.Add ("null");
+ nil = reader.NameTable.Add ("nil");
+ typeX = reader.NameTable.Add ("type");
+ arrayType = reader.NameTable.Add ("arrayType");
+ anyType = reader.NameTable.Add ("anyType");
+ InitIDs ();
+ }
+
+ private ArrayList EnsureArrayList (ArrayList list)
+ {
+ if (list == null)
+ list = new ArrayList ();
+ return list;
+ }
+
+ private Hashtable EnsureHashtable (Hashtable hash)
+ {
+ if (hash == null)
+ hash = new Hashtable ();
+ return hash;
+ }
+
+ protected XmlSerializationReader ()
+ {
+ }
+
+ protected XmlDocument Document
+ {
+ get {
+ if (document == null)
+ document = new XmlDocument (reader.NameTable);
+
+ return document;
+ }
+ }
+
+ protected XmlReader Reader {
+ get { return reader; }
+ }
+
+ #region Methods
+
+ protected void AddFixup (CollectionFixup fixup)
+ {
+ collFixups = EnsureArrayList (collFixups);
+ collFixups.Add(fixup);
+ }
+
+ protected void AddFixup (Fixup fixup)
+ {
+ fixups = EnsureArrayList (fixups);
+ fixups.Add(fixup);
+ }
+
+ protected void AddReadCallback (string name, string ns, Type type, XmlSerializationReadCallback read)
+ {
+ XmlNameTable nt = reader.NameTable;
+ XmlQualifiedName xqn = new XmlQualifiedName (nt.Add (name), nt.Add (ns));
+ readCallbacks = EnsureHashtable (readCallbacks);
+ readCallbacks.Add (xqn, read);
+ typesCallbacks = EnsureHashtable (typesCallbacks);
+ typesCallbacks.Add (xqn, type);
+ }
+
+ protected void AddTarget (string id, object o)
+ {
+ if (id != null) {
+ targets = EnsureHashtable (targets);
+ if (targets [id] == null)
+ targets.Add (id, o);
+ } else {
+ if (o != null)
+ return;
+ noIDTargets = EnsureArrayList (noIDTargets);
+ noIDTargets.Add (o);
+ }
+ }
+
+ private string CurrentTag ()
+ {
+ switch (reader.NodeType) {
+ case XmlNodeType.None:
+ return String.Format ("<{0} xmlns='{1}'>", reader.LocalName,
+ reader.NamespaceURI);
+ case XmlNodeType.Attribute:
+ return reader.Value;
+ case XmlNodeType.Text:
+ return "CDATA";
+ case XmlNodeType.ProcessingInstruction:
+ return "<--";
+ case XmlNodeType.Entity:
+ return "<?";
+ case XmlNodeType.EndElement:
+ return ">";
+ default:
+ return "(unknown)";
+ }
+ }
+
+ protected Exception CreateAbstractTypeException (string name, string ns)
+ {
+ string message = "Error at " + name + " " + ns + ":" + CurrentTag ();
+ return new InvalidOperationException (message);
+ }
+
+ protected Exception CreateInvalidCastException (Type type, object value)
+ {
+ string message = String.Format ("Cannot assign object of type {0} to an object of " +
+ "type {1}.", value.GetType (), type);
+ return new InvalidCastException (message);
+ }
+
+ protected Exception CreateReadOnlyCollectionException (string name)
+ {
+ string message = String.Format ("Could not serialize {0}. Default constructors are " +
+ "required for collections and enumerators.", name);
+ return new InvalidOperationException (message);
+ }
+
+ protected Exception CreateUnknownConstantException (string value, Type enumType)
+ {
+ string message = String.Format ("'{0}' is not a valid value for {1}.", value, enumType);
+ return new InvalidOperationException (message);
+ }
+
+ protected Exception CreateUnknownNodeException ()
+ {
+ string message = "Unknown xml node -> " + CurrentTag ();
+ return new InvalidOperationException (message);
+ }
+
+ protected Exception CreateUnknownTypeException (XmlQualifiedName type)
+ {
+ string message = "Unknown type " + type.Namespace + ":" + type.Name + " " + CurrentTag ();
+ return new InvalidOperationException (message);
+ }
+
+ protected Array EnsureArrayIndex (Array a, int index, Type elementType)
+ {
+ if (a != null && index < a.Length)
+ return a;
+
+ int size;
+ if (a == null) {
+ size = 32;
+ } else {
+ size = a.Length * 2;
+ }
+
+ Array result = Array.CreateInstance (elementType, size);
+ if (a != null)
+ Array.Copy (a, result, index);
+
+ return result;
+ }
+
+ [MonoTODO ("Implement")]
+ protected void FixupArrayRefs (object fixup)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("Implement")]
+ protected int GetArrayLength (string name, string ns)
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected bool GetNullAttr ()
+ {
+ string na = reader.GetAttribute (nullX, w3InstanceNS);
+ if (na == null) {
+ na = reader.GetAttribute (nil, w3InstanceNS);
+ if (na == null) {
+ na = reader.GetAttribute (nullX, w3InstanceNS2000);
+ if (na == null)
+ na = reader.GetAttribute (nullX, w3InstanceNS1999);
+ }
+ }
+ return (na != null);
+ }
+
+ [MonoTODO ("Implement")]
+ protected object GetTarget (string id)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("Implement")]
+ protected XmlQualifiedName GetXsiType ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected abstract void InitCallbacks ();
+ protected abstract void InitIDs ();
+
+ protected bool IsXmlnsAttribute (string name)
+ {
+ int length = name.Length;
+ if (length < 5)
+ return false;
+
+ if (length == 5)
+ return (name == "xmlns");
+
+ return name.StartsWith ("xmlns:");
+ }
+
+ [MonoTODO ("Implement")]
+ protected void ParseWsdlArrayType (XmlAttribute attr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected XmlQualifiedName ReadElementQualifiedName ()
+ {
+ if (reader.IsEmptyElement) {
+ reader.Skip();
+ return ToXmlQualifiedName (String.Empty);
+ }
+
+ XmlQualifiedName xqn = ToXmlQualifiedName(reader.ReadString ());
+ reader.ReadEndElement ();
+ return xqn;
+ }
+
+ protected void ReadEndElement ()
+ {
+ while (reader.NodeType == XmlNodeType.Whitespace)
+ reader.Skip ();
+
+ if (reader.NodeType != XmlNodeType.None) {
+ reader.ReadEndElement ();
+ } else {
+ reader.Skip ();
+ }
+ }
+
+ protected bool ReadNull ()
+ {
+ if (!GetNullAttr ())
+ return false;
+
+ if (reader.IsEmptyElement) {
+ reader.Skip();
+ return true;
+ }
+
+ reader.ReadStartElement();
+ while (reader.NodeType != XmlNodeType.EndElement)
+ UnknownNode (null);
+ ReadEndElement ();
+ return true;
+ }
+
+ protected XmlQualifiedName ReadNullableQualifiedName ()
+ {
+ if (ReadNull ())
+ return null;
+
+ return ReadElementQualifiedName ();
+ }
+
+ protected string ReadNullableString ()
+ {
+ if (ReadNull ())
+ return null;
+
+ return reader.ReadElementString ();
+ }
+
+ protected bool ReadReference (out string fixupReference)
+ {
+ string href = reader.GetAttribute ("href");
+ if (href == null) {
+ fixupReference = null;
+ return false;
+ }
+
+ if (href [0] != '#')
+ throw new InvalidOperationException("href not found: " + href);
+
+ fixupReference = href.Substring (1);
+ if (!reader.IsEmptyElement) {
+ reader.ReadStartElement ();
+ ReadEndElement ();
+ } else {
+ reader.Skip ();
+ }
+ return true;
+ }
+
+ protected object ReadReferencedElement ()
+ {
+ return ReadReferencedElement (null, null);
+ }
+
+ protected object ReadReferencedElement (string name, string ns)
+ {
+ string unused;
+ return ReadReferencingElement (name, ns, false, out unused);
+ }
+
+ protected void ReadReferencedElements ()
+ {
+ string unused;
+
+ reader.MoveToContent();
+ XmlNodeType nt = reader.NodeType;
+ while (nt != XmlNodeType.EndElement && nt != XmlNodeType.None) {
+ ReadReferencingElement (null, null, true, out unused);
+ reader.MoveToContent ();
+ nt = reader.NodeType;
+ }
+ }
+
+ [MonoTODO ("Implement")]
+ protected object ReadReferencingElement (out string fixupReference)
+ {
+ return ReadReferencingElement (null, null, false, out fixupReference);
+ }
+
+ protected object ReadReferencingElement (string name, string ns, out string fixupReference)
+ {
+ return ReadReferencingElement (name, ns, false, out fixupReference);
+ }
+
+ [MonoTODO]
+ protected object ReadReferencingElement (string name,
+ string ns,
+ bool elementCanBeType,
+ out string fixupReference)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("Implement")]
+ protected IXmlSerializable ReadSerializable (IXmlSerializable serializable)
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected string ReadString (string value)
+ {
+ if (value == null || value == String.Empty)
+ return reader.ReadString ();
+
+ return (value + reader.ReadString ());
+ }
+
+ [MonoTODO ("Implement")]
+ protected object ReadTypedPrimitive (XmlQualifiedName type)
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected XmlNode ReadXmlNode (bool wrapped)
+ {
+ return document.ReadNode (reader);
+ }
+
+ [MonoTODO ("Implement")]
+ protected void Referenced (object o)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("Implement")]
+ protected Array ShrinkArray (Array a, int length, Type elementType, bool isNullable)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("Implement")]
+ protected byte[] ToByteArrayBase64 (bool isNull)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("Implement")]
+ protected static byte[] ToByteArrayBase64 (string value)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("Implement")]
+ protected byte[] ToByteArrayHex (bool isNull)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("Implement")]
+ protected static byte[] ToByteArrayHex (string value)
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected static char ToChar (string value)
+ {
+ return XmlCustomFormatter.ToChar (value);
+ }
+
+ protected static DateTime ToDate (string value)
+ {
+ return XmlCustomFormatter.ToDate (value);
+ }
+
+ protected static DateTime ToDateTime (string value)
+ {
+ return XmlCustomFormatter.ToDateTime (value);
+ }
+
+ [MonoTODO ("Implement")]
+ protected static long ToEnum (string value, Hashtable h, string typeName)
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected static DateTime ToTime (string value)
+ {
+ return XmlCustomFormatter.ToTime (value);
+ }
+
+ protected static string ToXmlName (string value)
+ {
+ return XmlCustomFormatter.ToXmlName (value);
+ }
+
+ protected static string ToXmlNCName (string value)
+ {
+ return XmlCustomFormatter.ToXmlNCName (value);
+ }
+
+ protected static string ToXmlNmToken (string value)
+ {
+ return XmlCustomFormatter.ToXmlNmToken (value);
+ }
+
+ protected static string ToXmlNmTokens (string value)
+ {
+ return XmlCustomFormatter.ToXmlNmTokens (value);
+ }
+
+ protected XmlQualifiedName ToXmlQualifiedName (string value)
+ {
+ string name;
+ string ns;
+ int lastColon = value.LastIndexOf (':');
+ string decodedValue = XmlConvert.DecodeName (value);
+ if (lastColon < 0) {
+ name = reader.NameTable.Add (decodedValue);
+ ns = reader.LookupNamespace (String.Empty);
+ } else {
+ string prefix = value.Substring (0, lastColon);
+ ns = reader.LookupNamespace (prefix);
+ if (ns == null)
+ throw new InvalidOperationException ("namespace " + prefix + "not defined");
+
+ name = reader.NameTable.Add (value.Substring (lastColon + 1));
+ }
+
+ return new XmlQualifiedName (name, ns);
+ }
+
+ [MonoTODO ("Implement")]
+ protected void UnknownAttribute (object o, XmlAttribute attr)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("Implement")]
+ protected void UnknownElement (object o, XmlElement elem)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("Implement")]
+ protected void UnknownNode (object o)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("Implement")]
+ protected void UnreferencedObject (string id, object o)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+
+ protected class CollectionFixup {
+
+ #region Fields
+
+ XmlSerializationCollectionFixupCallback callback;
+ object collection;
+ object collectionItems;
+
+ #endregion // Fields
+
+ #region Constructors
+
+ [MonoTODO]
+ public CollectionFixup (object collection, XmlSerializationCollectionFixupCallback callback, object collectionItems)
+ {
+ this.callback = callback;
+ this.collection = collection;
+ this.collectionItems = collectionItems;
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public XmlSerializationCollectionFixupCallback Callback {
+ get { return callback; }
+ }
+
+ public object Collection {
+ get { return collection; }
+ }
+
+ public object CollectionItems {
+ get { return collectionItems; }
+ }
+
+ #endregion // Properties
+ }
+
+ protected class Fixup {
+
+ #region Fields
+
+ object source;
+ string[] ids;
+ XmlSerializationFixupCallback callback;
+
+ #endregion // Fields
+
+ #region Constructors
+
+ [MonoTODO]
+ public Fixup (object o, XmlSerializationFixupCallback callback, int count)
+ {
+ this.callback = callback;
+ }
+
+ [MonoTODO]
+ public Fixup (object o, XmlSerializationFixupCallback callback, string[] ids)
+ {
+ this.callback = callback;
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public XmlSerializationFixupCallback Callback {
+ get { return callback; }
+ }
+
+ public string[] Ids {
+ get { return ids; }
+ }
+
+ public object Source {
+ get { return source; }
+ set { source = value; }
+ }
+
+ #endregion // Properties
+ }
+ }
+}
+
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriteCallback.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriteCallback.cs
new file mode 100644
index 00000000000..8da2224c979
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriteCallback.cs
@@ -0,0 +1,17 @@
+//
+// System.Xml.Serialization.XmlSerializationWriteCallback.cs:
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System;
+
+namespace System.Xml.Serialization {
+
+ [Serializable]
+ public delegate void XmlSerializationWriteCallback (object o);
+}
+
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriter.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriter.cs
new file mode 100644
index 00000000000..6dc637b70ed
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriter.cs
@@ -0,0 +1,571 @@
+//
+// System.Xml.Serialization.XmlSerializationWriter.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System;
+using System.Collections;
+using System.Text;
+using System.Xml;
+using System.Xml.Schema;
+
+namespace System.Xml.Serialization {
+ public abstract class XmlSerializationWriter {
+
+ #region Fields
+
+ Hashtable references;
+ int referenceCount;
+ int qnameCount;
+
+ ArrayList namespaces;
+ XmlWriter writer;
+
+ #endregion // Fields
+
+ #region Constructors
+
+ [MonoTODO]
+ protected XmlSerializationWriter ()
+ {
+ qnameCount = 0;
+ references = new Hashtable ();
+ referenceCount = 0;
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ protected ArrayList Namespaces {
+ get { return namespaces; }
+ set { namespaces = value; }
+ }
+
+ protected XmlWriter Writer {
+ get { return writer; }
+ set { writer = value; }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO ("Implement")]
+ protected void AddWriteCallback (Type type, string typeName, string typeNs, XmlSerializationWriteCallback callback)
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected Exception CreateMismatchChoiceException (string value, string elementName, string enumValue)
+ {
+ string message = String.Format ("Value of {0} mismatches the type of {1}, you need to set it to {2}.", elementName, value, enumValue);
+ return new InvalidOperationException (message);
+ }
+
+ protected Exception CreateUnknownAnyElementException (string name, string ns)
+ {
+ string message = String.Format ("The XML element named '{0}' from namespace '{1}' was not expected. The XML element name and namespace must match those provided via XmlAnyElementAttribute(s).", name, ns);
+ return new InvalidOperationException (message);
+ }
+
+ protected Exception CreateUnknownTypeException (object o)
+ {
+ return CreateUnknownTypeException (o.GetType ());
+ }
+
+ protected Exception CreateUnknownTypeException (Type type)
+ {
+ string message = String.Format ("The type {0} may not be used in this context.", type);
+ return new InvalidOperationException (message);
+ }
+
+ protected static byte[] FromByteArrayBase64 (byte[] value)
+ {
+ return XmlCustomFormatter.FromByteArrayBase64 (value);
+ }
+
+ protected static string FromByteArrayHex (byte[] value)
+ {
+ return XmlCustomFormatter.FromByteArrayHex (value);
+ }
+
+ protected static string FromChar (char value)
+ {
+ return XmlCustomFormatter.FromChar (value);
+ }
+
+ protected static string FromDate (DateTime value)
+ {
+ return XmlCustomFormatter.FromDate (value);
+ }
+
+ protected static string FromDateTime (DateTime value)
+ {
+ return XmlCustomFormatter.FromDateTime (value);
+ }
+
+ protected static string FromEnum (long value, string[] values, long[] ids)
+ {
+ return XmlCustomFormatter.FromEnum (value, values, ids);
+ }
+
+ protected static string FromTime (DateTime value)
+ {
+ return XmlCustomFormatter.FromTime (value);
+ }
+
+ protected static string FromXmlName (string name)
+ {
+ return XmlCustomFormatter.FromXmlName (name);
+ }
+
+ protected static string FromXmlNCName (string ncName)
+ {
+ return XmlCustomFormatter.FromXmlNCName (ncName);
+ }
+
+ protected static string FromXmlNmToken (string nmToken)
+ {
+ return XmlCustomFormatter.FromXmlNmToken (nmToken);
+ }
+
+ protected static string FromXmlNmTokens (string nmTokens)
+ {
+ return XmlCustomFormatter.FromXmlNmTokens (nmTokens);
+ }
+
+ [MonoTODO ("Implement")]
+ protected string FromXmlQualifiedName (XmlQualifiedName xmlQualifiedName)
+ {
+ return GetQualifiedName (xmlQualifiedName.Name, xmlQualifiedName.Namespace);
+ }
+
+ private string GetId (object o, bool addToReferencesList)
+ {
+ referenceCount += 1;
+ string id = String.Format ("id{0}", referenceCount);
+ if (addToReferencesList)
+ references[o] = id;
+ return id;
+ }
+
+ [MonoTODO ("Complete this list.")]
+ private string GetPrimitiveTypeName (Type type)
+ {
+ if (type == typeof (string))
+ return "string";
+ if (type == typeof (bool))
+ return "Boolean";
+ if (type == typeof (float))
+ return "float";
+ if (type == typeof (double))
+ return "double";
+ if (type == typeof (XmlQualifiedName))
+ return "QName";
+
+ return String.Empty;
+ }
+
+ [MonoTODO ("Need to check for namespace conflicts before blindly allocating qN")]
+ private string GetQualifiedName (string name, string ns)
+ {
+ qnameCount += 1;
+ string prefix = String.Format ("q{0}", qnameCount);
+
+ WriteAttribute ("xmlns", prefix, null, ns);
+ return String.Format ("{0}:{1}", prefix, name);
+ }
+
+ protected abstract void InitCallbacks ();
+
+ [MonoTODO ("Implement")]
+ protected void TopLevelElement ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected void WriteAttribute (string localName, byte[] value)
+ {
+ WriteAttribute (localName, String.Empty, value);
+ }
+
+ protected void WriteAttribute (string localName, string value)
+ {
+ WriteAttribute (String.Empty, localName, String.Empty, value);
+ }
+
+ protected void WriteAttribute (string localName, string ns, byte[] value)
+ {
+ Writer.WriteStartAttribute (localName, ns);
+ WriteValue (value);
+ Writer.WriteEndAttribute ();
+ }
+
+ protected void WriteAttribute (string localName, string ns, string value)
+ {
+ WriteAttribute (String.Empty, localName, ns, value);
+ }
+
+ protected void WriteAttribute (string prefix, string localName, string ns, string value)
+ {
+ Writer.WriteStartAttribute (prefix, localName, ns);
+ WriteValue (value);
+ Writer.WriteEndAttribute ();
+ }
+
+ [MonoTODO ("Implement")]
+ protected void WriteElementEncoded (XmlNode node, string name, string ns, bool isNullable, bool any)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("Implement")]
+ protected void WriteElementLiteral (XmlNode node, string name, string ns, bool isNullable, bool any)
+ {
+ WriteStartElement (name, ns);
+ node.WriteTo (Writer);
+ WriteEndElement ();
+ }
+
+ protected void WriteElementQualifiedName (string localName, XmlQualifiedName value)
+ {
+ WriteElementQualifiedName (localName, String.Empty, value, null);
+ }
+
+ protected void WriteElementQualifiedName (string localName, string ns, XmlQualifiedName value)
+ {
+ WriteElementQualifiedName (localName, ns, value, null);
+ }
+
+ protected void WriteElementQualifiedName (string localName, XmlQualifiedName value, XmlQualifiedName xsiType)
+ {
+ WriteElementQualifiedName (localName, String.Empty, value, xsiType);
+ }
+
+ protected void WriteElementQualifiedName (string localName, string ns, XmlQualifiedName value, XmlQualifiedName xsiType)
+ {
+ WriteStartElement (localName, ns);
+ Writer.WriteString (FromXmlQualifiedName (value));
+ WriteEndElement ();
+ }
+
+ protected void WriteElementString (string localName, string value)
+ {
+ WriteElementString (localName, String.Empty, value, null);
+ }
+
+ protected void WriteElementString (string localName, string ns, string value)
+ {
+ WriteElementString (localName, ns, value, null);
+ }
+
+ protected void WriteElementString (string localName, string value, XmlQualifiedName xsiType)
+ {
+ WriteElementString (localName, String.Empty, value, xsiType);
+ }
+
+ [MonoTODO ("Implement")]
+ protected void WriteElementString (string localName, string ns, string value, XmlQualifiedName xsiType)
+ {
+ if (xsiType != null) {
+ WriteStartElement (localName, ns);
+ WriteXsiType (xsiType.Name, xsiType.Namespace);
+ Writer.WriteString (value);
+ WriteEndElement ();
+ }
+ else
+ Writer.WriteElementString (localName, ns, value);
+ }
+
+ protected void WriteElementStringRaw (string localName, byte[] value)
+ {
+ WriteElementStringRaw (localName, String.Empty, value, null);
+ }
+
+ protected void WriteElementStringRaw (string localName, string value)
+ {
+ WriteElementStringRaw (localName, String.Empty, value, null);
+ }
+
+ protected void WriteElementStringRaw (string localName, byte[] value, XmlQualifiedName xsiType)
+ {
+ WriteElementStringRaw (localName, String.Empty, value, xsiType);
+ }
+
+ protected void WriteElementStringRaw (string localName, string ns, byte[] value)
+ {
+ WriteElementStringRaw (localName, ns, value, null);
+ }
+
+ protected void WriteElementStringRaw (string localName, string ns, string value)
+ {
+ WriteElementStringRaw (localName, ns, value, null);
+ }
+
+ protected void WriteElementStringRaw (string localName, string value, XmlQualifiedName xsiType)
+ {
+ WriteElementStringRaw (localName, String.Empty, value, null);
+ }
+
+ [MonoTODO ("Implement")]
+ protected void WriteElementStringRaw (string localName, string ns, byte[] value, XmlQualifiedName xsiType)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("Implement")]
+ protected void WriteElementStringRaw (string localName, string ns, string value, XmlQualifiedName xsiType)
+ {
+ WriteStartElement (localName, ns);
+
+ if (xsiType != null)
+ WriteXsiType (xsiType.Name, xsiType.Namespace);
+
+ Writer.WriteRaw (value);
+ WriteEndElement ();
+ }
+
+ protected void WriteEmptyTag (string name)
+ {
+ WriteEmptyTag (name, String.Empty);
+ }
+
+ [MonoTODO ("Verify")]
+ protected void WriteEmptyTag (string name, string ns)
+ {
+ Writer.WriteStartElement (name, ns);
+ Writer.WriteEndElement ();
+ }
+
+ protected void WriteEndElement ()
+ {
+ WriteEndElement (null);
+ }
+
+ [MonoTODO ("Implement")]
+ protected void WriteEndElement (object o)
+ {
+ Writer.WriteEndElement ();
+ }
+
+ protected void WriteId (object o)
+ {
+ WriteAttribute ("id", GetId (o, true));
+ }
+
+ protected void WriteNamespaceDeclarations (XmlSerializerNamespaces ns)
+ {
+ if (ns == null)
+ return;
+
+ Hashtable tbl = ns.Namespaces;
+ foreach (string key in tbl.Keys) {
+ string val = tbl [key] as string;
+ if (val == null)
+ val = String.Empty;
+ WriteAttribute ("xmlns", key, null, val);
+ }
+ }
+
+ [MonoTODO ("Implement")]
+ protected void WriteNullableQualifiedNameEncoded (string name, string ns, XmlQualifiedName value, XmlQualifiedName xsiType)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("Implement")]
+ protected void WriteNullableQualifiedNameLiteral (string name, string ns, XmlQualifiedName value)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("Implement")]
+ protected void WriteNullableStringEncoded (string name, string ns, string value, XmlQualifiedName xsiType)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("Implement")]
+ protected void WriteNullableStringEncodedRaw (string name, string ns, byte[] value, XmlQualifiedName xsiType)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("Implement")]
+ protected void WriteNullableStringEncodedRaw (string name, string ns, string value, XmlQualifiedName xsiType)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("Implement")]
+ protected void WriteNullableStringLiteral (string name, string ns, string value)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("Implement")]
+ protected void WriteNullableStringLiteralRaw (string name, string ns, byte[] value)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("Implement")]
+ protected void WriteNullableStringLiteralRaw (string name, string ns, string value)
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected void WriteNullTagEncoded (string name)
+ {
+ WriteNullTagEncoded (name, String.Empty);
+ }
+
+ [MonoTODO ("Implement")]
+ protected void WriteNullTagEncoded (string name, string ns)
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected void WriteNullTagLiteral (string name)
+ {
+ WriteNullTagLiteral (name, String.Empty);
+ }
+
+ [MonoTODO ("Implement")]
+ protected void WriteNullTagLiteral (string name, string ns)
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected void WritePotentiallyReferencingElement (string n, string ns, object o)
+ {
+ WritePotentiallyReferencingElement (n, ns, o, null, false, false);
+ }
+
+ protected void WritePotentiallyReferencingElement (string n, string ns, object o, Type ambientType)
+ {
+ WritePotentiallyReferencingElement (n, ns, o, ambientType, false, false);
+ }
+
+ protected void WritePotentiallyReferencingElement (string n, string ns, object o, Type ambientType, bool suppressReference)
+ {
+ WritePotentiallyReferencingElement (n, ns, o, ambientType, suppressReference, false);
+ }
+
+ [MonoTODO ("Implement")]
+ protected void WritePotentiallyReferencingElement (string n, string ns, object o, Type ambientType, bool suppressReference, bool isNullable)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("Implement")]
+ protected void WriteReferencedElements ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected void WriteReferencingElement (string n, string ns, object o)
+ {
+ WriteReferencingElement (n, ns, o, false);
+ }
+
+ [MonoTODO ("Implement")]
+ protected void WriteReferencingElement (string n, string ns, object o, bool isNullable)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO ("Implement")]
+ protected void WriteSerializable (IXmlSerializable serializable, string name, string ns, bool isNullable)
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected void WriteStartDocument ()
+ {
+ Writer.WriteStartDocument ();
+ }
+
+ protected void WriteStartElement (string name)
+ {
+ WriteStartElement (name, String.Empty, null, false);
+ }
+
+ protected void WriteStartElement (string name, string ns)
+ {
+ WriteStartElement (name, ns, null, false);
+ }
+
+ protected void WriteStartElement (string name, string ns, bool writePrefixed)
+ {
+ WriteStartElement (name, ns, null, writePrefixed);
+ }
+
+ protected void WriteStartElement (string name, string ns, object o)
+ {
+ WriteStartElement (name, ns, o, false);
+ }
+
+ [MonoTODO]
+ protected void WriteStartElement (string name, string ns, object o, bool writePrefixed)
+ {
+ if (writePrefixed)
+ Writer.WriteStartElement (String.Empty, name, ns);
+ else
+ Writer.WriteStartElement (name, ns);
+ }
+
+ protected void WriteTypedPrimitive (string name, string ns, object o, bool xsiType)
+ {
+ string value;
+
+ WriteStartElement (name, ns);
+
+ if (o is XmlQualifiedName)
+ value = FromXmlQualifiedName ((XmlQualifiedName) o);
+ else
+ value = o.ToString ();
+
+ if (xsiType)
+ WriteXsiType (GetPrimitiveTypeName (o.GetType ()), XmlSchema.Namespace);
+
+ WriteValue (value);
+ WriteEndElement ();
+ }
+
+ protected void WriteValue (byte[] value)
+ {
+ Writer.WriteBase64 (value, 0, value.Length);
+ }
+
+ protected void WriteValue (string value)
+ {
+ Writer.WriteString (value);
+ }
+
+ protected void WriteXmlAttribute (XmlNode node)
+ {
+ WriteXmlAttribute (node, null);
+ }
+
+ [MonoTODO ("Implement")]
+ protected void WriteXmlAttribute (XmlNode node, object container)
+ {
+ if (!(node is XmlAttribute))
+ throw new InvalidOperationException ("The node must be either type XmlAttribute or a derived type.");
+ throw new NotImplementedException ();
+ }
+
+ protected void WriteXsiType (string name, string ns)
+ {
+ WriteAttribute ("type", XmlSchema.InstanceNamespace, GetQualifiedName (name, ns));
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs
new file mode 100644
index 00000000000..3a5ba0fd1e6
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs
@@ -0,0 +1,1012 @@
+//
+// Mono Class Libraries
+// System.Xml.Serialization.XmlSerializer
+//
+// Authors:
+// John Donagher (john@webmeta.com)
+// Ajay kumar Dwivedi (adwiv@yahoo.com)
+// Tim Coleman (tim@timcoleman.com)
+//
+// (C) 2002 John Donagher, Ajay kumar Dwivedi
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Reflection;
+using System.Xml;
+using System.Xml.Schema;
+
+namespace System.Xml.Serialization {
+ /// <summary>
+ /// Summary description for XmlSerializer.
+ /// </summary>
+ public class XmlSerializer {
+
+ #region Fields
+
+ Type xsertype;
+ XmlAttributeOverrides overrides;
+ Type[] extraTypes;
+ XmlRootAttribute rootAttribute;
+ string defaultNamespace;
+ Hashtable typeTable;
+ bool useOrder;
+ bool isNullable;
+ Hashtable typeMappings = new Hashtable ();
+
+ #endregion // Fields
+
+ #region Constructors
+
+ protected XmlSerializer ()
+ {
+ }
+
+ public XmlSerializer (Type type)
+ : this (type, null, null, null, null)
+ {
+ }
+
+ public XmlSerializer (XmlTypeMapping xmlTypeMapping)
+ {
+ typeMappings.Add (xmlTypeMapping.TypeFullName, xmlTypeMapping);
+ }
+
+ public XmlSerializer (Type type, string defaultNamespace)
+ : this (type, null, null, null, defaultNamespace)
+ {
+ }
+
+ public XmlSerializer (Type type, Type[] extraTypes)
+ : this (type, null, extraTypes, null, null)
+ {
+ }
+
+ public XmlSerializer (Type type, XmlAttributeOverrides overrides)
+ : this (type, overrides, null, null, null)
+ {
+ }
+
+ public XmlSerializer (Type type, XmlRootAttribute root)
+ : this (type, null, null, root, null)
+ {
+ }
+
+ internal XmlSerializer (Hashtable typeTable)
+ {
+ this.typeTable = typeTable;
+ }
+
+ public XmlSerializer (Type type,
+ XmlAttributeOverrides overrides,
+ Type [] extraTypes,
+ XmlRootAttribute root,
+ string defaultNamespace)
+ {
+ if (type == null)
+ throw new ArgumentNullException ("type");
+
+ XmlReflectionImporter ri = new XmlReflectionImporter (overrides, defaultNamespace);
+ TypeData td = TypeTranslator.GetTypeData (type);
+ typeMappings.Add (td.FullTypeName, ri.ImportTypeMapping (type, root, defaultNamespace));
+ ri.IncludeTypes (type);
+
+ if (extraTypes != null) {
+ foreach (Type t in extraTypes) {
+ td = TypeTranslator.GetTypeData (t);
+ string n = td.FullTypeName;
+ typeMappings.Add (n, ri.ImportTypeMapping (type, root, defaultNamespace));
+ ri.IncludeTypes (t);
+ }
+ }
+
+ this.xsertype = type;
+ this.overrides = overrides;
+ this.extraTypes = (extraTypes == null ? new Type[0] : extraTypes);
+
+ if (root != null)
+ this.rootAttribute = root;
+ else {
+ object[] attributes = type.GetCustomAttributes (typeof (XmlRootAttribute), false);
+ if (attributes.Length > 0)
+ this.rootAttribute = (XmlRootAttribute) attributes[0];
+ }
+
+ this.defaultNamespace = defaultNamespace;
+
+ if (typeTable == null)
+ typeTable = new Hashtable ();
+
+ FillTypeTable (type);
+ }
+
+ #endregion // Constructors
+
+ #region Events
+
+ public event XmlAttributeEventHandler UnknownAttribute;
+ public event XmlElementEventHandler UnknownElement;
+ public event XmlNodeEventHandler UnknownNode;
+ public event UnreferencedObjectEventHandler UnreferencedObject;
+
+ #endregion // Events
+
+ #region Properties
+
+ internal bool UseOrder {
+ get { return useOrder; }
+ set { useOrder = value; }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public virtual bool CanDeserialize (XmlReader xmlReader)
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected virtual XmlSerializationReader CreateReader ()
+ {
+ // This is what MS does!!!
+ throw new NotImplementedException ();
+ }
+
+ protected virtual XmlSerializationWriter CreateWriter ()
+ {
+ // This is what MS does!!!
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public object Deserialize (Stream stream)
+ {
+ throw new NotImplementedException ();
+ }
+ [MonoTODO]
+ public object Deserialize (TextReader textReader)
+ {
+ throw new NotImplementedException ();
+ }
+ [MonoTODO]
+ public object Deserialize (XmlReader xmlReader)
+ {
+ throw new NotImplementedException ();
+ }
+
+ protected virtual object Deserialize (XmlSerializationReader reader)
+ {
+ // This is what MS does!!!
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static XmlSerializer [] FromMappings (XmlMapping [] mappings)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static XmlSerializer [] FromTypes (Type [] mappings)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected virtual void Serialize (object o, XmlSerializationWriter writer)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public void Serialize (Stream stream, object o)
+ {
+ XmlTextWriter xmlWriter = new XmlTextWriter (stream, System.Text.Encoding.Default);
+ xmlWriter.Formatting = Formatting.Indented;
+ Serialize (xmlWriter, o, null);
+ }
+
+ public void Serialize (TextWriter textWriter, object o)
+ {
+ XmlTextWriter xmlWriter = new XmlTextWriter (textWriter);
+ xmlWriter.Formatting = Formatting.Indented;
+ Serialize (xmlWriter, o, null);
+ }
+
+ public void Serialize (XmlWriter xmlWriter, object o)
+ {
+ Serialize (xmlWriter, o, null);
+ }
+
+ public void Serialize (Stream stream, object o, XmlSerializerNamespaces namespaces)
+ {
+ XmlTextWriter xmlWriter = new XmlTextWriter (stream, System.Text.Encoding.Default);
+ xmlWriter.Formatting = Formatting.Indented;
+ Serialize (xmlWriter, o, namespaces);
+ }
+
+ public void Serialize (TextWriter textWriter, object o, XmlSerializerNamespaces namespaces)
+ {
+ XmlTextWriter xmlWriter = new XmlTextWriter (textWriter);
+ xmlWriter.Formatting = Formatting.Indented;
+ Serialize (xmlWriter, o, namespaces);
+ }
+
+ public void Serialize (XmlWriter writer, object o, XmlSerializerNamespaces namespaces)
+ {
+ Type objType = xsertype;//o.GetType ();
+
+ if (IsInbuiltType(objType))
+ {
+ writer.WriteStartDocument ();
+ SerializeBuiltIn (writer, o);
+ writer.WriteEndDocument();
+ return;
+ }
+
+ string rootName = objType.Name;
+ string rootNs = String.Empty;
+ string rootPrefix = String.Empty;
+
+ if (namespaces == null)
+ namespaces = new XmlSerializerNamespaces ();
+
+ if (namespaces.Count == 0) {
+ namespaces.Add ("xsd", XmlSchema.Namespace);
+ namespaces.Add ("xsi", XmlSchema.InstanceNamespace);
+ }
+
+ XmlSerializerNamespaces nss = new XmlSerializerNamespaces ();
+ XmlQualifiedName[] qnames;
+
+ writer.WriteStartDocument ();
+ object [] memberObj = (object []) typeTable [objType];
+ if (memberObj == null)
+ throw new Exception ("Unknown Type " + objType +
+ " encountered during Serialization");
+
+ Hashtable memberTable = (Hashtable) memberObj [0];
+ XmlAttributes xmlAttributes = (XmlAttributes) memberTable [""];
+
+ //If we have been passed an XmlRoot, set it on the base class
+ if (rootAttribute != null)
+ xmlAttributes.XmlRoot = rootAttribute;
+
+ if (xmlAttributes.XmlRoot != null) {
+ isNullable = xmlAttributes.XmlRoot.IsNullable;
+ if (xmlAttributes.XmlRoot.ElementName != null)
+ rootName = xmlAttributes.XmlRoot.ElementName;
+ rootNs = xmlAttributes.XmlRoot.Namespace;
+ }
+
+ if (namespaces != null && namespaces.GetPrefix (rootNs) != null)
+ rootPrefix = namespaces.GetPrefix (rootNs);
+
+ //XMLNS attributes in the Root
+ XmlAttributes XnsAttrs = (XmlAttributes) ((object[]) typeTable[objType])[1];
+
+ if (XnsAttrs != null) {
+ MemberInfo member = XnsAttrs.MemberInfo;
+ FieldInfo fieldInfo = member as FieldInfo;
+ PropertyInfo propertyInfo = member as PropertyInfo;
+ XmlSerializerNamespaces xns;
+
+ if (fieldInfo != null)
+ xns = (XmlSerializerNamespaces) fieldInfo.GetValue (o);
+ else
+ xns = (XmlSerializerNamespaces) propertyInfo.GetValue (o, null);
+
+ qnames = xns.ToArray ();
+
+ foreach (XmlQualifiedName qname in qnames)
+ nss.Add (qname.Name, qname.Namespace);
+ }
+
+ //XmlNs from the namespaces passed
+ qnames = namespaces.ToArray ();
+ foreach (XmlQualifiedName qname in qnames)
+ if (writer.LookupPrefix (qname.Namespace) != qname.Name)
+ nss.Add (qname.Name, qname.Namespace);
+
+ writer.WriteStartElement (rootPrefix, rootName, rootNs);
+
+ qnames = nss.ToArray();
+ foreach (XmlQualifiedName qname in qnames)
+ if (writer.LookupPrefix (qname.Namespace) != qname.Name)
+ writer.WriteAttributeString ("xmlns", qname.Name, null, qname.Namespace);
+
+ if (rootPrefix == String.Empty && rootNs != String.Empty && rootNs != null)
+ writer.WriteAttributeString (String.Empty, "xmlns", null, rootNs);
+
+ SerializeMembers (writer, o, true);//, namespaces);
+
+ writer.WriteEndDocument ();
+ }
+
+ private void SerializeBuiltIn (XmlWriter writer, object o)
+ {
+ TypeData td = TypeTranslator.GetTypeData (o.GetType ());
+ writer.WriteStartElement (td.ElementName);
+ WriteBuiltinValue(writer,o);
+ writer.WriteEndElement();
+ }
+
+ private void WriteNilAttribute(XmlWriter writer)
+ {
+ writer.WriteAttributeString("nil",XmlSchema.InstanceNamespace, "true");
+ }
+
+ private void WriteBuiltinValue(XmlWriter writer, object o)
+ {
+ if(o == null)
+ WriteNilAttribute(writer);
+ else
+ writer.WriteString (GetXmlValue(o));
+ }
+
+ private void SerializeMembers (XmlWriter writer, object o, bool isRoot)
+ {
+ if(o == null)
+ {
+ WriteNilAttribute(writer);
+ return;
+ }
+
+ Type objType = o.GetType ();
+
+ if (IsInbuiltType(objType))
+ {
+ SerializeBuiltIn (writer, o);
+ return;
+ }
+
+ XmlAttributes nsAttributes = (XmlAttributes) ((object[]) typeTable [objType])[1];
+ ArrayList attributes = (ArrayList) ((object[]) typeTable [objType])[2];
+ ArrayList elements = (ArrayList) ((object[]) typeTable [objType])[3];
+
+ if (!isRoot && nsAttributes != null) {
+ MemberInfo member = nsAttributes.MemberInfo;
+ FieldInfo fieldInfo = member as FieldInfo;
+ PropertyInfo propertyInfo = member as PropertyInfo;
+
+ XmlSerializerNamespaces xns;
+
+ if (fieldInfo != null)
+ xns = (XmlSerializerNamespaces) fieldInfo.GetValue (o);
+ else
+ xns = (XmlSerializerNamespaces) propertyInfo.GetValue (o, null);
+
+ XmlQualifiedName[] qnames = xns.ToArray ();
+ foreach (XmlQualifiedName qname in qnames)
+ if (writer.LookupPrefix (qname.Namespace) != qname.Name)
+ writer.WriteAttributeString ("xmlns", qname.Name, null, qname.Namespace);
+ }
+
+ //Serialize the Attributes.
+ foreach (XmlAttributes xmlAttributes in attributes) {
+ MemberInfo member = xmlAttributes.MemberInfo;
+ FieldInfo fieldInfo = member as FieldInfo;
+ PropertyInfo propertyInfo = member as PropertyInfo;
+
+ Type attributeType;
+ object attributeValue;
+ string attributeValueString;
+ string attributeName;
+ string attributeNs;
+
+ if (fieldInfo != null) {
+ attributeType = fieldInfo.FieldType;
+ attributeValue = fieldInfo.GetValue (o);
+ }
+ else {
+ attributeType = propertyInfo.PropertyType;
+ attributeValue = propertyInfo.GetValue (o, null);
+ }
+
+ attributeName = xmlAttributes.GetAttributeName (attributeType, member.Name);
+ attributeNs = xmlAttributes.GetAttributeNamespace (attributeType);
+
+ if (attributeValue is XmlQualifiedName) {
+ XmlQualifiedName qname = (XmlQualifiedName) attributeValue;
+
+ if (qname.IsEmpty)
+ continue;
+
+ writer.WriteStartAttribute (attributeName, attributeNs);
+ writer.WriteQualifiedName (qname.Name, qname.Namespace);
+ writer.WriteEndAttribute ();
+ continue;
+ }
+ else if (attributeValue is XmlQualifiedName[]) {
+ XmlQualifiedName[] qnames = (XmlQualifiedName[]) attributeValue;
+ writer.WriteStartAttribute (attributeName, attributeNs);
+ int count = 0;
+ foreach (XmlQualifiedName qname in qnames) {
+ if (qname.IsEmpty)
+ continue;
+ if (count++ > 0)
+ writer.WriteWhitespace (" ");
+ writer.WriteQualifiedName (qname.Name, qname.Namespace);
+ }
+ writer.WriteEndAttribute ();
+ continue;
+ }
+ else if (attributeValue is XmlAttribute[]) {
+ XmlAttribute[] xmlattrs = (XmlAttribute[]) attributeValue;
+ foreach (XmlAttribute xmlattr in xmlattrs)
+ xmlattr.WriteTo(writer);
+ continue;
+ }
+
+ attributeValueString = GetXmlValue (attributeValue);
+ if (attributeValueString != GetXmlValue (xmlAttributes.XmlDefaultValue))
+ writer.WriteAttributeString (attributeName, attributeNs, attributeValueString);
+ }
+
+ // Serialize Elements
+ foreach (XmlAttributes xmlElements in elements) {
+ MemberInfo member = xmlElements.MemberInfo;
+ FieldInfo fieldInfo = member as FieldInfo;
+ PropertyInfo propertyInfo = member as PropertyInfo;
+
+ Type elementType;
+ object elementValue;
+ string elementName;
+ string elementNs;
+
+ if (fieldInfo != null) {
+ elementType = fieldInfo.FieldType;
+ elementValue = fieldInfo.GetValue (o);
+ }
+ else {
+ elementType = propertyInfo.PropertyType;
+ elementValue = propertyInfo.GetValue (o, null);
+ }
+
+ elementName = xmlElements.GetElementName (elementType, member.Name);
+ elementNs = xmlElements.GetElementNamespace (elementType);
+ WriteElement (writer, xmlElements, elementName, elementNs, elementType, elementValue);
+ }
+ }
+
+ [MonoTODO ("Remove FIXMEs")]
+ private void WriteElement (XmlWriter writer, XmlAttributes attrs, string name, string ns, Type type, Object value)
+ {
+ //IF the element has XmlText Attribute, the name of the member is not serialized;
+ if (attrs.XmlText != null && value != null)
+ {
+ if (type == typeof (object[]))
+ {
+ foreach(object obj in (object[]) value)
+ writer.WriteRaw(""+obj);
+ }
+ else if (type == typeof (string[]))
+ {
+ foreach(string str in (string[]) value)
+ writer.WriteRaw(str);
+ }
+ else if (type == typeof (XmlNode))
+ {
+ ((XmlNode) value).WriteTo (writer);
+ }
+ else if (type == typeof (XmlNode[]))
+ {
+ XmlNode[] nodes = (XmlNode[]) value;
+ foreach (XmlNode node in nodes)
+ node.WriteTo (writer);
+ }
+ return;
+ }
+
+ //If not text, serialize as an element
+
+ //Start the element tag
+ writer.WriteStartElement (name, ns);
+
+ if (IsInbuiltType (type))
+ {
+ WriteBuiltinValue(writer,value);
+ }
+ else if (type.IsArray && value != null)
+ {
+ SerializeArray (writer, value);
+ }
+ else if (value is ICollection)
+ {
+ BindingFlags flags = BindingFlags.Public | BindingFlags.Instance;
+
+ //Find a non indexer Count Property with return type of int
+ PropertyInfo countInfo = type.GetProperty ("Count", flags, null, typeof (int), new Type[0], null);
+ PropertyInfo itemInfo = type.GetProperty ("Item", flags, null, null, new Type[1] {typeof (int)}, null);
+ int count = (int) countInfo.GetValue (value, null);
+
+ if (count > 0)
+ for (int i = 0; i < count; i++)
+ {
+ object itemValue = itemInfo.GetValue (value, new object[1] {i});
+ Type itemType = itemInfo.PropertyType;
+
+ if (itemValue != null)
+ {
+ string itemName = attrs.GetElementName (itemValue.GetType (), TypeTranslator.GetTypeData(itemType).ElementName);
+ string itemNs = attrs.GetElementNamespace (itemValue.GetType ());
+
+ writer.WriteStartElement (itemName, itemNs);
+ SerializeMembers (writer, itemValue, false);
+ writer.WriteEndElement ();
+ }
+ }
+ }
+ else if (value is IEnumerable)
+ {
+ // FIXME
+ }
+ else if (type.IsEnum)
+ {
+ // FIXME
+ }
+ else
+ { //Complex Type
+ SerializeMembers (writer, value, false);
+ }
+
+ // Close the Element
+ writer.WriteEndElement();
+ }
+
+ //Does not take care of any array specific Xml Attributes
+ [MonoTODO]
+ private void SerializeArray (XmlWriter writer, object o)
+ {
+ Array arr = (o as Array);
+ if(arr == null || arr.Rank != 1)
+ throw new ApplicationException("Expected a single dimension Array, Got "+ o);
+
+ Type arrayType = arr.GetType().GetElementType();
+ string arrayTypeName = TypeTranslator.GetTypeData(arrayType).ElementName;
+
+ TypeData td = TypeTranslator.GetTypeData (arrayType);
+ writer.WriteStartElement (td.ElementName);
+ Console.WriteLine(td.ElementName);
+ //Special Treatment for Byte array
+ if(arrayType.Equals(typeof(byte)))
+ {
+ WriteBuiltinValue(writer,o);
+ }
+ else
+ {
+ for(int i=0; i< arr.Length; i++)
+ {
+ object value = arr.GetValue(i);
+ if (IsInbuiltType (arrayType))
+ {
+ WriteBuiltinValue(writer, value);
+ }
+ else
+ {
+ SerializeMembers(writer, value, false);
+ }
+ }
+ }
+ writer.WriteEndElement();
+ }
+
+ /// <summary>
+ /// If the type is a string, valuetype or primitive type we do not populate the TypeTable.
+ /// If the type is an array, we populate the TypeTable with Element type of the array.
+ /// If the type implements ICollection, it is handled differently. We do not care for its members.
+ /// If the type implements IEnumberable, we check that it implements Add(). Don't care for members.
+ /// </summary>
+ [MonoTODO ("Remove FIXMEs")]
+ private void FillTypeTable (Type type)
+ {
+ if (typeTable.Contains (type))
+ return;
+
+ //For value types and strings we don't need the members.
+ //FIXME: We will need the enum types probably.
+ if (IsInbuiltType (type))
+ return;
+
+ //Array, ICollection and IEnumberable are treated differenty
+ if (type.IsArray) {
+ FillArrayType (type);
+ return;
+ }
+ else if (type.IsEnum) {
+ FillEnum (type);
+ return;
+ }
+ else {
+ //There must be a public constructor
+ if (!HasDefaultConstructor (type))
+ throw new Exception ("Can't Serialize Type " + type.Name + " since it does not have default Constructor");
+
+ if (type.GetInterface ("ICollection") == typeof (System.Collections.ICollection)) {
+ FillICollectionType (type);
+ return;
+ }
+ if (type.GetInterface ("IEnumerable") == typeof (System.Collections.IEnumerable)) {
+ //FillIEnumerableType(type);
+ //return;
+ }
+ }
+
+
+ //Add the Class to the hashtable.
+ //Each value of the hashtable has two objects, one is the hashtable with key of membername (for deserialization)
+ //Other is an Array of XmlSerializernames, Array of XmlAttributes & Array of XmlElements.
+ Object[] memberObj = new Object[4];
+ typeTable.Add (type,memberObj);
+
+ Hashtable memberTable = new Hashtable ();
+ memberObj[0] = memberTable;
+ memberTable.Add ("", XmlAttributes.FromClass (type));
+
+ memberObj[1] = null;
+
+ ArrayList attributes = new ArrayList ();
+ memberObj[2] = attributes;
+
+ ArrayList elements = new ArrayList ();
+ memberObj[3] = elements;
+
+ //Get the graph of the members. Graph is nothing but the order
+ //in which MS implementation serializes the members.
+ MemberInfo[] minfo = GetGraph (type);
+
+ foreach (MemberInfo member in minfo) {
+ FieldInfo fieldInfo = (member as FieldInfo);
+ PropertyInfo propertyInfo = (member as PropertyInfo);
+
+ if (fieldInfo != null) {
+ //If field is readOnly or const, do not serialize it.
+ if (fieldInfo.IsLiteral || fieldInfo.IsInitOnly)
+ continue;
+
+ XmlAttributes xmlAttributes = XmlAttributes.FromField (member, fieldInfo);
+
+ //If XmlAttributes have XmlIgnore, ignore this member
+
+ if (xmlAttributes.XmlIgnore)
+ continue;
+
+ //If this member is a XmlNs type, set the XmlNs object.
+ if (xmlAttributes.Xmlns) {
+ memberObj[1] = xmlAttributes;
+ continue;
+ }
+
+ //If the member is a attribute Type, Add to attribute list
+ if (xmlAttributes.isAttribute)
+ attributes.Add (xmlAttributes);
+ else //Add to elements
+ elements.Add (xmlAttributes);
+
+ //Add in the Hashtable.
+ memberTable.Add (member.Name, xmlAttributes);
+
+ if (xmlAttributes.XmlAnyAttribute != null || xmlAttributes.XmlText != null)
+ continue;
+
+ if (xmlAttributes.XmlElements.Count > 0) {
+ foreach (XmlElementAttribute elem in xmlAttributes.XmlElements) {
+ if (elem.Type != null)
+ FillTypeTable (elem.Type);
+ else
+ FillTypeTable (fieldInfo.FieldType);
+ }
+ continue;
+ }
+
+ if (!IsInbuiltType (fieldInfo.FieldType))
+ FillTypeTable (fieldInfo.FieldType);
+ }
+ else if (propertyInfo != null) {
+ //If property is readonly or writeonly, do not serialize it.
+ //Exceptions are properties whose return type is array, ICollection or IEnumerable
+ //Indexers are not serialized unless the class Implements ICollection.
+ if (!(propertyInfo.PropertyType.IsArray || Implements (propertyInfo.PropertyType, typeof (ICollection)) ||
+ (propertyInfo.PropertyType != typeof (string) && Implements (propertyInfo.PropertyType, typeof (IEnumerable))))) {
+ if(!(propertyInfo.CanRead && propertyInfo.CanWrite) || propertyInfo.GetIndexParameters ().Length != 0)
+ continue;
+ }
+
+ XmlAttributes xmlAttributes = XmlAttributes.FromProperty (member, propertyInfo);
+
+ // If XmlAttributes have XmlIgnore, ignore this member
+ if (xmlAttributes.XmlIgnore)
+ continue;
+
+ // If this member is a XmlNs type, set the XmlNs object.
+ if (xmlAttributes.Xmlns) {
+ memberObj[1] = xmlAttributes;
+ continue;
+ }
+ // If the member is a attribute Type, Add to attribute list
+ if (xmlAttributes.isAttribute)
+ attributes.Add (xmlAttributes);
+ else //Add to elements
+ elements.Add (xmlAttributes);
+
+ // OtherWise add in the Hashtable.
+ memberTable.Add (member.Name, xmlAttributes);
+
+ if (xmlAttributes.XmlAnyAttribute != null || xmlAttributes.XmlText != null)
+ continue;
+
+ if (xmlAttributes.XmlElements.Count > 0) {
+ foreach (XmlElementAttribute elem in xmlAttributes.XmlElements) {
+ if (elem.Type != null)
+ FillTypeTable (elem.Type);
+ else
+ FillTypeTable (propertyInfo.PropertyType);
+ }
+ continue;
+ }
+
+ if (!IsInbuiltType (propertyInfo.PropertyType))
+ FillTypeTable (propertyInfo.PropertyType);
+ }
+ }
+
+ // Sort the attributes for the members according to their Order
+ // This is an extension to MS's Implementation and will be useful
+ // if our reflection does not return the same order of elements
+ // as MS .NET impl
+ if (useOrder)
+ BubbleSort (elements, XmlAttributes.attrComparer);
+ }
+
+ private void FillArrayType (Type type)
+ {
+ if (type.GetArrayRank () != 1)
+ throw new Exception ("MultiDimensional Arrays are not Supported");
+
+ Type arrayType = type.GetElementType ();
+
+ if (arrayType.IsArray)
+ FillArrayType (arrayType);
+ else if (!IsInbuiltType (arrayType))
+ FillTypeTable (arrayType);
+ }
+
+ private void FillICollectionType (Type type)
+ {
+ //Must have an public Indexer that takes an integer and
+ //a public Count Property which returns an int.
+
+ BindingFlags flags = BindingFlags.Public | BindingFlags.Instance;
+
+ //Find a non indexer Count Property with return type of int
+ PropertyInfo countProp = type.GetProperty ("Count", flags, null, typeof (int), new Type[0], null);
+ if (countProp == null || !countProp.CanRead)
+ throw new Exception ("Cannot Serialize " + type + " because it implements ICollectoion, but does not implement public Count property");
+ //Find a indexer Item Property which takes an int
+ PropertyInfo itemProp = type.GetProperty ("Item", flags, null, null, new Type[1] {typeof (int)}, null);
+ if (itemProp == null || !itemProp.CanRead || !itemProp.CanWrite)
+ throw new Exception ("Cannot Serialize " + type + " because it does not have a read/write indexer property that takes an int as argument");
+ FillTypeTable (itemProp.PropertyType);
+ }
+
+ [MonoTODO]
+ private void FillIEnumerableType (Type type)
+ {
+ //Must implement a public Add method that takes a single parameter.
+ //The Add method's parameter must be of the same type as is returned from
+ //the Current property on the value returned from GetEnumerator, or one of that type's bases.
+
+ // We currently ignore enumerable types anyway, so this method was junked.
+ // The code did not do what the documentation above says (if that is even possible!)
+ return;
+ }
+
+ private void FillEnum (Type type)
+ {
+ Hashtable memberTable = new Hashtable ();
+ BindingFlags flags = BindingFlags.Public | BindingFlags.Instance;
+ typeTable.Add (type, memberTable);
+ string[] names = Enum.GetNames (type);
+
+ foreach (string name in names) {
+ MemberInfo[] members = type.GetMember (name);
+ if (members.Length != 1)
+ throw new Exception("Should never happen. Enum member not present or more than one. " + name);
+ XmlAttributes xmlAttributes = new XmlAttributes (members[0]);
+
+ if (xmlAttributes.XmlIgnore)
+ continue;
+
+ if (xmlAttributes.XmlEnum != null)
+ memberTable.Add (members[0].Name, xmlAttributes.XmlEnum.Name);
+ else
+ memberTable.Add (members[0].Name, members[0].Name);
+ }
+ }
+
+ private bool HasDefaultConstructor (Type type)
+ {
+ ConstructorInfo defaultConstructor = type.GetConstructor (new Type[0]);
+ if (defaultConstructor == null || defaultConstructor.IsAbstract || defaultConstructor.IsStatic || !defaultConstructor.IsPublic)
+ return false;
+
+ return true;
+ }
+
+ private bool IsInbuiltType (Type type)
+ {
+ if (type.IsEnum)
+ return false;
+ if (type.IsValueType || type == typeof (string) || type.IsPrimitive)
+ return true;
+ if (type == typeof (DateTime) || type == typeof (XmlNode))
+ return true;
+
+ return false;
+ }
+
+ private static MemberInfo[] GetGraph(Type type)
+ {
+ ArrayList typeGraph = new ArrayList ();
+ GetGraph (type, typeGraph);
+ return (MemberInfo[]) typeGraph.ToArray (typeof (MemberInfo));
+ }
+
+ private static void GetGraph (Type type, ArrayList typeGraph)
+ {
+ BindingFlags flags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly;
+ if (type.BaseType == null)
+ return;
+ GetGraph (type.BaseType, typeGraph);
+
+ typeGraph.AddRange (type.GetFields (flags));
+ typeGraph.AddRange (type.GetProperties (flags));
+ }
+
+ private string GetXmlValue (object value)
+ {
+ if (value == null)
+ return null;
+ #region enum type
+ if (value is Enum)
+ {
+ Type type = value.GetType ();
+
+ if (typeTable.ContainsKey (type)) {
+ Hashtable memberTable = (Hashtable) (typeTable[type]);
+ if (type.IsDefined (typeof (FlagsAttribute), false)) {
+ //If value is exactly a single enum member
+ if (memberTable.Contains (value.ToString ()))
+ return (string) memberTable[value.ToString ()];
+
+ string retval = "";
+ int enumval = (int) value;
+ string[] names = Enum.GetNames (type);
+
+ foreach (string key in names) {
+ if (!memberTable.ContainsKey (key))
+ continue;
+
+ //Otherwise multiple values.
+ int val = (int) Enum.Parse (type, key);
+ if (val != 0 && (enumval & val) == val)
+ retval += " " + (string) memberTable[Enum.GetName (type, val)];
+ }
+
+ retval = retval.Trim ();
+
+ if (retval.Length == 0)
+ return null;
+
+ return retval;
+ }
+ else if (memberTable.ContainsKey (value.ToString ()))
+ return (string) memberTable[value.ToString()];
+ else
+ return null;
+ }
+ else
+ throw new Exception ("Unknown Enumeration");
+ }
+ #endregion
+ if (value is byte[])
+ return XmlCustomFormatter.FromByteArrayHex((byte[])value);
+ if (value is Guid)
+ return XmlConvert.ToString((Guid)value);
+ if(value is DateTime)
+ return XmlConvert.ToString((DateTime)value);
+ if(value is TimeSpan)
+ return XmlConvert.ToString((TimeSpan)value);
+ if(value is bool)
+ return XmlConvert.ToString((bool)value);
+ if(value is byte)
+ return XmlConvert.ToString((byte)value);
+ if(value is char)
+ return XmlCustomFormatter.FromChar((char)value);
+ if(value is decimal)
+ return XmlConvert.ToString((decimal)value);
+ if(value is double)
+ return XmlConvert.ToString((double)value);
+ if(value is short)
+ return XmlConvert.ToString((short)value);
+ if(value is int)
+ return XmlConvert.ToString((int)value);
+ if(value is long)
+ return XmlConvert.ToString((long)value);
+ if(value is sbyte)
+ return XmlConvert.ToString((sbyte)value);
+ if(value is float)
+ return XmlConvert.ToString((float)value);
+ if(value is ushort)
+ return XmlConvert.ToString((ushort)value);
+ if(value is uint)
+ return XmlConvert.ToString((uint)value);
+ if(value is ulong)
+ return XmlConvert.ToString((ulong)value);
+ if (value is XmlQualifiedName) {
+ if (((XmlQualifiedName) value).IsEmpty)
+ return null;
+ }
+ return (value == null) ? null : value.ToString ();
+ }
+
+ [MonoTODO ("Remove FIXMEs")]
+ private static void ProcessAttributes (XmlAttributes attrs, Hashtable memberTable)
+ {
+ if (attrs.XmlAnyAttribute != null) {
+ // FIXME
+ }
+ foreach (XmlAnyElementAttribute anyelem in attrs.XmlAnyElements)
+ memberTable.Add (new XmlQualifiedName (anyelem.Name, anyelem.Namespace), attrs);
+
+ if (attrs.XmlArray != null) {
+ // FIXME
+ }
+
+ foreach (XmlArrayItemAttribute item in attrs.XmlArrayItems)
+ memberTable.Add (new XmlQualifiedName (item.ElementName, item.Namespace), attrs);
+
+ if (attrs.XmlAttribute != null)
+ memberTable.Add (new XmlQualifiedName (attrs.XmlAttribute.AttributeName,attrs.XmlAttribute.Namespace), attrs);
+
+ if (attrs.XmlChoiceIdentifier != null) {
+ // FIXME
+ }
+
+ foreach (XmlElementAttribute elem in attrs.XmlElements)
+ memberTable.Add (new XmlQualifiedName (elem.ElementName, elem.Namespace), attrs);
+
+ if (attrs.XmlEnum != null) {
+ // FIXME
+ }
+
+ if (attrs.XmlType != null)
+ memberTable.Add (new XmlQualifiedName (attrs.XmlType.TypeName, attrs.XmlType.Namespace), attrs);
+ }
+
+ private bool Implements (Type type, Type interfaceType)
+ {
+ return (type.GetInterface (interfaceType.Name) == interfaceType);
+ }
+
+ private static void BubbleSort (ArrayList array, IComparer comparer)
+ {
+ int len = array.Count;
+ object obj1, obj2;
+ for (int i=0; i < len; i++) {
+ for (int j=0; j < len -i -1; j++) {
+ obj1 = array[j];
+ obj2 = array[j+1];
+ if (comparer.Compare (obj2 , obj1 ) < 0) {
+ array[j] = obj2;
+ array[j+1] = obj1;
+ }
+ }
+ }
+ }
+ #endregion // Methods
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializerNamespaces.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializerNamespaces.cs
new file mode 100644
index 00000000000..744026ae201
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializerNamespaces.cs
@@ -0,0 +1,76 @@
+//
+// XmlSerializerNamespaces.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System;
+using System.Xml;
+using System.Collections;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for XmlSerializerNamespaces.
+ /// </summary>
+ public class XmlSerializerNamespaces
+ {
+ private Hashtable namespaces;
+
+ public XmlSerializerNamespaces ()
+ {
+ namespaces = new Hashtable ();
+ }
+
+ public XmlSerializerNamespaces(XmlQualifiedName[] namespaces)
+ : this()
+ {
+ foreach(XmlQualifiedName qname in namespaces)
+ {
+ this.namespaces[qname.Name] = qname;
+ }
+ }
+
+ public XmlSerializerNamespaces(XmlSerializerNamespaces namespaces)
+ : this(namespaces.ToArray())
+ {}
+
+ public void Add (string prefix, string ns)
+ {
+ XmlQualifiedName qname = new XmlQualifiedName(prefix,ns);
+ namespaces[qname.Name] = qname;
+ }
+
+ public XmlQualifiedName[] ToArray ()
+ {
+ XmlQualifiedName[] array = new XmlQualifiedName[namespaces.Count];
+ namespaces.Values.CopyTo(array,0);
+ return array;
+ }
+
+ public int Count
+ {
+ get{ return namespaces.Count; }
+ }
+
+ internal string GetPrefix(string Ns)
+ {
+ foreach(string prefix in namespaces.Keys)
+ {
+ if(Ns == ((XmlQualifiedName)namespaces[prefix]).Namespace)
+ return prefix;
+ }
+ return null;
+ }
+
+ internal Hashtable Namespaces
+ {
+ get {
+ return namespaces;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlTextAttribute.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlTextAttribute.cs
new file mode 100644
index 00000000000..c45c61cc2c6
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlTextAttribute.cs
@@ -0,0 +1,61 @@
+//
+// XmlTextAttribute.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for XmlTextAttribute.
+ /// </summary>
+ [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field
+ | AttributeTargets.Parameter | AttributeTargets.ReturnValue)]
+ public class XmlTextAttribute : Attribute
+ {
+ private string dataType;
+ private Type type;
+ private int order;
+
+ public XmlTextAttribute ()
+ {
+ }
+
+ public XmlTextAttribute (Type type)
+ {
+ Type = type;
+ }
+
+ public string DataType {
+ get {
+ return dataType;
+ }
+ set {
+ dataType = value;
+ }
+ }
+ public Type Type
+ {
+ get {
+ return type;
+ }
+ set {
+ type = value;
+ }
+ }
+ /// <summary>
+ /// Specifies Order in which Memberswill be serialized as Elements.
+ /// </summary>
+ internal int Order
+ {
+ get{ return order; }
+ set{ order = value; }
+ }
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlTypeAttribute.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlTypeAttribute.cs
new file mode 100644
index 00000000000..dd8ebacb162
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlTypeAttribute.cs
@@ -0,0 +1,60 @@
+//
+// XmlTypeAttribute.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for XmlTypeAttribute.
+ /// </summary>
+ [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct |
+ AttributeTargets.Enum | AttributeTargets.Interface)]
+ public class XmlTypeAttribute : Attribute
+ {
+ private bool includeInSchema;
+ private string ns;
+ private string typeName;
+
+ public XmlTypeAttribute ()
+ {
+ }
+
+ public XmlTypeAttribute (string typeName)
+ {
+ TypeName = typeName;
+ }
+
+ public bool IncludeInSchema {
+ get {
+ return includeInSchema;
+ }
+ set {
+ includeInSchema = value;
+ }
+ }
+
+ public string Namespace {
+ get {
+ return ns;
+ }
+ set {
+ ns = value;
+ }
+ }
+ public string TypeName {
+ get {
+ return typeName;
+ }
+ set {
+ typeName = value;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlTypeMapping.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlTypeMapping.cs
new file mode 100644
index 00000000000..ff9c9b7b4f0
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlTypeMapping.cs
@@ -0,0 +1,50 @@
+//
+// XmlTypeMapping.cs:
+//
+// Author:
+// John Donagher (john@webmeta.com)
+//
+// (C) 2002 John Donagher
+//
+
+using System.Xml;
+using System;
+
+namespace System.Xml.Serialization
+{
+ /// <summary>
+ /// Summary description for XmlTypeMapping.
+ /// </summary>
+ public class XmlTypeMapping : XmlMapping
+ {
+ private string elementName;
+ private string ns;
+ private string typeFullName;
+ private string typeName;
+
+ internal XmlTypeMapping(string elementName, string ns, string typeFullName, string typeName)
+ {
+ this.elementName = elementName;
+ this.ns = ns;
+ this.typeFullName = typeFullName;
+ this.typeName = typeName;
+ }
+
+ public string ElementName
+ {
+ get { return elementName; }
+ }
+ public string Namespace
+ {
+ get { return ns; }
+ }
+ public string TypeFullName
+ {
+ get { return typeFullName; }
+ }
+ public string TypeName
+ {
+ get { return typeName; }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.XPath/ChangeLog b/mcs/class/System.XML/System.Xml.XPath/ChangeLog
new file mode 100644
index 00000000000..de38e95c0ce
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.XPath/ChangeLog
@@ -0,0 +1,183 @@
+2003-01-02 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * Tokenizer.cs : Fixed ParseIdentifier to allow digits.
+ (It should be a temporary fix.)
+
+2002-09-22 Nick Drochak <ndrochak@gol.com>
+
+ * Parser.cs: Remove extraneous "using" that was stopping the build.
+
+2002-09-21 Piers Haken <piersh@friskit.com>
+
+ * XPathException: implementation
+ * Expression.cs:
+ * Iterator.cs:
+ * Parser.jay:
+ * Tokenizer.jay:
+ * XPathNavigator.jay:
+ use XPathException.
+
+2002-09-13 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Parser.cs: commented out non-existent namespace (it compiles fine
+ with mcs because of a bug that is already on bugzilla).
+
+2002-09-12 Piers Haken <piersh@friskit.com>
+
+ * Tokenizer.cs: fix parsing numbers that start with '.'
+ * DefaultContext.cs: use MS-compatible formatting of doubles
+
+2002-09-12 Piers Haken <piersh@friskit.com>
+
+ * Iterator.cs: added NullIterator to handle unspecified contexts
+ * XPathNavigator.cs: use NullIterator insted of SelfIterator when context is unspecified.
+ * XPathNodeIterator.cs: change default _count to -1 to prevent recalculations for NullIterators
+
+2002-09-12 Piers Haken <piersh@friskit.com>
+
+ * Expression.cs, Parser.jay: allow ExprSLASH to take a generic expression as its left argument.
+ * Iterator.cs: fix SlashIterator.Clone() when _iterRight is null.
+ * DefaultContext.cs: fix id() return type.
+
+2002-09-03 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * DefaultContext.cs: fixed bug #28840.
+ * Expression.cs: added FIXME.
+
+2002-08-17 Jason Diamond <jason@injektilo.org>
+
+ * XPathNavigator.cs: Fixed matching on patterns that look like
+ absolute XPath expressions.
+
+2002-08-17 Jason Diamond <jason@injektilo.org>
+
+ * XPathNavigator.cs: Added naive (but working) implementation of
+ Matches.
+
+2002-07-31 Piers Haken <piersh@friskit.com>
+
+ * XPathDocument.cs: simple, XmlDocument-based implementation
+
+2002-07-25 Piers Haken <piersh@friskit.com>
+
+ * DefaultContext.cs: implement XPathFunctionName 'name()' function.
+
+2002-07-17 Piers Haken <piersh@friskit.com>
+
+ * DefaultContext.cs: implement 'string-length()', 'normalize-space()'
+ * Parser.jay: remove redundant production
+ * Expression.cs: add switches for debugging under VS.NET
+
+2002-07-17 Piers Haken <piersh@friskit.com>
+
+ * Expression.cs: implement nodeset/nodeset comparisons (non-optimal)
+
+2002-07-15 Piers Haken <piersh@friskit.com>
+
+ * Iterator.cs:
+ - rename UnionIterator to MergedIterator,
+ - create new UnionIterator to implment uniqueness for '|' operator
+ - fix position bug in ArrayListIterator.Clone()
+ * Expression.cs: use new UnionIterator constructor syntax
+
+2002-07-12 Piers Haken <piersh@friskit.com>
+
+ * Iterator.cs: PredicateIterator: handle numeric predicates
+ * Parser.jay: add some debugging support: yyparseDebug
+ * Tokenizer.cs: cleanup, include '-' chars in identifier tokens
+
+2002-06-29 Piers Haken <piersh@friskit.com>
+
+ * Expression.cs:
+ - remove dead code
+ - NodeTest uses XPathResultType instead of internal NodeTestTypes enum
+ - remove NodeTestTypes enum
+ - remove NodeTestTypeAny (functionality provided by base now)
+ - fix ExprStep to handle wildcard QNames
+ * Parser.jay:
+ - moved to Mono.Xml.XPath namespace
+ - use XPathResultType
+ - handle wildcard QNames
+
+ * Tokenizer.cs: moved to Mono.Xml.XPath namespace
+
+ * XPathNavigator.cs: implement
+ - IsDescendant
+ - SelectAncestors
+ - SelectDescendants
+ - SelectChildren
+
+ * XPathResultType.cs: fix enum values
+
+2002-06-24 Jason Diamond <jason@injektilo.org>
+
+ * XPathScanner.cs: Removed.
+
+2002-06-24 Dick Porter <dick@ximian.com>
+
+ * XmlCaseOrder.cs: Fix namespace
+
+2002-06-23 Piers Haken <piersh@friskit.com>
+
+ * DefaultContext.cs: implemented XPathFUnctionId
+ * Iterator.cs: new ArrayListIterator for id() support
+
+2002-06-23 Piers Haken <piersh@friskit.com>
+
+ * XPathNavigator.cs: implement:
+ - Compile
+ - Evaluate
+ - Clone
+ - Select
+ - ToString
+ - some forwarding methods
+
+ * XPathNodeIterator: implement caching Count
+
+ * Tokenizer.cs: new XPath tokenizer
+ * Parser.jay: new XPath grammar
+ * Parser.cs: new precompiled XPath grammar
+ * Expression.cs: new XPath expression objects
+ * Iterator.cs: new XPath result/context objects
+ * DefaultContext.cs: new XPath function binding context
+
+2002-05-08 Tim Coleman <tim@timcoleman.com>
+ * XPathDocument.cs:
+ * XPathException.cs: New stub files added.
+
+2002-04-12 Duncan Mak <duncan@ximian.com>
+
+ * XmlCaseOrder.cs: Moved to here from System.Xml.
+
+2002-03-26 Jason Diamond <jason@injektilo.org>
+
+ * XPathScanner.cs: Now handles name tests with wildacards. Abbreviated
+ steps. Both absolution and relative abbreviated location paths.
+
+2002-03-25 Jason Diamond <jason@injektilo.org>
+
+ * XPathScanner.cs: Added new file. This class is supposed to be internal
+ but that would make it impossible to test.
+
+2002-03-08 Duncan Mak <duncan@ximian.com>
+
+ * XPathNamespaceScope.cs:
+ * XPathNodeType.cs:
+ * XPathResultType.cs:
+ * XmlDataType.cs:
+ * XmlSortOrder.cs: Used EnumCheck and realigned elements to be compatible with MS
+ implementation. XPathResultType is interesting as EnumCheck does
+ not show the Navigator element, but shows the String element twice.
+
+2002-03-08 Jason Diamond <jason@injektilo.org>
+
+ * XmlDataType.cs, XmlSortOrder.cs, XPathNodeType.cs: Added files.
+
+2002-03-06 Jason Diamond <jason@injektilo.org>
+
+ * ChangeLog: Added to this directory.
+
+ * XPathExpression.cs, XPathNamespaceScope.cs, XPathNodeIterator.cs,
+ XPathResultType.cs: New files.
+
+ * XPathNavigator.cs: Stubbed out all properties and methods.
diff --git a/mcs/class/System.XML/System.Xml.XPath/DefaultContext.cs b/mcs/class/System.XML/System.Xml.XPath/DefaultContext.cs
new file mode 100644
index 00000000000..ed27d168858
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.XPath/DefaultContext.cs
@@ -0,0 +1,618 @@
+//
+// System.Xml.XPath.DefaultContext & support classes
+//
+// Author:
+// Piers Haken (piersh@friskit.com)
+//
+// (C) 2002 Piers Haken
+//
+using System;
+using System.Collections;
+using System.Xml;
+using System.Xml.XPath;
+using System.Xml.Xsl;
+
+namespace System.Xml.XPath
+{
+ /// <summary>
+ /// Summary description for DefaultContext.
+ /// </summary>
+ internal class DefaultContext : XsltContext
+ {
+ protected static Hashtable _htFunctions = new Hashtable ();
+
+ static DefaultContext()
+ {
+ Add (new XPathFunctionLast ());
+ Add (new XPathFunctionPosition ());
+ Add (new XPathFunctionCount ());
+ Add (new XPathFunctionId ());
+ Add (new XPathFunctionLocalName ());
+ Add (new XPathFunctionNamespaceUri ());
+ Add (new XPathFunctionName ());
+ Add (new XPathFunctionString ());
+ Add (new XPathFunctionConcat ());
+ Add (new XPathFunctionStartsWith ());
+ Add (new XPathFunctionContains ());
+ Add (new XPathFunctionSubstringBefore ());
+ Add (new XPathFunctionSubstringAfter ());
+ Add (new XPathFunctionSubstring ());
+ Add (new XPathFunctionStringLength ());
+ Add (new XPathFunctionNormalizeSpace ());
+ Add (new XPathFunctionTranslate ());
+ Add (new XPathFunctionBoolean ());
+ Add (new XPathFunctionNot ());
+ Add (new XPathFunctionTrue ());
+ Add (new XPathFunctionFalse ());
+ Add (new XPathFunctionLang ());
+ Add (new XPathFunctionNumber ());
+ Add (new XPathFunctionSum ());
+ Add (new XPathFunctionFloor ());
+ Add (new XPathFunctionCeil ());
+ Add (new XPathFunctionRound ());
+ }
+
+ [MonoTODO]
+ public override IXsltContextFunction ResolveFunction (string prefix, string name, XPathResultType[] ArgTypes)
+ {
+ // match the prefix
+ if (prefix != null && prefix != "") // TODO: should we allow some namespaces here?
+ return null;
+
+ // match the function name
+ XPathFunction fn = (XPathFunction) _htFunctions [name];
+ if (fn == null)
+ return null;
+
+ // check the number of arguments
+ int cArgs = ArgTypes.Length;
+ if (cArgs < fn.Minargs || cArgs > fn.Maxargs)
+ return null;
+
+ // check the types of the arguments
+ XPathResultType [] rgTypes = fn.ArgTypes;
+ if (rgTypes == null)
+ {
+ if (cArgs != 0)
+ return null;
+ }
+ else
+ {
+ int cTypes = rgTypes.Length;
+ for (int iArg = 0; iArg < cArgs; iArg ++)
+ {
+ XPathResultType typeRequested = ArgTypes [iArg];
+ XPathResultType typeDefined = (iArg >= cTypes) ? rgTypes [cTypes - 1] : rgTypes [iArg];
+ if (typeDefined != XPathResultType.Any && typeDefined != typeRequested)
+ return null;
+ }
+ }
+ return fn;
+ }
+ public override IXsltContextVariable ResolveVariable (string prefix, string name)
+ {
+ return null;
+ }
+ [MonoTODO]
+ public override int CompareDocument (string baseUri, string nextBaseUri) { throw new NotImplementedException (); }
+ [MonoTODO]
+ public override bool PreserveWhitespace (XPathNavigator nav) { throw new NotImplementedException (); }
+ [MonoTODO]
+ public override bool Whitespace { get { throw new NotImplementedException (); }}
+ protected static void Add (XPathFunction fn)
+ {
+ _htFunctions.Add (fn.Name, fn);
+ }
+ }
+
+ internal class XPathFunctions
+ {
+ public static bool ToBoolean (object arg)
+ {
+ if (arg == null)
+ throw new ArgumentNullException ();
+ if (arg is bool)
+ return (bool) arg;
+ if (arg is double)
+ {
+ double dArg = (double) arg;
+ return (dArg != 0.0 && !double.IsNaN (dArg));
+ }
+ if (arg is string)
+ return ((string) arg).Length != 0;
+ if (arg is BaseIterator)
+ {
+ BaseIterator iter = (BaseIterator) arg;
+ return iter.MoveNext ();
+ }
+ throw new ArgumentException ();
+ }
+ [MonoTODO]
+ public static string ToString (object arg)
+ {
+ if (arg == null)
+ throw new ArgumentNullException ();
+ if (arg is string)
+ return (string) arg;
+ if (arg is bool)
+ return ((bool) arg) ? "true" : "false";
+ if (arg is double)
+ return ((double) arg).ToString ("R", System.Globalization.NumberFormatInfo.InvariantInfo);
+ if (arg is BaseIterator)
+ {
+ BaseIterator iter = (BaseIterator) arg;
+ if (!iter.MoveNext ())
+ return "";
+ return iter.Current.Value;
+ }
+ throw new ArgumentException ();
+ }
+ [MonoTODO]
+ public static double ToNumber (object arg)
+ {
+ if (arg == null)
+ throw new ArgumentNullException ();
+ if (arg is BaseIterator)
+ arg = ToString (arg); // follow on
+ if (arg is string)
+ return XmlConvert.ToDouble ((string) arg); // TODO: spec? convert string to number
+ if (arg is double)
+ return (double) arg;
+ if (arg is bool)
+ return Convert.ToDouble ((bool) arg);
+ throw new ArgumentException ();
+ }
+ }
+
+ internal abstract class XPathFunction : IXsltContextFunction
+ {
+ public abstract XPathResultType ReturnType { get; }
+ public abstract int Minargs { get; }
+ public abstract int Maxargs { get; }
+ public abstract XPathResultType [] ArgTypes { get; }
+ public object Invoke (XsltContext xsltContext, object[] args, XPathNavigator docContext)
+ {
+ return TypesafeInvoke (xsltContext, args, docContext);
+ }
+
+ public abstract string Name { get; }
+ public abstract object TypesafeInvoke (XsltContext xsltContext, object[] args, XPathNavigator docContext);
+ }
+
+ internal class XPathFunctionLast : XPathFunction
+ {
+ public override XPathResultType ReturnType { get { return XPathResultType.Number; }}
+ public override int Minargs { get { return 0; }}
+ public override int Maxargs { get { return 0; }}
+ public override XPathResultType [] ArgTypes { get { return null; }}
+ public override object TypesafeInvoke (XsltContext xsltContext, object[] args, XPathNavigator docContext)
+ {
+ throw new NotImplementedException (); // special-cased
+ }
+ public override string Name { get { return "last"; }}
+ }
+ internal class XPathFunctionPosition : XPathFunction
+ {
+ public override XPathResultType ReturnType { get { return XPathResultType.Number; }}
+ public override int Minargs { get { return 0; }}
+ public override int Maxargs { get { return 0; }}
+ public override XPathResultType [] ArgTypes { get { return null; }}
+ public override object TypesafeInvoke (XsltContext xsltContext, object[] args, XPathNavigator docContext)
+ {
+ throw new NotImplementedException (); // special-cased
+ }
+ public override string Name { get { return "position"; }}
+ }
+ internal class XPathFunctionCount : XPathFunction
+ {
+ public override XPathResultType ReturnType { get { return XPathResultType.Number; }}
+ public override int Minargs { get { return 1; }}
+ public override int Maxargs { get { return 1; }}
+ public override XPathResultType [] ArgTypes { get { return new XPathResultType [] { XPathResultType.NodeSet }; }}
+ public override object TypesafeInvoke (XsltContext xsltContext, object[] args, XPathNavigator docContext)
+ {
+ return ((BaseIterator) args [0]).Count;
+ }
+ public override string Name { get { return "count"; }}
+ }
+ internal class XPathFunctionId : XPathFunction
+ {
+ private static char [] rgchWhitespace = {' ', '\t', '\r', '\n'};
+ public override XPathResultType ReturnType { get { return XPathResultType.NodeSet; }}
+ public override int Minargs { get { return 1; }}
+ public override int Maxargs { get { return 1; }}
+ public override XPathResultType [] ArgTypes { get { return new XPathResultType [] { XPathResultType.Any }; }}
+ [MonoTODO]
+ public override object TypesafeInvoke (XsltContext xsltContext, object[] args, XPathNavigator docContext)
+ {
+ String strArgs;
+ BaseIterator iter = args [0] as BaseIterator;
+ if (iter != null)
+ {
+ strArgs = "";
+ while (!iter.MoveNext ())
+ strArgs += iter.Current.Value + " ";
+ }
+ else
+ strArgs = XPathFunctions.ToString (args [0]);
+ string [] rgstrArgs = strArgs.Split (rgchWhitespace);
+ ArrayList rgNodes = new ArrayList ();
+ foreach (string strArg in rgstrArgs)
+ {
+ if (docContext.MoveToId (strArg))
+ rgNodes.Add (docContext.Clone ());
+ }
+ return new ArrayListIterator (iter, rgNodes);
+ }
+ public override string Name { get { return "id"; }}
+ }
+ internal class XPathFunctionLocalName : XPathFunction
+ {
+ public override XPathResultType ReturnType { get { return XPathResultType.NodeSet; }}
+ public override int Minargs { get { return 0; }}
+ public override int Maxargs { get { return 1; }}
+ public override XPathResultType [] ArgTypes { get { return new XPathResultType [] { XPathResultType.NodeSet }; }}
+ public override object TypesafeInvoke (XsltContext xsltContext, object[] args, XPathNavigator docContext)
+ {
+ BaseIterator iter = (args.Length == 1) ? ((BaseIterator) args [0]) : new SelfIterator (docContext, xsltContext);
+ if (iter == null || !iter.MoveNext ())
+ return "";
+ return iter.Current.LocalName;
+ }
+ public override string Name { get { return "local-name"; }}
+ }
+ internal class XPathFunctionNamespaceUri : XPathFunction
+ {
+ public override XPathResultType ReturnType { get { return XPathResultType.String; }}
+ public override int Minargs { get { return 0; }}
+ public override int Maxargs { get { return 1; }}
+ public override XPathResultType [] ArgTypes { get { return new XPathResultType [] { XPathResultType.NodeSet }; }}
+ [MonoTODO]
+ public override object TypesafeInvoke (XsltContext xsltContext, object[] args, XPathNavigator docContext)
+ {
+ BaseIterator iter = (args.Length == 1) ? ((BaseIterator) args [0]) : new SelfIterator (docContext, xsltContext);
+ if (iter == null || !iter.MoveNext ())
+ return "";
+ return iter.Current.NamespaceURI; // TODO: should the namespace be expanded wrt. the given context?
+ }
+ public override string Name { get { return "namespace-uri"; }}
+ }
+ internal class XPathFunctionName : XPathFunction
+ {
+ public override XPathResultType ReturnType { get { return XPathResultType.String; }}
+ public override int Minargs { get { return 0; }}
+ public override int Maxargs { get { return 1; }}
+ public override XPathResultType [] ArgTypes { get { return new XPathResultType [] { XPathResultType.NodeSet }; }}
+ [MonoTODO]
+ public override object TypesafeInvoke (XsltContext xsltContext, object[] args, XPathNavigator docContext)
+ {
+ BaseIterator iter = (args.Length == 1) ? ((BaseIterator) args [0]) : new SelfIterator (docContext, xsltContext);
+ if (iter == null || !iter.MoveNext ())
+ return "";
+ return iter.Current.Name;
+ }
+ public override string Name { get { return "name"; }}
+ }
+ internal class XPathFunctionString : XPathFunction
+ {
+ public override XPathResultType ReturnType { get { return XPathResultType.String; }}
+ public override int Minargs { get { return 0; }}
+ public override int Maxargs { get { return 1; }}
+ public override XPathResultType [] ArgTypes { get { return new XPathResultType [] { XPathResultType.Any }; }}
+ public override object TypesafeInvoke (XsltContext xsltContext, object[] args, XPathNavigator docContext)
+ {
+ return XPathFunctions.ToString (args [0]);
+ }
+ public override string Name { get { return "string"; }}
+ }
+ internal class XPathFunctionConcat : XPathFunction
+ {
+ public override XPathResultType ReturnType { get { return XPathResultType.String; }}
+ public override int Minargs { get { return 2; }}
+ public override int Maxargs { get { return int.MaxValue; }}
+ public override XPathResultType [] ArgTypes { get { return new XPathResultType [] { XPathResultType.String, XPathResultType.String, XPathResultType.String }; }}
+ public override object TypesafeInvoke (XsltContext xsltContext, object[] args, XPathNavigator docContext)
+ {
+ String str = "";
+ foreach (string strArg in args)
+ str += strArg;
+ return str;
+ }
+ public override string Name { get { return "concat"; }}
+ }
+ internal class XPathFunctionStartsWith : XPathFunction
+ {
+ public override XPathResultType ReturnType { get { return XPathResultType.Boolean; }}
+ public override int Minargs { get { return 2; }}
+ public override int Maxargs { get { return 2; }}
+ public override XPathResultType [] ArgTypes { get { return new XPathResultType [] { XPathResultType.String, XPathResultType.String }; }}
+ public override object TypesafeInvoke (XsltContext xsltContext, object[] args, XPathNavigator docContext)
+ {
+ string str1 = (string) args [0];
+ string str2 = (string) args [1];
+ return str1.StartsWith (str2);
+ }
+ public override string Name { get { return "starts-with"; }}
+ }
+ internal class XPathFunctionContains : XPathFunction
+ {
+ public override XPathResultType ReturnType { get { return XPathResultType.Boolean; }}
+ public override int Minargs { get { return 2; }}
+ public override int Maxargs { get { return 2; }}
+ public override XPathResultType [] ArgTypes { get { return new XPathResultType [] { XPathResultType.String, XPathResultType.String }; }}
+ public override object TypesafeInvoke (XsltContext xsltContext, object[] args, XPathNavigator docContext)
+ {
+ string str1 = (string) args [0];
+ string str2 = (string) args [1];
+ return str1.IndexOf (str2) != -1;
+ }
+ public override string Name { get { return "contains"; }}
+ }
+ internal class XPathFunctionSubstringBefore : XPathFunction
+ {
+ public override XPathResultType ReturnType { get { return XPathResultType.String; }}
+ public override int Minargs { get { return 2; }}
+ public override int Maxargs { get { return 2; }}
+ public override XPathResultType [] ArgTypes { get { return new XPathResultType [] { XPathResultType.String, XPathResultType.String }; }}
+ public override object TypesafeInvoke (XsltContext xsltContext, object[] args, XPathNavigator docContext)
+ {
+ string str1 = (string) args [0];
+ string str2 = (string) args [1];
+ int ich = str1.IndexOf (str2);
+ if (ich <= 0)
+ return "";
+ return str1.Substring (0, ich);
+ }
+ public override string Name { get { return "substring-before"; }}
+ }
+ internal class XPathFunctionSubstringAfter : XPathFunction
+ {
+ public override XPathResultType ReturnType { get { return XPathResultType.String; }}
+ public override int Minargs { get { return 2; }}
+ public override int Maxargs { get { return 2; }}
+ public override XPathResultType [] ArgTypes { get { return new XPathResultType [] { XPathResultType.String, XPathResultType.String }; }}
+ public override object TypesafeInvoke (XsltContext xsltContext, object[] args, XPathNavigator docContext)
+ {
+ string str1 = (string) args [0];
+ string str2 = (string) args [1];
+ int ich = str1.IndexOf (str2);
+ if (ich <= 0)
+ return "";
+ return str1.Substring (ich + str2.Length);
+ }
+ public override string Name { get { return "substring-after"; }}
+ }
+ internal class XPathFunctionSubstring : XPathFunction
+ {
+ public override XPathResultType ReturnType { get { return XPathResultType.String; }}
+ public override int Minargs { get { return 2; }}
+ public override int Maxargs { get { return int.MaxValue; }}
+ public override XPathResultType [] ArgTypes { get { return new XPathResultType [] { XPathResultType.String, XPathResultType.String, XPathResultType.String }; }}
+ [MonoTODO]
+ public override object TypesafeInvoke (XsltContext xsltContext, object[] args, XPathNavigator docContext)
+ {
+ // TODO: check this, what the hell were they smoking?
+ string str = (string) args [0];
+ double ich = Math.Round ((double) args [1]) - 1;
+ if (Double.IsNaN (ich) || ich >= (double) str.Length)
+ return "";
+
+ if (args.Length == 2)
+ {
+ if (ich < 0)
+ ich = 0.0;
+ return str.Substring ((int) ich);
+ }
+ else
+ {
+ double cch = Math.Round ((double) args [2]);
+ if (Double.IsNaN (cch))
+ return "";
+ if (ich < 0.0 || cch < 0.0)
+ {
+ cch = ich + cch;
+ if (cch <= 0.0)
+ return "";
+ ich = 0.0;
+ }
+ double cchMax = (double) str.Length - ich;
+ if (cch > cchMax)
+ cch = cchMax;
+ return str.Substring ((int) ich, (int) cch);
+ }
+ }
+ public override string Name { get { return "substring"; }}
+ }
+ internal class XPathFunctionStringLength : XPathFunction
+ {
+ public override XPathResultType ReturnType { get { return XPathResultType.Number; }}
+ public override int Minargs { get { return 0; }}
+ public override int Maxargs { get { return 1; }}
+ public override XPathResultType [] ArgTypes { get { return new XPathResultType [] { XPathResultType.String }; }}
+ public override object TypesafeInvoke (XsltContext xsltContext, object[] args, XPathNavigator docContext)
+ {
+ string str;
+ if (args.Length == 1)
+ str = (string) args [0];
+ else
+ str = docContext.Value;
+ return (double) str.Length;
+ }
+ public override string Name { get { return "string-length"; }}
+ }
+ internal class XPathFunctionNormalizeSpace : XPathFunction
+ {
+ public override XPathResultType ReturnType { get { return XPathResultType.String; }}
+ public override int Minargs { get { return 0; }}
+ public override int Maxargs { get { return 1; }}
+ public override XPathResultType [] ArgTypes { get { return new XPathResultType [] { XPathResultType.String }; }}
+ [MonoTODO]
+ public override object TypesafeInvoke (XsltContext xsltContext, object[] args, XPathNavigator docContext)
+ {
+ string str;
+ if (args.Length == 1)
+ str = (string) args [0];
+ else
+ str = docContext.Value;
+ System.Text.StringBuilder sb = new System.Text.StringBuilder ();
+ bool fSpace = false;
+ foreach (char ch in str)
+ {
+ if (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n')
+ {
+ fSpace = true;
+ }
+ else
+ {
+ if (fSpace)
+ {
+ fSpace = false;
+ if (sb.Length > 0)
+ sb.Append (' ');
+ }
+ sb.Append (ch);
+ }
+ }
+ return sb.ToString ();
+ }
+ public override string Name { get { return "normalize-space"; }}
+ }
+ internal class XPathFunctionTranslate : XPathFunction
+ {
+ public override XPathResultType ReturnType { get { return XPathResultType.String; }}
+ public override int Minargs { get { return 3; }}
+ public override int Maxargs { get { return 3; }}
+ public override XPathResultType [] ArgTypes { get { return new XPathResultType [] { XPathResultType.String, XPathResultType.String, XPathResultType.String }; }}
+ [MonoTODO]
+ public override object TypesafeInvoke (XsltContext xsltContext, object[] args, XPathNavigator docContext)
+ {
+ throw new NotImplementedException ();
+ }
+ public override string Name { get { return "translate"; }}
+ }
+ internal class XPathFunctionBoolean : XPathFunction
+ {
+ public override XPathResultType ReturnType { get { return XPathResultType.Boolean; }}
+ public override int Minargs { get { return 1; }}
+ public override int Maxargs { get { return 1; }}
+ public override XPathResultType [] ArgTypes { get { return new XPathResultType [] { XPathResultType.Any }; }}
+ public override object TypesafeInvoke (XsltContext xsltContext, object[] args, XPathNavigator docContext)
+ {
+ return XPathFunctions.ToBoolean (args [0]);
+ }
+ public override string Name { get { return "boolean"; }}
+ }
+ internal class XPathFunctionNot : XPathFunction
+ {
+ public override XPathResultType ReturnType { get { return XPathResultType.Boolean; }}
+ public override int Minargs { get { return 1; }}
+ public override int Maxargs { get { return 1; }}
+ public override XPathResultType [] ArgTypes { get { return new XPathResultType [] { XPathResultType.Any }; }}
+ public override object TypesafeInvoke (XsltContext xsltContext, object[] args, XPathNavigator docContext)
+ {
+ return !(XPathFunctions.ToBoolean (args [0]));
+ }
+ public override string Name { get { return "not"; }}
+ }
+ internal class XPathFunctionTrue : XPathFunction
+ {
+ public override XPathResultType ReturnType { get { return XPathResultType.Boolean; }}
+ public override int Minargs { get { return 0; }}
+ public override int Maxargs { get { return 0; }}
+ public override XPathResultType [] ArgTypes { get { return null; }}
+ public override object TypesafeInvoke (XsltContext xsltContext, object[] args, XPathNavigator docContext)
+ {
+ return true;
+ }
+ public override string Name { get { return "true"; }}
+ }
+ internal class XPathFunctionFalse : XPathFunction
+ {
+ public override XPathResultType ReturnType { get { return XPathResultType.Boolean; }}
+ public override int Minargs { get { return 0; }}
+ public override int Maxargs { get { return 0; }}
+ public override XPathResultType [] ArgTypes { get { return null; }}
+ public override object TypesafeInvoke (XsltContext xsltContext, object[] args, XPathNavigator docContext)
+ {
+ return false;
+ }
+ public override string Name { get { return "false"; }}
+ }
+ internal class XPathFunctionLang : XPathFunction
+ {
+ public override XPathResultType ReturnType { get { return XPathResultType.Boolean; }}
+ public override int Minargs { get { return 1; }}
+ public override int Maxargs { get { return 1; }}
+ public override XPathResultType [] ArgTypes { get { return new XPathResultType [] { XPathResultType.String }; }}
+ [MonoTODO]
+ public override object TypesafeInvoke (XsltContext xsltContext, object[] args, XPathNavigator docContext)
+ {
+ throw new NotImplementedException ();
+ }
+ public override string Name { get { return "lang"; }}
+ }
+ internal class XPathFunctionNumber : XPathFunction
+ {
+ public override XPathResultType ReturnType { get { return XPathResultType.Number; }}
+ public override int Minargs { get { return 0; }}
+ public override int Maxargs { get { return 1; }}
+ public override XPathResultType [] ArgTypes { get { return new XPathResultType [] { XPathResultType.Any }; }}
+ public override object TypesafeInvoke (XsltContext xsltContext, object[] args, XPathNavigator docContext)
+ {
+ return XPathFunctions.ToNumber (args [0]);
+ }
+ public override string Name { get { return "number"; }}
+ }
+ internal class XPathFunctionSum : XPathFunction
+ {
+ public override XPathResultType ReturnType { get { return XPathResultType.Number; }}
+ public override int Minargs { get { return 1; }}
+ public override int Maxargs { get { return 1; }}
+ public override XPathResultType [] ArgTypes { get { return new XPathResultType [] { XPathResultType.NodeSet }; }}
+ [MonoTODO]
+ public override object TypesafeInvoke (XsltContext xsltContext, object[] args, XPathNavigator docContext)
+ {
+ throw new NotImplementedException ();
+ }
+ public override string Name { get { return "sum"; }}
+ }
+ internal class XPathFunctionFloor : XPathFunction
+ {
+ public override XPathResultType ReturnType { get { return XPathResultType.Number; }}
+ public override int Minargs { get { return 1; }}
+ public override int Maxargs { get { return 1; }}
+ public override XPathResultType [] ArgTypes { get { return new XPathResultType [] { XPathResultType.Number }; }}
+ public override object TypesafeInvoke (XsltContext xsltContext, object[] args, XPathNavigator docContext)
+ {
+ return Math.Floor ((double) args [0]);
+ }
+ public override string Name { get { return "floor"; }}
+ }
+ internal class XPathFunctionCeil : XPathFunction
+ {
+ public override XPathResultType ReturnType { get { return XPathResultType.Number; }}
+ public override int Minargs { get { return 1; }}
+ public override int Maxargs { get { return 1; }}
+ public override XPathResultType [] ArgTypes { get { return new XPathResultType [] { XPathResultType.Number }; }}
+ public override object TypesafeInvoke (XsltContext xsltContext, object[] args, XPathNavigator docContext)
+ {
+ return Math.Ceiling ((double) args [0]);
+ }
+ public override string Name { get { return "ceil"; }}
+ }
+ internal class XPathFunctionRound : XPathFunction
+ {
+ public override XPathResultType ReturnType { get { return XPathResultType.Number; }}
+ public override int Minargs { get { return 1; }}
+ public override int Maxargs { get { return 1; }}
+ public override XPathResultType [] ArgTypes { get { return new XPathResultType [] { XPathResultType.Number }; }}
+ public override object TypesafeInvoke (XsltContext xsltContext, object[] args, XPathNavigator docContext)
+ {
+ double arg = (double) args [0];
+ if (arg < -0.5 || arg > 0)
+ return Math.Floor (arg + 0.5);
+ return Math.Round (arg);
+ }
+ public override string Name { get { return "round"; }}
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.XPath/Expression.cs b/mcs/class/System.XML/System.Xml.XPath/Expression.cs
new file mode 100644
index 00000000000..fe1d25e9ba1
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.XPath/Expression.cs
@@ -0,0 +1,1009 @@
+//
+// System.Xml.XPath.XPathExpression support classes
+//
+// Author:
+// Piers Haken (piersh@friskit.com)
+//
+// (C) 2002 Piers Haken
+//
+using System;
+using System.IO;
+using System.Collections;
+using System.Xml;
+using System.Xml.XPath;
+using System.Xml.Xsl;
+
+namespace System.Xml.XPath
+{
+#if XPATH_DEBUG
+ internal class CompiledExpression : Test.Xml.XPath.XPathExpression
+#else
+ internal class CompiledExpression : XPathExpression
+#endif
+ {
+ protected XmlNamespaceManager _nsm;
+ protected Expression _expr;
+
+ public CompiledExpression (Expression expr)
+ {
+ _expr = expr;
+ }
+ private CompiledExpression (CompiledExpression other)
+ {
+ _nsm = other._nsm;
+ _expr = other._expr;
+ }
+#if XPATH_DEBUG
+ public override Test.Xml.XPath.XPathExpression Clone () { return new CompiledExpression (this); }
+#else
+ public override XPathExpression Clone () { return new CompiledExpression (this); }
+#endif
+
+ public override void SetContext (XmlNamespaceManager nsManager)
+ {
+ _nsm = nsManager;
+ }
+ public override String Expression { get { return _expr.ToString (); }}
+ public override XPathResultType ReturnType { get { return _expr.ReturnType; }}
+ [MonoTODO]
+ public override void AddSort (Object obj, IComparer cmp)
+ {
+ throw new NotImplementedException ();
+ }
+ [MonoTODO]
+ public override void AddSort(object obj, XmlSortOrder sortOrder, XmlCaseOrder caseOrder, string str, XmlDataType type)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public object Evaluate (BaseIterator iter)
+ {
+ try
+ {
+ return _expr.Evaluate (iter);
+ }
+ catch (XPathException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw new XPathException ("Error during evaluation", e);
+ }
+ }
+ public XPathNodeIterator EvaluateNodeSet (BaseIterator iter)
+ {
+ try
+ {
+ return _expr.EvaluateNodeSet (iter);
+ }
+ catch (XPathException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw new XPathException ("Error during evaluation", e);
+ }
+ }
+ }
+
+
+ /// <summary>
+ /// Summary description for Expression.
+ /// </summary>
+ internal abstract class Expression
+ {
+ public Expression ()
+ {
+ }
+ public abstract XPathResultType ReturnType { get; }
+ public virtual XPathResultType GetReturnType (BaseIterator iter) { return ReturnType; }
+ public virtual object Evaluate (BaseIterator iter) { return null; }
+
+ public BaseIterator EvaluateNodeSet (BaseIterator iter)
+ {
+ if (GetReturnType (iter) == XPathResultType.NodeSet)
+ return (BaseIterator) Evaluate (iter);
+ throw new XPathException ("expected nodeset: "+ToString ());
+ }
+ [MonoTODO]
+ public double EvaluateNumber (BaseIterator iter)
+ {
+ object result;
+ XPathResultType type = GetReturnType (iter);
+ if (type == XPathResultType.NodeSet)
+ {
+ result = EvaluateString (iter);
+ type = XPathResultType.String;
+ }
+ else
+ result = Evaluate (iter);
+
+ switch (type)
+ {
+ case XPathResultType.Number:
+ return (double) result;
+ case XPathResultType.Boolean:
+ return Convert.ToDouble ((bool) result);
+ case XPathResultType.String:
+ return XmlConvert.ToDouble ((string) result); // TODO: spec? convert string to number
+ default:
+ throw new XPathException ("invalid node type"); // TODO: handle other types
+ }
+ }
+ [MonoTODO]
+ public string EvaluateString (BaseIterator iter)
+ {
+ object result = Evaluate (iter);
+ switch (GetReturnType (iter))
+ {
+ case XPathResultType.Number:
+ return (string) XmlConvert.ToString ((double) result); // TODO: spec? convert number to string
+ case XPathResultType.Boolean:
+ return ((bool) result) ? "true" : "false";
+ case XPathResultType.String:
+ return (string) result;
+ case XPathResultType.NodeSet:
+ {
+ BaseIterator iterResult = (BaseIterator) result;
+ if (iterResult == null || !iterResult.MoveNext ())
+ return "";
+ return iterResult.Current.Value;
+ }
+ default:
+ throw new XPathException ("invalid node type"); // TODO: handle other types
+ }
+ }
+ [MonoTODO]
+ public bool EvaluateBoolean (BaseIterator iter)
+ {
+ object result = Evaluate (iter);
+ switch (GetReturnType (iter))
+ {
+ case XPathResultType.Number:
+ {
+ double num = (double) result;
+ return (num != 0.0 && num != -0.0 && num != Double.NaN);
+ }
+ case XPathResultType.Boolean:
+ return (bool) result;
+ case XPathResultType.String:
+ return ((string) result).Length != 0;
+ case XPathResultType.NodeSet:
+ {
+ BaseIterator iterResult = (BaseIterator) result;
+ return (iterResult != null && iterResult.MoveNext ());
+ }
+ default:
+ throw new XPathException ("invalid node type"); // TODO: handle other types
+ }
+ }
+ }
+
+ internal abstract class ExprBinary : Expression
+ {
+ protected Expression _left, _right;
+
+ public ExprBinary (Expression left, Expression right)
+ {
+ _left = left;
+ _right = right;
+ }
+ public override String ToString ()
+ {
+ return _left.ToString () + ' ' + Operator + ' ' + _right.ToString ();
+ }
+ protected abstract String Operator { get; }
+ }
+
+ internal abstract class ExprBoolean : ExprBinary
+ {
+ public ExprBoolean (Expression left, Expression right) : base (left, right) {}
+ public override XPathResultType ReturnType { get { return XPathResultType.Boolean; }}
+ }
+
+ internal class ExprOR : ExprBoolean
+ {
+ public ExprOR (Expression left, Expression right) : base (left, right) {}
+ protected override String Operator { get { return "or"; }}
+ public override object Evaluate (BaseIterator iter)
+ {
+ if (_left.EvaluateBoolean (iter))
+ return true;
+ return _right.EvaluateBoolean (iter);
+ }
+ }
+ internal class ExprAND : ExprBoolean
+ {
+ public ExprAND (Expression left, Expression right) : base (left, right) {}
+ protected override String Operator { get { return "and"; }}
+ public override object Evaluate (BaseIterator iter)
+ {
+ if (!_left.EvaluateBoolean (iter))
+ return false;
+ return _right.EvaluateBoolean (iter);
+ }
+ }
+
+ internal abstract class EqualityExpr : ExprBoolean
+ {
+ public EqualityExpr (Expression left, Expression right) : base (left, right) {}
+ [MonoTODO]
+ public override object Evaluate (BaseIterator iter)
+ {
+ XPathResultType typeL = _left.GetReturnType (iter);
+ XPathResultType typeR = _right.GetReturnType (iter);
+ if (typeL == XPathResultType.NodeSet || typeR == XPathResultType.NodeSet)
+ {
+ Expression left, right;
+ if (typeL != XPathResultType.NodeSet)
+ {
+ left = _right;
+ right = _left;
+ XPathResultType typeTmp = typeL;
+ typeL = typeR;
+ typeR = typeTmp;
+ }
+ else
+ {
+ left = _left;
+ right = _right;
+ }
+ if (typeR == XPathResultType.Boolean)
+ {
+ bool fL = left.EvaluateBoolean (iter);
+ bool fR = right.EvaluateBoolean (iter);
+ return Compare (Convert.ToDouble (fL), Convert.ToDouble (fR));
+ }
+ else
+ {
+ BaseIterator iterL = left.EvaluateNodeSet (iter);
+ if (typeR == XPathResultType.Number)
+ {
+ double dR = right.EvaluateNumber (iter);
+ while (iterL.MoveNext ())
+ if (Compare (XPathFunctions.ToNumber (iterL.Current.Value), dR))
+ return true;
+ }
+ else if (typeR == XPathResultType.String)
+ {
+ string strR = right.EvaluateString (iter);
+ while (iterL.MoveNext ())
+ if (Compare (iterL.Current.Value, strR))
+ return true;
+ }
+ else if (typeR == XPathResultType.NodeSet)
+ {
+ BaseIterator iterR = right.EvaluateNodeSet (iter);
+ ArrayList rgNodesL = new ArrayList ();
+ while (iterL.MoveNext ())
+ rgNodesL.Add (XPathFunctions.ToString (iterL.Current.Value));
+ while (iterR.MoveNext ())
+ {
+ string strR = XPathFunctions.ToString (iterR.Current.Value);
+ foreach (string strL in rgNodesL)
+ if (Compare (strL, strR))
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+ else if (typeL == XPathResultType.Boolean || typeR == XPathResultType.Boolean)
+ return Compare (_left.EvaluateBoolean (iter), _right.EvaluateBoolean (iter));
+ else if (typeL == XPathResultType.Number || typeR == XPathResultType.Number)
+ return Compare (_left.EvaluateNumber (iter), _right.EvaluateNumber (iter));
+ else
+ return Compare (_left.EvaluateString (iter), _right.EvaluateString (iter));
+ }
+ [MonoTODO]
+ public abstract bool Compare (object arg1, object arg2); // TODO: should probably have type-safe methods here
+ }
+
+ internal class ExprEQ : EqualityExpr
+ {
+ public ExprEQ (Expression left, Expression right) : base (left, right) {}
+ protected override String Operator { get { return "="; }}
+ public override bool Compare (object arg1, object arg2)
+ {
+ return arg1.Equals (arg2);
+ }
+ }
+ internal class ExprNE : EqualityExpr
+ {
+ public ExprNE (Expression left, Expression right) : base (left, right) {}
+ protected override String Operator { get { return "!="; }}
+ public override bool Compare (object arg1, object arg2)
+ {
+ return !arg1.Equals (arg2);
+ }
+ }
+
+ internal abstract class RelationalExpr : ExprBoolean
+ {
+ public RelationalExpr (Expression left, Expression right) : base (left, right) {}
+ [MonoTODO]
+ public override object Evaluate (BaseIterator iter)
+ {
+ XPathResultType typeL = _left.GetReturnType (iter);
+ XPathResultType typeR = _right.GetReturnType (iter);
+ if (typeL == XPathResultType.NodeSet || typeR == XPathResultType.NodeSet)
+ {
+ bool fReverse = false;
+ Expression left, right;
+ if (typeL != XPathResultType.NodeSet)
+ {
+ fReverse = true;
+ left = _right;
+ right = _left;
+ XPathResultType typeTmp = typeL;
+ typeL = typeR;
+ typeR = typeTmp;
+ }
+ else
+ {
+ left = _left;
+ right = _right;
+ }
+ if (typeR == XPathResultType.Boolean)
+ {
+ bool fL = left.EvaluateBoolean (iter);
+ bool fR = right.EvaluateBoolean (iter);
+ return Compare (Convert.ToDouble (fL), Convert.ToDouble (fR), fReverse);
+ }
+ else
+ {
+ BaseIterator iterL = left.EvaluateNodeSet (iter);
+ if (typeR == XPathResultType.Number || typeR == XPathResultType.String)
+ {
+ double dR = right.EvaluateNumber (iter);
+ while (iterL.MoveNext ())
+ if (Compare (XPathFunctions.ToNumber (iterL.Current.Value), dR, fReverse))
+ return true;
+ }
+ else if (typeR == XPathResultType.NodeSet)
+ {
+ BaseIterator iterR = right.EvaluateNodeSet (iter);
+ ArrayList rgNodesL = new ArrayList ();
+ while (iterL.MoveNext ())
+ rgNodesL.Add (XPathFunctions.ToNumber (iterL.Current.Value));
+ while (iterR.MoveNext ())
+ {
+ double numR = XPathFunctions.ToNumber (iterR.Current.Value);
+ foreach (double numL in rgNodesL)
+ if (Compare (numL, numR))
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+ else
+ return Compare (_left.EvaluateNumber (iter), _right.EvaluateNumber (iter));
+ }
+ public abstract bool Compare (double arg1, double arg2);
+ public bool Compare (double arg1, double arg2, bool fReverse)
+ {
+ if (fReverse)
+ return Compare (arg2, arg1);
+ else
+ return Compare (arg1, arg2);
+ }
+ }
+ internal class ExprGT : RelationalExpr
+ {
+ public ExprGT (Expression left, Expression right) : base (left, right) {}
+ protected override String Operator { get { return ">"; }}
+ public override bool Compare (double arg1, double arg2)
+ {
+ return arg1 > arg2;
+ }
+ }
+ internal class ExprGE : RelationalExpr
+ {
+ public ExprGE (Expression left, Expression right) : base (left, right) {}
+ protected override String Operator { get { return ">="; }}
+ public override bool Compare (double arg1, double arg2)
+ {
+ return arg1 >= arg2;
+ }
+ }
+ internal class ExprLT : RelationalExpr
+ {
+ public ExprLT (Expression left, Expression right) : base (left, right) {}
+ protected override String Operator { get { return "<"; }}
+ public override bool Compare (double arg1, double arg2)
+ {
+ return arg1 < arg2;
+ }
+ }
+ internal class ExprLE : RelationalExpr
+ {
+ public ExprLE (Expression left, Expression right) : base (left, right) {}
+ protected override String Operator { get { return "<="; }}
+ public override bool Compare (double arg1, double arg2)
+ {
+ return arg1 <= arg2;
+ }
+ }
+
+
+ internal abstract class ExprNumeric : ExprBinary
+ {
+ public ExprNumeric (Expression left, Expression right) : base (left, right) {}
+ public override XPathResultType ReturnType { get { return XPathResultType.Number; }}
+ }
+
+ internal class ExprPLUS : ExprNumeric
+ {
+ public ExprPLUS (Expression left, Expression right) : base (left, right) {}
+ protected override String Operator { get { return "+"; }}
+ public override object Evaluate (BaseIterator iter)
+ {
+ return _left.EvaluateNumber (iter) + _right.EvaluateNumber (iter);
+ }
+ }
+ internal class ExprMINUS : ExprNumeric
+ {
+ public ExprMINUS (Expression left, Expression right) : base (left, right) {}
+ protected override String Operator { get { return "-"; }}
+ public override object Evaluate (BaseIterator iter)
+ {
+ return _left.EvaluateNumber (iter) - _right.EvaluateNumber (iter);
+ }
+ }
+ internal class ExprMULT : ExprNumeric
+ {
+ public ExprMULT (Expression left, Expression right) : base (left, right) {}
+ protected override String Operator { get { return "*"; }}
+ public override object Evaluate (BaseIterator iter)
+ {
+ return _left.EvaluateNumber (iter) * _right.EvaluateNumber (iter);
+ }
+ }
+ internal class ExprDIV : ExprNumeric
+ {
+ public ExprDIV (Expression left, Expression right) : base (left, right) {}
+ protected override String Operator { get { return "/"; }}
+ public override object Evaluate (BaseIterator iter)
+ {
+ return _left.EvaluateNumber (iter) / _right.EvaluateNumber (iter);
+ }
+ }
+ internal class ExprMOD : ExprNumeric
+ {
+ public ExprMOD (Expression left, Expression right) : base (left, right) {}
+ protected override String Operator { get { return "%"; }}
+ [MonoTODO]
+ public override object Evaluate (BaseIterator iter)
+ {
+ return _left.EvaluateNumber (iter) % _right.EvaluateNumber (iter); // TODO: spec?
+ }
+ }
+ internal class ExprNEG : Expression
+ {
+ Expression _expr;
+ public ExprNEG (Expression expr)
+ {
+ _expr = expr;
+ }
+ public override String ToString () { return "- " + _expr.ToString (); }
+ public override XPathResultType ReturnType { get { return XPathResultType.Number; }}
+ public override object Evaluate (BaseIterator iter)
+ {
+ return - _expr.EvaluateNumber (iter);
+ }
+ }
+
+
+ internal abstract class NodeSet : Expression
+ {
+ public override XPathResultType ReturnType { get { return XPathResultType.NodeSet; }}
+ }
+ internal class ExprUNION : NodeSet
+ {
+ protected Expression _left, _right;
+ public ExprUNION (NodeSet left, NodeSet right)
+ {
+ _left = left;
+ _right = right;
+ }
+ public override String ToString () { return _left.ToString ()+ " | " + _right.ToString (); }
+ public override object Evaluate (BaseIterator iter)
+ {
+ BaseIterator iterLeft = _left.EvaluateNodeSet (iter);
+ BaseIterator iterRight = _right.EvaluateNodeSet (iter);
+ return new UnionIterator (iter, iterLeft, iterRight);
+ }
+ }
+ internal class ExprSLASH : NodeSet
+ {
+ protected Expression _left, _right;
+ public ExprSLASH (Expression left, NodeSet right)
+ {
+ _left = left;
+ _right = right;
+ }
+ public override String ToString () { return _left.ToString ()+ "/" + _right.ToString (); }
+ public override object Evaluate (BaseIterator iter)
+ {
+ BaseIterator iterLeft = _left.EvaluateNodeSet (iter);
+ return new SlashIterator (iterLeft, _right);
+ }
+ }
+ internal class ExprRoot : NodeSet
+ {
+ public override String ToString () { return ""; }
+ public override object Evaluate (BaseIterator iter)
+ {
+ XPathNavigator navRoot = iter.Current.Clone ();
+ navRoot.MoveToRoot ();
+ return new SelfIterator (navRoot, iter.Context);
+ }
+ }
+
+ internal enum Axes
+ {
+ Ancestor,
+ AncestorOrSelf,
+ Attribute,
+ Child,
+ Descendant,
+ DescendantOrSelf,
+ Following,
+ FollowingSibling,
+ Namespace,
+ Parent,
+ Preceding,
+ PrecedingSibling,
+ Self,
+ }
+
+ internal class AxisSpecifier
+ {
+ protected Axes _axis;
+ public AxisSpecifier (Axes axis)
+ {
+ _axis = axis;
+ }
+ public XPathNodeType NodeType
+ {
+ get
+ {
+ switch (_axis)
+ {
+ case Axes.Namespace:
+ return XPathNodeType.Namespace;
+ case Axes.Attribute:
+ return XPathNodeType.Attribute;
+ default:
+ return XPathNodeType.Element;
+ }
+ }
+ }
+ public override string ToString ()
+ {
+ switch (_axis)
+ {
+ case Axes.Ancestor:
+ return "ancestor";
+ case Axes.AncestorOrSelf:
+ return "ancestor-or-self";
+ case Axes.Attribute:
+ return "attribute";
+ case Axes.Child:
+ return "child";
+ case Axes.Descendant:
+ return "descendant";
+ case Axes.DescendantOrSelf:
+ return "descendant-or-self";
+ case Axes.Following:
+ return "following";
+ case Axes.FollowingSibling:
+ return "following-sibling";
+ case Axes.Namespace:
+ return "namespace";
+ case Axes.Parent:
+ return "parent";
+ case Axes.Preceding:
+ return "preceeding";
+ case Axes.PrecedingSibling:
+ return "preceeding-sibling";
+ case Axes.Self:
+ return "self";
+ default:
+ throw new IndexOutOfRangeException ();
+ }
+ }
+ public Axes Axis { get { return _axis; }}
+ public virtual BaseIterator Evaluate (BaseIterator iter)
+ {
+ switch (_axis)
+ {
+ case Axes.Ancestor:
+ return new AncestorIterator (iter);
+ case Axes.AncestorOrSelf:
+ return new AncestorOrSelfIterator (iter);
+ case Axes.Attribute:
+ return new AttributeIterator (iter);
+ case Axes.Child:
+ return new ChildIterator (iter);
+ case Axes.Descendant:
+ return new DescendantIterator (iter);
+ case Axes.DescendantOrSelf:
+ return new DescendantOrSelfIterator (iter);
+ case Axes.Following:
+ return new FollowingIterator (iter);
+ case Axes.FollowingSibling:
+ return new FollowingSiblingIterator (iter);
+ case Axes.Namespace:
+ return new NamespaceIterator (iter);
+ case Axes.Parent:
+ return new ParentIterator (iter);
+ case Axes.Preceding:
+ return new PrecedingIterator (iter);
+ case Axes.PrecedingSibling:
+ return new PrecedingSiblingIterator (iter);
+ case Axes.Self:
+ return new SelfIterator (iter);
+ default:
+ throw new IndexOutOfRangeException ();
+ }
+ }
+ }
+
+ internal abstract class NodeTest
+ {
+ protected AxisSpecifier _axis;
+ public NodeTest (AxisSpecifier axis)
+ {
+ _axis = axis;
+ }
+ public NodeTest (Axes axis)
+ {
+ _axis = new AxisSpecifier (axis);
+ }
+ public abstract bool Match (XsltContext context, XPathNavigator nav);
+ public AxisSpecifier Axis { get { return _axis; }}
+ public virtual BaseIterator Evaluate (BaseIterator iter)
+ {
+ BaseIterator iterAxis = _axis.Evaluate (iter);
+ return new AxisIterator (iterAxis, this);
+ }
+ }
+
+ internal class NodeTypeTest : NodeTest
+ {
+ protected XPathNodeType _type;
+ protected String _param;
+ public NodeTypeTest (Axes axis) : base (axis)
+ {
+ _type = _axis.NodeType;
+ }
+ public NodeTypeTest (Axes axis, XPathNodeType type) : base (axis)
+ {
+ _type = type;
+ }
+ [MonoTODO]
+ public NodeTypeTest (Axes axis, XPathNodeType type, String param) : base (axis)
+ {
+ _type = type;
+ _param = param;
+ if (param != null && type != XPathNodeType.ProcessingInstruction)
+ throw new XPathException ("No argument allowed for "+ToString (_type)+"() test"); // TODO: better description
+ }
+ public override String ToString ()
+ {
+ String strType = ToString (_type);
+ if (_type == XPathNodeType.ProcessingInstruction && _param != null)
+ strType += "('" + _param + "')";
+ else
+ strType += "()";
+
+ return _axis.ToString () + "::" + strType;
+ }
+ private static String ToString (XPathNodeType type)
+ {
+ switch (type)
+ {
+ case XPathNodeType.Comment:
+ return "comment";
+ case XPathNodeType.Text:
+ return "text";
+ case XPathNodeType.ProcessingInstruction:
+ return "processing-instruction";
+ case XPathNodeType.All:
+ case XPathNodeType.Attribute:
+ case XPathNodeType.Element:
+ return "node";
+ default:
+ throw new NotImplementedException ();
+ }
+ }
+ public override bool Match (XsltContext context, XPathNavigator nav)
+ {
+ XPathNodeType nodeType = nav.NodeType;
+ switch (_type)
+ {
+ case XPathNodeType.All:
+ return true;
+
+ case XPathNodeType.ProcessingInstruction:
+ if (nodeType != XPathNodeType.ProcessingInstruction)
+ return false;
+ if (_param != null && nav.Name != _param)
+ return false;
+ return true;
+
+ default:
+ return _type == nodeType;
+ }
+ }
+ }
+ internal class NodeNameTest : NodeTest
+ {
+ protected QName _name;
+ public NodeNameTest (Axes axis, QName name) : base (axis)
+ {
+ _name = name;
+ }
+ public override String ToString () { return _axis.ToString () + "::" + _name.ToString (); }
+ [MonoTODO]
+ public override bool Match (XsltContext context, XPathNavigator nav)
+ {
+ // must be the correct node type
+ if (nav.NodeType != _axis.NodeType)
+ return false;
+
+ if (_name.Local != null && _name.Local != "")
+ {
+ // test the local part of the name first
+ if (_name.Local != nav.LocalName)
+ return false;
+ }
+
+ // get the prefix for the given name
+ String strURI1 = "";
+ if (_name.Prefix != null)
+ {
+ strURI1 = context.LookupNamespace (_name.Prefix); // TODO: check to see if this returns null or ""
+ if (strURI1 == null)
+ throw new XPathException ("Invalid namespace prefix: "+_name.Prefix);
+ }
+
+ string strURI = nav.NamespaceURI;
+ if (strURI == null && strURI1 == "") // TODO: remove when bug #26855 fixed
+ return true;
+
+ // test the prefixes
+ return strURI1 == nav.NamespaceURI;
+ }
+ }
+
+ internal class ExprStep : NodeSet
+ {
+ protected NodeTest _test;
+ protected Expression [] _preds;
+ public ExprStep (NodeTest test, ExprPredicates preds)
+ {
+ _test = test;
+ if (preds != null)
+ _preds = preds.GetPredicates ();
+ }
+ public ExprStep (NodeTest test)
+ {
+ _test = test;
+ }
+ public override String ToString ()
+ {
+ String strExpr = _test.ToString ();
+ if (_preds != null)
+ {
+ foreach (Expression pred in _preds)
+ {
+ strExpr += '[' + pred.ToString () + ']';
+ }
+ }
+ return strExpr;
+ }
+ public override object Evaluate (BaseIterator iter)
+ {
+ BaseIterator iterStep = _test.Evaluate (iter);
+ if (_preds == null)
+ return iterStep;
+
+ return new PredicateIterator (iterStep, _preds);
+ }
+ }
+
+
+ internal class ExprPredicates
+ {
+ protected Expression _pred;
+ protected ExprPredicates _tail;
+ public ExprPredicates (Expression pred, ExprPredicates tail)
+ {
+ _pred = pred;
+ _tail = tail;
+ }
+ public ExprPredicates (Expression pred)
+ {
+ _pred = pred;
+ }
+ public Expression [] GetPredicates ()
+ {
+ ArrayList lstPreds = new ArrayList ();
+ ExprPredicates curr = this;
+ while (curr != null)
+ {
+ lstPreds.Add (curr._pred);
+ curr = curr._tail;
+ }
+ return (Expression []) lstPreds.ToArray (typeof (Expression));
+ }
+ }
+
+ internal class ExprFilter : Expression
+ {
+ protected Expression _expr;
+ protected Expression _pred;
+ public ExprFilter (Expression expr, Expression pred)
+ {
+ _expr = expr;
+ _pred = pred;
+ }
+ public override String ToString () { return "(" + _expr.ToString () + ")[" + _pred.ToString () + "]"; }
+ public override XPathResultType ReturnType { get { return XPathResultType.NodeSet; }}
+ }
+
+ internal class QName
+ {
+ protected String _prefix;
+ protected String _local;
+ public QName (String prefix, String local)
+ {
+ _prefix = prefix;
+ _local = local;
+ }
+ public override String ToString ()
+ {
+ String strLocal = (_local != null) ? _local : "*";
+ if (_prefix != null)
+ return _prefix + ':' + strLocal;
+ return strLocal;
+ }
+ public String Prefix { get { return _prefix; } }
+ public String Local { get { return _local; } }
+ }
+ internal class NCName : QName
+ {
+ public NCName (String local) : base (null, local) {}
+ }
+
+ internal class ExprNumber : Expression
+ {
+ protected double _value;
+ public ExprNumber (double value)
+ {
+ _value = value;
+ }
+ public override String ToString () { return _value.ToString (); }
+ public override XPathResultType ReturnType { get { return XPathResultType.Number; }}
+ public override object Evaluate (BaseIterator iter)
+ {
+ return _value;
+ }
+ }
+ internal class ExprLiteral : Expression
+ {
+ protected String _value;
+ public ExprLiteral (String value)
+ {
+ _value = value;
+ }
+ public override String ToString () { return "'" + _value + "'"; }
+ public override XPathResultType ReturnType { get { return XPathResultType.String; }}
+ public override object Evaluate (BaseIterator iter)
+ {
+ return _value;
+ }
+ }
+
+ internal class ExprVariable : Expression
+ {
+ protected QName _name;
+ public ExprVariable (QName name)
+ {
+ _name = name;
+ }
+ public override String ToString () { return "$" + _name.ToString (); }
+ public override XPathResultType ReturnType { get { return XPathResultType.Any; }}
+ public override XPathResultType GetReturnType (BaseIterator iter)
+ {
+ IXsltContextVariable var = iter.Context.ResolveVariable (_name.Prefix, _name.Local);
+ return var.VariableType;
+ }
+ }
+
+ internal class FunctionArguments
+ {
+ protected Expression _arg;
+ protected FunctionArguments _tail;
+ public FunctionArguments (Expression arg, FunctionArguments tail)
+ {
+ _arg = arg;
+ _tail = tail;
+ }
+ public Expression Arg
+ {
+ get { return _arg; }
+ }
+ public FunctionArguments Tail
+ {
+ get { return _tail; }
+ }
+ }
+ internal class ExprFunctionCall : Expression
+ {
+ protected QName _name;
+ protected ArrayList _args = new ArrayList ();
+ public ExprFunctionCall (String name, FunctionArguments args)
+ {
+ _name = new NCName (name);
+ while (args != null)
+ {
+ _args.Add (args.Arg);
+ args = args.Tail;
+ }
+ }
+ public override String ToString ()
+ {
+ String strArgs = "";
+ foreach (Expression arg in _args)
+ {
+ if (strArgs != "")
+ strArgs += ", ";
+ strArgs += arg.ToString ();
+ }
+ return _name.ToString () + '(' + strArgs + ')';
+ }
+ public override XPathResultType ReturnType { get { return XPathResultType.Any; }}
+ public override XPathResultType GetReturnType (BaseIterator iter)
+ {
+ IXsltContextFunction func = iter.Context.ResolveFunction (_name.Prefix, _name.Local, GetArgTypes (iter));
+ return func.ReturnType;
+ }
+ private XPathResultType [] GetArgTypes (BaseIterator iter)
+ {
+ // TODO: can we cache these? what if the types depend on the context?
+ XPathResultType [] rgArgs = new XPathResultType [_args.Count];
+ for (int iArg = 0; iArg < _args.Count; iArg++)
+ rgArgs [iArg] = ((Expression) _args [iArg]).GetReturnType (iter);
+ return rgArgs;
+ }
+ public override object Evaluate (BaseIterator iter)
+ {
+ //special-case the 'last' and 'position' functions
+ if (_args.Count == 0 && _name.Prefix == null)
+ {
+ if (_name.Local == "last")
+ {
+ return (double) iter.Count;
+ }
+ else if (_name.Local == "position")
+ {
+ return (double) iter.CurrentPosition;
+ }
+ }
+
+ XPathResultType [] rgTypes = GetArgTypes (iter);
+ //FIXME: what if func == null after next line?
+ IXsltContextFunction func = iter.Context.ResolveFunction (_name.Prefix, _name.Local, rgTypes);
+ object [] rgArgs = new object [_args.Count];
+ for (int iArg = 0; iArg < _args.Count; iArg ++)
+ rgArgs [iArg] = ((Expression) _args [iArg]).Evaluate (iter);
+ return func.Invoke (iter.Context, rgArgs, iter.Current);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.XPath/IXPathNavigable.cs b/mcs/class/System.XML/System.Xml.XPath/IXPathNavigable.cs
new file mode 100644
index 00000000000..13c9018e761
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.XPath/IXPathNavigable.cs
@@ -0,0 +1,16 @@
+//
+// System.Xml.XPath.IXPathNavigable
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2001 Jason Diamond http://injektilo.org/
+//
+
+namespace System.Xml.XPath
+{
+ public interface IXPathNavigable
+ {
+ XPathNavigator CreateNavigator ();
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.XPath/Iterator.cs b/mcs/class/System.XML/System.Xml.XPath/Iterator.cs
new file mode 100644
index 00000000000..4b8a43d98fc
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.XPath/Iterator.cs
@@ -0,0 +1,607 @@
+//
+// System.Xml.XPath.BaseIterator
+//
+// Author:
+// Piers Haken (piersh@friskit.com)
+//
+// (C) 2002 Piers Haken
+//
+
+using System;
+using System.Collections;
+using System.Xml;
+using System.Xml.XPath;
+using System.Xml.Xsl;
+
+namespace System.Xml.XPath
+{
+ internal abstract class BaseIterator : XPathNodeIterator
+ {
+ private XsltContext _context;
+
+ internal BaseIterator (BaseIterator other)
+ {
+ _context = other._context;
+ }
+ internal BaseIterator (XsltContext context)
+ {
+ _context = context;
+ }
+
+ public XsltContext Context { get { return _context; } }
+
+ public override string ToString ()
+ {
+ return Current.NodeType.ToString () + "[" + CurrentPosition + "] : " + Current.Name + " = " + Current.Value;
+ }
+ }
+
+ internal class MergedIterator : BaseIterator
+ {
+ protected ArrayList _iters = new ArrayList ();
+ protected int _pos;
+ protected int _index;
+
+ public MergedIterator (BaseIterator iter ) : base (iter) {}
+ protected MergedIterator (MergedIterator other) : base (other)
+ {
+ foreach (object obj in other._iters)
+ _iters.Add (obj);
+ _pos = other._pos;
+ _index = other._index;
+ }
+ public override XPathNodeIterator Clone () { return new MergedIterator (this); }
+
+ public void Add (BaseIterator iter)
+ {
+ _iters.Add (iter);
+ }
+
+ public override bool MoveNext ()
+ {
+ while (_index < _iters.Count)
+ {
+ BaseIterator iter = (BaseIterator) _iters [_index];
+ if (iter.MoveNext ())
+ {
+ _pos ++;
+ return true;
+ }
+ _index ++;
+ }
+ return false;
+ }
+ public override XPathNavigator Current
+ {
+ get
+ {
+ if (_index >= _iters.Count)
+ return null;
+ BaseIterator iter = (BaseIterator) _iters [_index];
+ return iter.Current;
+ }
+ }
+ public override int CurrentPosition { get { return _pos; }}
+ }
+
+ internal abstract class SimpleIterator : BaseIterator
+ {
+ protected XPathNavigator _nav;
+ protected int _pos;
+
+ public SimpleIterator (BaseIterator iter) : base (iter)
+ {
+ _nav = iter.Current.Clone ();
+ }
+ protected SimpleIterator (SimpleIterator other) : base (other)
+ {
+ _nav = other._nav.Clone ();
+ _pos = other._pos;
+ }
+ public SimpleIterator (XPathNavigator nav, XsltContext context) : base (context)
+ {
+ _nav = nav.Clone ();
+ }
+
+ public override XPathNavigator Current { get { return _nav; }}
+ public override int CurrentPosition { get { return _pos; }}
+ }
+
+ internal class SelfIterator : SimpleIterator
+ {
+ public SelfIterator (BaseIterator iter) : base (iter) {}
+ public SelfIterator (XPathNavigator nav, XsltContext context) : base (nav, context) {}
+ protected SelfIterator (SimpleIterator other) : base (other) {}
+ public override XPathNodeIterator Clone () { return new SelfIterator (this); }
+ public override bool MoveNext ()
+ {
+ if (_pos == 0)
+ {
+ _pos = 1;
+ return true;
+ }
+ return false;
+ }
+ }
+
+ internal class NullIterator : SelfIterator
+ {
+ public NullIterator (BaseIterator iter) : base (iter) {}
+ public NullIterator (XPathNavigator nav, XsltContext context) : base (nav, context) {}
+ protected NullIterator (SimpleIterator other) : base (other) {}
+ public override XPathNodeIterator Clone () { return new NullIterator (this); }
+ public override bool MoveNext ()
+ {
+ return false;
+ }
+ }
+
+ internal class ParentIterator : SimpleIterator
+ {
+ public ParentIterator (BaseIterator iter) : base (iter) {}
+ protected ParentIterator (SimpleIterator other) : base (other) {}
+ public override XPathNodeIterator Clone () { return new ParentIterator (this); }
+ public override bool MoveNext ()
+ {
+ if (_pos == 0 && _nav.MoveToParent ())
+ {
+ _pos = 1;
+ return true;
+ }
+ return false;
+ }
+ }
+
+ internal class ChildIterator : SimpleIterator
+ {
+ public ChildIterator (BaseIterator iter) : base (iter) {}
+ protected ChildIterator (SimpleIterator other) : base (other) {}
+ public override XPathNodeIterator Clone () { return new ChildIterator (this); }
+ public override bool MoveNext ()
+ {
+ bool fSuccess = (_pos == 0) ? _nav.MoveToFirstChild () : _nav.MoveToNext ();
+ if (fSuccess)
+ _pos ++;
+ return fSuccess;
+ }
+ }
+
+ internal class FollowingSiblingIterator : SimpleIterator
+ {
+ public FollowingSiblingIterator (BaseIterator iter) : base (iter) {}
+ protected FollowingSiblingIterator (SimpleIterator other) : base (other) {}
+ public override XPathNodeIterator Clone () { return new FollowingSiblingIterator (this); }
+ public override bool MoveNext ()
+ {
+ if (_nav.MoveToNext ())
+ {
+ _pos ++;
+ return true;
+ }
+ return false;
+ }
+ }
+
+ internal class PrecedingSiblingIterator : SimpleIterator
+ {
+ public PrecedingSiblingIterator (BaseIterator iter) : base (iter) {}
+ protected PrecedingSiblingIterator (SimpleIterator other) : base (other) {}
+ public override XPathNodeIterator Clone () { return new PrecedingSiblingIterator (this); }
+ public override bool MoveNext ()
+ {
+ if (_nav.MoveToPrevious ())
+ {
+ _pos ++;
+ return true;
+ }
+ return false;
+ }
+ }
+
+ internal class AncestorIterator : SimpleIterator
+ {
+ public AncestorIterator (BaseIterator iter) : base (iter) {}
+ protected AncestorIterator (SimpleIterator other) : base (other) {}
+ public override XPathNodeIterator Clone () { return new AncestorIterator (this); }
+ public override bool MoveNext ()
+ {
+ if (_nav.MoveToParent ())
+ {
+ _pos ++;
+ return true;
+ }
+ return false;
+ }
+ }
+
+ internal class AncestorOrSelfIterator : MergedIterator
+ {
+ public AncestorOrSelfIterator (BaseIterator iter) : base (iter)
+ {
+ Add (new SelfIterator (iter));
+ Add (new AncestorIterator (iter));
+ }
+ protected AncestorOrSelfIterator (MergedIterator other) : base (other) {}
+ public override XPathNodeIterator Clone () { return new AncestorOrSelfIterator (this); }
+ }
+
+ internal class DescendantIterator : SimpleIterator
+ {
+ protected int _depth;
+ public DescendantIterator (BaseIterator iter) : base (iter) {}
+ protected DescendantIterator (SimpleIterator other) : base (other) {}
+ public override XPathNodeIterator Clone () { return new DescendantIterator (this); }
+ [MonoTODO]
+ public override bool MoveNext ()
+ {
+ if (_nav.MoveToFirstChild ())
+ {
+ _depth ++;
+ _pos ++;
+ return true;
+ }
+ while (_depth != 0)
+ {
+ if (_nav.MoveToNext ())
+ {
+ _pos ++;
+ return true;
+ }
+ if (!_nav.MoveToParent ()) // should NEVER fail!
+ throw new XPathException ("unexpected depth"); // TODO: better message
+ _depth --;
+ }
+ return false;
+ }
+ }
+
+ internal class DescendantOrSelfIterator : MergedIterator
+ {
+ public DescendantOrSelfIterator (BaseIterator iter) : base (iter)
+ {
+ Add (new SelfIterator (iter));
+ Add (new DescendantIterator (iter));
+ }
+ protected DescendantOrSelfIterator (MergedIterator other) : base (other) {}
+ public override XPathNodeIterator Clone () { return new DescendantOrSelfIterator (this); }
+ }
+
+ internal class FollowingIterator : SimpleIterator
+ {
+ public FollowingIterator (BaseIterator iter) : base (iter) {}
+ protected FollowingIterator (SimpleIterator other) : base (other) {}
+ public override XPathNodeIterator Clone () { return new FollowingIterator (this); }
+ public override bool MoveNext ()
+ {
+ if (_pos == 0)
+ {
+ if (_nav.MoveToNext ())
+ {
+ _pos ++;
+ return true;
+ }
+ }
+ else
+ {
+ if (_nav.MoveToFirstChild ())
+ {
+ _pos ++;
+ return true;
+ }
+ do
+ {
+ if (_nav.MoveToNext ())
+ {
+ _pos ++;
+ return true;
+ }
+ }
+ while (_nav.MoveToParent ());
+ }
+ return false;
+ }
+ }
+
+ internal class PrecedingIterator : SimpleIterator
+ {
+ public PrecedingIterator (BaseIterator iter) : base (iter) {}
+ protected PrecedingIterator (SimpleIterator other) : base (other) {}
+ public override XPathNodeIterator Clone () { return new PrecedingIterator (this); }
+ public override bool MoveNext ()
+ {
+ if (_pos == 0)
+ {
+ if (_nav.MoveToPrevious ())
+ {
+ _pos ++;
+ return true;
+ }
+ }
+ else
+ {
+ if (_nav.MoveToFirstChild ())
+ {
+ while (_nav.MoveToNext ())
+ ;
+ _pos ++;
+ return true;
+ }
+ do
+ {
+ if (_nav.MoveToPrevious ())
+ {
+ _pos ++;
+ return true;
+ }
+ }
+ while (_nav.MoveToParent ());
+ }
+ return false;
+ }
+ }
+
+ internal class NamespaceIterator : SimpleIterator
+ {
+ public NamespaceIterator (BaseIterator iter) : base (iter) {}
+ protected NamespaceIterator (SimpleIterator other) : base (other) {}
+ public override XPathNodeIterator Clone () { return new NamespaceIterator (this); }
+ public override bool MoveNext ()
+ {
+ if (_pos == 0)
+ {
+ if (_nav.MoveToFirstNamespace ())
+ {
+ _pos ++;
+ return true;
+ }
+ }
+ else if (_nav.MoveToNextNamespace ())
+ {
+ _pos ++;
+ return true;
+ }
+ return false;
+ }
+ }
+
+ internal class AttributeIterator : SimpleIterator
+ {
+ public AttributeIterator (BaseIterator iter) : base (iter) {}
+ protected AttributeIterator (SimpleIterator other) : base (other) {}
+ public override XPathNodeIterator Clone () { return new AttributeIterator (this); }
+ public override bool MoveNext ()
+ {
+ if (_pos == 0)
+ {
+ if (_nav.MoveToFirstAttribute ())
+ {
+ _pos += 1;
+ return true;
+ }
+ }
+ else if (_nav.MoveToNextAttribute ())
+ {
+ _pos ++;
+ return true;
+ }
+ return false;
+ }
+ }
+
+ internal class AxisIterator : BaseIterator
+ {
+ protected BaseIterator _iter;
+ protected NodeTest _test;
+ protected int _pos;
+
+ public AxisIterator (BaseIterator iter, NodeTest test) : base (iter)
+ {
+ _iter = iter;
+ _test = test;
+ }
+
+ protected AxisIterator (AxisIterator other) : base (other)
+ {
+ _iter = (BaseIterator) other._iter.Clone ();
+ _test = other._test;
+ _pos = other._pos;
+ }
+ public override XPathNodeIterator Clone () { return new AxisIterator (this); }
+
+ public override bool MoveNext ()
+ {
+ while (_iter.MoveNext ())
+ {
+ if (_test.Match (Context, Current))
+ {
+ _pos ++;
+ return true;
+ }
+ }
+ return false;
+ }
+ public override XPathNavigator Current { get { return _iter.Current; }}
+ public override int CurrentPosition { get { return _pos; }}
+ }
+
+ internal class SlashIterator : BaseIterator
+ {
+ protected BaseIterator _iterLeft;
+ protected BaseIterator _iterRight;
+ protected Expression _expr;
+ protected int _pos;
+
+ public SlashIterator (BaseIterator iter, Expression expr) : base (iter)
+ {
+ _iterLeft = iter;
+ _expr = expr;
+ }
+
+ protected SlashIterator (SlashIterator other) : base (other)
+ {
+ _iterLeft = (BaseIterator) other._iterLeft.Clone ();
+ if (other._iterRight != null)
+ _iterRight = (BaseIterator) other._iterRight.Clone ();
+ _expr = other._expr;
+ _pos = other._pos;
+ }
+ public override XPathNodeIterator Clone () { return new SlashIterator (this); }
+
+ public override bool MoveNext ()
+ {
+ while (_iterRight == null || !_iterRight.MoveNext ())
+ {
+ if (!_iterLeft.MoveNext ())
+ return false;
+ _iterRight = _expr.EvaluateNodeSet (_iterLeft);
+ }
+ _pos ++;
+ return true;
+ }
+ public override XPathNavigator Current { get { return _iterRight.Current; }}
+ public override int CurrentPosition { get { return _pos; }}
+ }
+ internal class PredicateIterator : BaseIterator
+ {
+ protected BaseIterator _iter;
+ protected Expression [] _preds;
+ protected int _pos;
+
+ public PredicateIterator (BaseIterator iter, Expression [] preds) : base (iter)
+ {
+ _iter = iter;
+ _preds = preds;
+ }
+
+ protected PredicateIterator (PredicateIterator other) : base (other)
+ {
+ _iter = (BaseIterator) other._iter.Clone ();
+ _preds = other._preds;
+ _pos = other._pos;
+ }
+ public override XPathNodeIterator Clone () { return new PredicateIterator (this); }
+
+ public override bool MoveNext ()
+ {
+ while (_iter.MoveNext ())
+ {
+ bool fTrue = true;
+ foreach (Expression pred in _preds)
+ {
+ object result = pred.Evaluate ((BaseIterator) _iter.Clone ());
+ if (result is double)
+ {
+ if ((double) result != _iter.CurrentPosition)
+ {
+ fTrue = false;
+ break;
+ }
+ }
+ else if (!XPathFunctions.ToBoolean (result))
+ {
+ fTrue = false;
+ break;
+ }
+ }
+ if (fTrue)
+ return true;
+ }
+ return false;
+ }
+ public override XPathNavigator Current { get { return _iter.Current; }}
+ public override int CurrentPosition { get { return _pos; }}
+ }
+ internal class ArrayListIterator : BaseIterator
+ {
+ protected ArrayList _rgNodes;
+ protected int _pos;
+
+ public ArrayListIterator (BaseIterator iter, ArrayList rgNodes) : base (iter)
+ {
+ _rgNodes = rgNodes;
+ }
+
+ protected ArrayListIterator (ArrayListIterator other) : base (other)
+ {
+ _rgNodes = other._rgNodes;
+ _pos = other._pos;
+ }
+ public override XPathNodeIterator Clone () { return new ArrayListIterator (this); }
+
+ public override bool MoveNext ()
+ {
+ if (_pos >= _rgNodes.Count)
+ return false;
+ _pos++;
+ return true;
+ }
+ public override XPathNavigator Current { get { return (XPathNavigator) _rgNodes [_pos - 1]; }}
+ public override int CurrentPosition { get { return _pos; }}
+ }
+
+ internal class UnionIterator : BaseIterator
+ {
+ protected ArrayList _rgNodes;
+ protected BaseIterator _left, _right;
+ protected int _pos;
+
+ public UnionIterator (BaseIterator iter, BaseIterator left, BaseIterator right) : base (iter)
+ {
+ _rgNodes = new ArrayList ();
+ _left = left;
+ _right = right;
+ }
+
+ protected UnionIterator (UnionIterator other) : base (other)
+ {
+ _rgNodes = (ArrayList) other._rgNodes.Clone ();
+ _left = other._left;
+ _right = other._right;
+ _pos = other._pos;
+ }
+ public override XPathNodeIterator Clone () { return new UnionIterator (this); }
+
+ public override bool MoveNext ()
+ {
+ if (_left.MoveNext ())
+ {
+ _rgNodes.Add (_left.Current.Clone ());
+ _pos ++;
+ return true;
+ }
+
+ while (_right.MoveNext ())
+ {
+ XPathNavigator navRight = _right.Current;
+ bool fFound = false;
+ foreach (XPathNavigator navLeft in _rgNodes)
+ {
+ if (navLeft.IsSamePosition (navRight))
+ {
+ fFound = true;
+ break;
+ }
+ }
+ if (!fFound)
+ {
+ _pos ++;
+ return true;
+ }
+ }
+ return false;
+ }
+ public override XPathNavigator Current
+ {
+ get
+ {
+ if (_pos < _rgNodes.Count)
+ throw new XPathException ("bug in UnionOperator"); // TODO: better exception
+ if (_pos == _rgNodes.Count)
+ return _left.Current;
+ else
+ return _right.Current;
+ }
+ }
+ public override int CurrentPosition { get { return _pos; }}
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.XPath/Parser.cs b/mcs/class/System.XML/System.Xml.XPath/Parser.cs
new file mode 100644
index 00000000000..6914e278dc9
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.XPath/Parser.cs
@@ -0,0 +1,1107 @@
+// created by jay 0.7 (c) 1998 Axel.Schreiner@informatik.uni-osnabrueck.de
+
+ // line 2 "Parser.jay"
+// XPath parser
+//
+// Author - Piers Haken <piersh@friskit.com>
+//
+
+// TODO: FUNCTION_CALL should be a QName, not just a NCName
+// TODO: PROCESSING_INSTRUCTION's optional parameter
+// TODO: flatten argument/predicate lists in place
+
+using System;
+using System.Xml.XPath;
+//using Test.Xml.XPath;
+
+namespace Mono.Xml.XPath
+{
+ public class XPathParser
+ {
+ internal object yyparseSafe (Tokenizer tok)
+ {
+ return yyparseSafe (tok, null);
+ }
+
+ internal object yyparseSafe (Tokenizer tok, object yyDebug)
+ {
+ try
+ {
+ return yyparse (tok, yyDebug);
+ }
+ catch (XPathException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw new XPathException ("Error during parse", e);
+ }
+ }
+
+ internal object yyparseDebug (Tokenizer tok)
+ {
+ return yyparseSafe (tok, new yydebug.yyDebugSimple ());
+ }
+
+ // line 48 "-"
+
+ /** simplified error message.
+ @see <a href="#yyerror(java.lang.String, java.lang.String[])">yyerror</a>
+ */
+ public void yyerror (string message) {
+ yyerror(message, null);
+ }
+
+ /** (syntax) error message.
+ Can be overwritten to control message format.
+ @param message text to be displayed.
+ @param expected vector of acceptable tokens, if available.
+ */
+ public void yyerror (string message, string[] expected) {
+ if ((expected != null) && (expected.Length > 0)) {
+ System.Console.Write (message+", expecting");
+ for (int n = 0; n < expected.Length; ++ n)
+ System.Console.Write (" "+expected[n]);
+ System.Console.WriteLine ();
+ } else
+ System.Console.WriteLine (message);
+ }
+
+ /** debugging support, requires the package jay.yydebug.
+ Set to null to suppress debugging messages.
+ */
+ protected yydebug.yyDebug debug;
+
+ protected static int yyFinal = 25;
+ public static string [] yyRule = {
+ "$accept : Expr",
+ "Expr : OrExpr",
+ "OrExpr : AndExpr",
+ "OrExpr : OrExpr OR AndExpr",
+ "AndExpr : EqualityExpr",
+ "AndExpr : AndExpr AND EqualityExpr",
+ "EqualityExpr : RelationalExpr",
+ "EqualityExpr : EqualityExpr EQ RelationalExpr",
+ "EqualityExpr : EqualityExpr NE RelationalExpr",
+ "RelationalExpr : AdditiveExpr",
+ "RelationalExpr : RelationalExpr LT AdditiveExpr",
+ "RelationalExpr : RelationalExpr GT AdditiveExpr",
+ "RelationalExpr : RelationalExpr LE AdditiveExpr",
+ "RelationalExpr : RelationalExpr GE AdditiveExpr",
+ "AdditiveExpr : MultiplicativeExpr",
+ "AdditiveExpr : AdditiveExpr PLUS MultiplicativeExpr",
+ "AdditiveExpr : AdditiveExpr MINUS MultiplicativeExpr",
+ "MultiplicativeExpr : UnaryExpr",
+ "MultiplicativeExpr : MultiplicativeExpr ASTERISK UnaryExpr",
+ "MultiplicativeExpr : MultiplicativeExpr DIV UnaryExpr",
+ "MultiplicativeExpr : MultiplicativeExpr MOD UnaryExpr",
+ "UnaryExpr : UnionExpr",
+ "UnaryExpr : MINUS UnaryExpr",
+ "UnionExpr : PathExpr",
+ "UnionExpr : UnionExpr BAR PathExpr",
+ "PathExpr : RelativeLocationPath",
+ "PathExpr : SLASH",
+ "PathExpr : SLASH RelativeLocationPath",
+ "PathExpr : SLASH2 RelativeLocationPath",
+ "PathExpr : FilterExpr",
+ "PathExpr : FilterExpr SLASH RelativeLocationPath",
+ "PathExpr : FilterExpr SLASH2 RelativeLocationPath",
+ "RelativeLocationPath : Step",
+ "RelativeLocationPath : RelativeLocationPath SLASH Step",
+ "RelativeLocationPath : RelativeLocationPath SLASH2 Step",
+ "Step : AxisSpecifier QName ZeroOrMorePredicates",
+ "Step : AxisSpecifier ASTERISK ZeroOrMorePredicates",
+ "Step : AxisSpecifier NodeType PAREN_OPEN OptionalLiteral PAREN_CLOSE ZeroOrMorePredicates",
+ "Step : DOT",
+ "Step : DOT2",
+ "AxisSpecifier :",
+ "AxisSpecifier : AT",
+ "AxisSpecifier : AxisName COLON2",
+ "NodeType : COMMENT",
+ "NodeType : TEXT",
+ "NodeType : PROCESSING_INSTRUCTION",
+ "NodeType : NODE",
+ "FilterExpr : PrimaryExpr",
+ "FilterExpr : FilterExpr Predicate",
+ "PrimaryExpr : DOLLAR QName",
+ "PrimaryExpr : PAREN_OPEN Expr PAREN_CLOSE",
+ "PrimaryExpr : LITERAL",
+ "PrimaryExpr : NUMBER",
+ "PrimaryExpr : FunctionCall",
+ "FunctionCall : FUNCTION_NAME PAREN_OPEN OptionalArgumentList PAREN_CLOSE",
+ "OptionalArgumentList :",
+ "OptionalArgumentList : Expr OptionalArgumentListTail",
+ "OptionalArgumentListTail :",
+ "OptionalArgumentListTail : COMMA Expr OptionalArgumentListTail",
+ "ZeroOrMorePredicates :",
+ "ZeroOrMorePredicates : Predicate ZeroOrMorePredicates",
+ "Predicate : BRACKET_OPEN Expr BRACKET_CLOSE",
+ "AxisName : ANCESTOR",
+ "AxisName : ANCESTOR_OR_SELF",
+ "AxisName : ATTRIBUTE",
+ "AxisName : CHILD",
+ "AxisName : DESCENDANT",
+ "AxisName : DESCENDANT_OR_SELF",
+ "AxisName : FOLLOWING",
+ "AxisName : FOLLOWING_SIBLING",
+ "AxisName : NAMESPACE",
+ "AxisName : PARENT",
+ "AxisName : PRECEDING",
+ "AxisName : PRECEDING_SIBLING",
+ "AxisName : SELF",
+ "OptionalLiteral :",
+ "OptionalLiteral : LITERAL",
+ "QName : NCName",
+ "QName : NCName COLON ASTERISK",
+ "QName : NCName COLON NCName",
+ };
+ protected static string [] yyName = {
+ "end-of-file",null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,null,null,null,null,null,null,null,
+ null,null,null,null,null,null,null,"ERROR","EOF","SLASH","SLASH2",
+ "DOT","DOT2","COLON","COLON2","COMMA","AT","FUNCTION_NAME",
+ "BRACKET_OPEN","BRACKET_CLOSE","PAREN_OPEN","PAREN_CLOSE","AND","OR",
+ "DIV","MOD","PLUS","MINUS","ASTERISK","DOLLAR","BAR","EQ","NE","LE",
+ "GE","LT","GT","ANCESTOR","ANCESTOR_OR_SELF","ATTRIBUTE","CHILD",
+ "DESCENDANT","DESCENDANT_OR_SELF","FOLLOWING","FOLLOWING_SIBLING",
+ "NAMESPACE","PARENT","PRECEDING","PRECEDING_SIBLING","SELF","COMMENT",
+ "TEXT","PROCESSING_INSTRUCTION","NODE","NUMBER","LITERAL","NCName",
+ };
+
+ /** index-checked interface to yyName[].
+ @param token single character or %token value.
+ @return token name or [illegal] or [unknown].
+ */
+ public static string yyname (int token) {
+ if ((token < 0) || (token > yyName.Length)) return "[illegal]";
+ string name;
+ if ((name = yyName[token]) != null) return name;
+ return "[unknown]";
+ }
+
+ /** computes list of expected tokens on error by tracing the tables.
+ @param state for which to compute the list.
+ @return list of token names.
+ */
+ protected string[] yyExpecting (int state) {
+ int token, n, len = 0;
+ bool[] ok = new bool[yyName.Length];
+
+ if ((n = yySindex[state]) != 0)
+ for (token = n < 0 ? -n : 0;
+ (token < yyName.Length) && (n+token < yyTable.Length); ++ token)
+ if (yyCheck[n+token] == token && !ok[token] && yyName[token] != null) {
+ ++ len;
+ ok[token] = true;
+ }
+ if ((n = yyRindex[state]) != 0)
+ for (token = n < 0 ? -n : 0;
+ (token < yyName.Length) && (n+token < yyTable.Length); ++ token)
+ if (yyCheck[n+token] == token && !ok[token] && yyName[token] != null) {
+ ++ len;
+ ok[token] = true;
+ }
+
+ string [] result = new string[len];
+ for (n = token = 0; n < len; ++ token)
+ if (ok[token]) result[n++] = yyName[token];
+ return result;
+ }
+
+ /** the generated parser, with debugging messages.
+ Maintains a state and a value stack, currently with fixed maximum size.
+ @param yyLex scanner.
+ @param yydebug debug message writer implementing yyDebug, or null.
+ @return result of the last reduction, if any.
+ @throws yyException on irrecoverable parse error.
+ */
+ public Object yyparse (yyParser.yyInput yyLex, Object yyd)
+ {
+ this.debug = (yydebug.yyDebug)yyd;
+ return yyparse(yyLex);
+ }
+
+ /** initial size and increment of the state/value stack [default 256].
+ This is not final so that it can be overwritten outside of invocations
+ of yyparse().
+ */
+ protected int yyMax;
+
+ /** executed at the beginning of a reduce action.
+ Used as $$ = yyDefault($1), prior to the user-specified action, if any.
+ Can be overwritten to provide deep copy, etc.
+ @param first value for $1, or null.
+ @return first.
+ */
+ protected Object yyDefault (Object first) {
+ return first;
+ }
+
+ /** the generated parser.
+ Maintains a state and a value stack, currently with fixed maximum size.
+ @param yyLex scanner.
+ @return result of the last reduction, if any.
+ @throws yyException on irrecoverable parse error.
+ */
+ public Object yyparse (yyParser.yyInput yyLex)
+ {
+ if (yyMax <= 0) yyMax = 256; // initial size
+ int yyState = 0; // state stack ptr
+ int [] yyStates = new int[yyMax]; // state stack
+ Object yyVal = null; // value stack ptr
+ Object [] yyVals = new Object[yyMax]; // value stack
+ int yyToken = -1; // current input
+ int yyErrorFlag = 0; // #tks to shift
+
+ int yyTop = 0;
+ goto skip;
+ yyLoop:
+ yyTop++;
+ skip:
+ for (;; ++ yyTop) {
+ if (yyTop >= yyStates.Length) { // dynamically increase
+ int[] i = new int[yyStates.Length+yyMax];
+ yyStates.CopyTo (i, 0);
+ yyStates = i;
+ Object[] o = new Object[yyVals.Length+yyMax];
+ yyVals.CopyTo (o, 0);
+ yyVals = o;
+ }
+ yyStates[yyTop] = yyState;
+ yyVals[yyTop] = yyVal;
+ if (debug != null) debug.push(yyState, yyVal);
+
+ yyDiscarded: for (;;) { // discarding a token does not change stack
+ int yyN;
+ if ((yyN = yyDefRed[yyState]) == 0) { // else [default] reduce (yyN)
+ if (yyToken < 0) {
+ yyToken = yyLex.advance() ? yyLex.token() : 0;
+ if (debug != null)
+ debug.lex(yyState, yyToken, yyname(yyToken), yyLex.value());
+ }
+ if ((yyN = yySindex[yyState]) != 0 && ((yyN += yyToken) >= 0)
+ && (yyN < yyTable.Length) && (yyCheck[yyN] == yyToken)) {
+ if (debug != null)
+ debug.shift(yyState, yyTable[yyN], yyErrorFlag-1);
+ yyState = yyTable[yyN]; // shift to yyN
+ yyVal = yyLex.value();
+ yyToken = -1;
+ if (yyErrorFlag > 0) -- yyErrorFlag;
+ goto yyLoop;
+ }
+ if ((yyN = yyRindex[yyState]) != 0 && (yyN += yyToken) >= 0
+ && yyN < yyTable.Length && yyCheck[yyN] == yyToken)
+ yyN = yyTable[yyN]; // reduce (yyN)
+ else
+ switch (yyErrorFlag) {
+
+ case 0:
+ yyerror("syntax error", yyExpecting(yyState));
+ if (debug != null) debug.error("syntax error");
+ goto case 1;
+ case 1: case 2:
+ yyErrorFlag = 3;
+ do {
+ if ((yyN = yySindex[yyStates[yyTop]]) != 0
+ && (yyN += Token.yyErrorCode) >= 0 && yyN < yyTable.Length
+ && yyCheck[yyN] == Token.yyErrorCode) {
+ if (debug != null)
+ debug.shift(yyStates[yyTop], yyTable[yyN], 3);
+ yyState = yyTable[yyN];
+ yyVal = yyLex.value();
+ goto yyLoop;
+ }
+ if (debug != null) debug.pop(yyStates[yyTop]);
+ } while (-- yyTop >= 0);
+ if (debug != null) debug.reject();
+ throw new yyParser.yyException("irrecoverable syntax error");
+
+ case 3:
+ if (yyToken == 0) {
+ if (debug != null) debug.reject();
+ throw new yyParser.yyException("irrecoverable syntax error at end-of-file");
+ }
+ if (debug != null)
+ debug.discard(yyState, yyToken, yyname(yyToken),
+ yyLex.value());
+ yyToken = -1;
+ goto yyDiscarded; // leave stack alone
+ }
+ }
+ int yyV = yyTop + 1-yyLen[yyN];
+ if (debug != null)
+ debug.reduce(yyState, yyStates[yyV-1], yyN, yyRule[yyN], yyLen[yyN]);
+ yyVal = yyDefault(yyV > yyTop ? null : yyVals[yyV]);
+ switch (yyN) {
+case 3:
+ // line 133 "Parser.jay"
+ {
+ yyVal = new ExprOR ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
+ }
+ break;
+case 5:
+ // line 141 "Parser.jay"
+ {
+ yyVal = new ExprAND ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
+ }
+ break;
+case 7:
+ // line 149 "Parser.jay"
+ {
+ yyVal = new ExprEQ ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
+ }
+ break;
+case 8:
+ // line 153 "Parser.jay"
+ {
+ yyVal = new ExprNE ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
+ }
+ break;
+case 10:
+ // line 161 "Parser.jay"
+ {
+ yyVal = new ExprLT ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
+ }
+ break;
+case 11:
+ // line 165 "Parser.jay"
+ {
+ yyVal = new ExprGT ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
+ }
+ break;
+case 12:
+ // line 169 "Parser.jay"
+ {
+ yyVal = new ExprLE ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
+ }
+ break;
+case 13:
+ // line 173 "Parser.jay"
+ {
+ yyVal = new ExprGE ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
+ }
+ break;
+case 15:
+ // line 181 "Parser.jay"
+ {
+ yyVal = new ExprPLUS ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
+ }
+ break;
+case 16:
+ // line 185 "Parser.jay"
+ {
+ yyVal = new ExprMINUS ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
+ }
+ break;
+case 18:
+ // line 193 "Parser.jay"
+ {
+ yyVal = new ExprMULT ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
+ }
+ break;
+case 19:
+ // line 197 "Parser.jay"
+ {
+ yyVal = new ExprDIV ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
+ }
+ break;
+case 20:
+ // line 201 "Parser.jay"
+ {
+ yyVal = new ExprMOD ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
+ }
+ break;
+case 22:
+ // line 209 "Parser.jay"
+ {
+ yyVal = new ExprNEG ((Expression) yyVals[0+yyTop]);
+ }
+ break;
+case 24:
+ // line 217 "Parser.jay"
+ {
+ yyVal = new ExprUNION ((NodeSet) yyVals[-2+yyTop], (NodeSet) yyVals[0+yyTop]);
+ }
+ break;
+case 26:
+ // line 225 "Parser.jay"
+ {
+ yyVal = new ExprRoot ();
+ }
+ break;
+case 27:
+ // line 229 "Parser.jay"
+ {
+ yyVal = new ExprSLASH (new ExprRoot (), (NodeSet) yyVals[0+yyTop]);
+ }
+ break;
+case 28:
+ // line 233 "Parser.jay"
+ {
+ ExprStep exprStep = new ExprStep (new NodeTypeTest (Axes.DescendantOrSelf, XPathNodeType.All));
+ yyVal = new ExprSLASH (new ExprSLASH (new ExprRoot (), exprStep), (NodeSet) yyVals[0+yyTop]);
+ }
+ break;
+case 30:
+ // line 239 "Parser.jay"
+ {
+ yyVal = new ExprSLASH ((Expression) yyVals[-2+yyTop], (NodeSet) yyVals[0+yyTop]);
+ }
+ break;
+case 31:
+ // line 243 "Parser.jay"
+ {
+ ExprStep exprStep = new ExprStep (new NodeTypeTest (Axes.DescendantOrSelf, XPathNodeType.All));
+ yyVal = new ExprSLASH (new ExprSLASH ((Expression) yyVals[-2+yyTop], exprStep), (NodeSet) yyVals[0+yyTop]);
+ }
+ break;
+case 33:
+ // line 252 "Parser.jay"
+ {
+ yyVal = new ExprSLASH ((Expression) yyVals[-2+yyTop], (NodeSet) yyVals[0+yyTop]);
+ }
+ break;
+case 34:
+ // line 256 "Parser.jay"
+ {
+ ExprStep exprStep = new ExprStep (new NodeTypeTest (Axes.DescendantOrSelf, XPathNodeType.All));
+ yyVal = new ExprSLASH (new ExprSLASH ((Expression) yyVals[-2+yyTop], exprStep), (NodeSet) yyVals[0+yyTop]);
+ }
+ break;
+case 35:
+ // line 264 "Parser.jay"
+ {
+ yyVal = new ExprStep (new NodeNameTest ((Axes) yyVals[-2+yyTop], (QName) yyVals[-1+yyTop]), (ExprPredicates) yyVals[0+yyTop]);
+ }
+ break;
+case 36:
+ // line 268 "Parser.jay"
+ {
+ yyVal = new ExprStep (new NodeTypeTest ((Axes) yyVals[-2+yyTop]), (ExprPredicates) yyVals[0+yyTop]);
+ }
+ break;
+case 37:
+ // line 272 "Parser.jay"
+ {
+ yyVal = new ExprStep (new NodeTypeTest ((Axes) yyVals[-5+yyTop], (XPathNodeType) yyVals[-4+yyTop], (String) yyVals[-2+yyTop]), (ExprPredicates) yyVals[0+yyTop]);
+ }
+ break;
+case 38:
+ // line 276 "Parser.jay"
+ {
+ yyVal = new ExprStep (new NodeTypeTest (Axes.Self, XPathNodeType.All));
+ }
+ break;
+case 39:
+ // line 280 "Parser.jay"
+ {
+ yyVal = new ExprStep (new NodeTypeTest (Axes.Parent, XPathNodeType.All));
+ }
+ break;
+case 40:
+ // line 287 "Parser.jay"
+ {
+ yyVal = Axes.Child;
+ }
+ break;
+case 41:
+ // line 291 "Parser.jay"
+ {
+ yyVal = Axes.Attribute;
+ }
+ break;
+case 42:
+ // line 295 "Parser.jay"
+ {
+ yyVal = yyVals[-1+yyTop];
+ }
+ break;
+case 43:
+ // line 301 "Parser.jay"
+ { yyVal = XPathNodeType.Comment; }
+ break;
+case 44:
+ // line 302 "Parser.jay"
+ { yyVal = XPathNodeType.Text; }
+ break;
+case 45:
+ // line 303 "Parser.jay"
+ { yyVal = XPathNodeType.ProcessingInstruction; }
+ break;
+case 46:
+ // line 304 "Parser.jay"
+ { yyVal = XPathNodeType.All; }
+ break;
+case 48:
+ // line 311 "Parser.jay"
+ {
+ yyVal = new ExprFilter ((Expression) yyVals[-1+yyTop], (Expression) yyVals[0+yyTop]);
+ }
+ break;
+case 49:
+ // line 318 "Parser.jay"
+ {
+ yyVal = new ExprVariable ((QName) yyVals[0+yyTop]);
+ }
+ break;
+case 50:
+ // line 322 "Parser.jay"
+ {
+ yyVal = yyVals[-1+yyTop];
+ }
+ break;
+case 51:
+ // line 326 "Parser.jay"
+ {
+ yyVal = new ExprLiteral ((String) yyVals[0+yyTop]);
+ }
+ break;
+case 52:
+ // line 330 "Parser.jay"
+ {
+ yyVal = new ExprNumber ((double) yyVals[0+yyTop]);
+ }
+ break;
+case 54:
+ // line 338 "Parser.jay"
+ {
+ yyVal = new ExprFunctionCall ((String) yyVals[-3+yyTop], (FunctionArguments) yyVals[-1+yyTop]);
+ }
+ break;
+case 56:
+ // line 346 "Parser.jay"
+ {
+ yyVal = new FunctionArguments ((Expression) yyVals[-1+yyTop], (FunctionArguments) yyVals[0+yyTop]);
+ }
+ break;
+case 58:
+ // line 354 "Parser.jay"
+ {
+ yyVal = new FunctionArguments ((Expression) yyVals[-1+yyTop], (FunctionArguments) yyVals[0+yyTop]);
+ }
+ break;
+case 60:
+ // line 363 "Parser.jay"
+ {
+ yyVal = new ExprPredicates ((Expression) yyVals[-1+yyTop], (ExprPredicates) yyVals[0+yyTop]);
+ }
+ break;
+case 61:
+ // line 370 "Parser.jay"
+ {
+ yyVal = yyVals[-1+yyTop];
+ }
+ break;
+case 62:
+ // line 376 "Parser.jay"
+ { yyVal = Axes.Ancestor; }
+ break;
+case 63:
+ // line 377 "Parser.jay"
+ { yyVal = Axes.AncestorOrSelf; }
+ break;
+case 64:
+ // line 378 "Parser.jay"
+ { yyVal = Axes.Attribute; }
+ break;
+case 65:
+ // line 379 "Parser.jay"
+ { yyVal = Axes.Child; }
+ break;
+case 66:
+ // line 380 "Parser.jay"
+ { yyVal = Axes.Descendant; }
+ break;
+case 67:
+ // line 381 "Parser.jay"
+ { yyVal = Axes.DescendantOrSelf; }
+ break;
+case 68:
+ // line 382 "Parser.jay"
+ { yyVal = Axes.Following; }
+ break;
+case 69:
+ // line 383 "Parser.jay"
+ { yyVal = Axes.FollowingSibling; }
+ break;
+case 70:
+ // line 384 "Parser.jay"
+ { yyVal = Axes.Namespace; }
+ break;
+case 71:
+ // line 385 "Parser.jay"
+ { yyVal = Axes.Parent; }
+ break;
+case 72:
+ // line 386 "Parser.jay"
+ { yyVal = Axes.Preceding; }
+ break;
+case 73:
+ // line 387 "Parser.jay"
+ { yyVal = Axes.PrecedingSibling; }
+ break;
+case 74:
+ // line 388 "Parser.jay"
+ { yyVal = Axes.Self; }
+ break;
+case 77:
+ // line 398 "Parser.jay"
+ {
+ yyVal = new NCName ((String) yyVals[0+yyTop]);
+ }
+ break;
+case 78:
+ // line 402 "Parser.jay"
+ {
+ yyVal = new QName ((String) yyVals[-2+yyTop], null);
+ }
+ break;
+case 79:
+ // line 406 "Parser.jay"
+ {
+ yyVal = new QName ((String) yyVals[-2+yyTop], (String) yyVals[0+yyTop]);
+ }
+ break;
+ // line 683 "-"
+ }
+ yyTop -= yyLen[yyN];
+ yyState = yyStates[yyTop];
+ int yyM = yyLhs[yyN];
+ if (yyState == 0 && yyM == 0) {
+ if (debug != null) debug.shift(0, yyFinal);
+ yyState = yyFinal;
+ if (yyToken < 0) {
+ yyToken = yyLex.advance() ? yyLex.token() : 0;
+ if (debug != null)
+ debug.lex(yyState, yyToken,yyname(yyToken), yyLex.value());
+ }
+ if (yyToken == 0) {
+ if (debug != null) debug.accept(yyVal);
+ return yyVal;
+ }
+ goto yyLoop;
+ }
+ if (((yyN = yyGindex[yyM]) != 0) && ((yyN += yyState) >= 0)
+ && (yyN < yyTable.Length) && (yyCheck[yyN] == yyState))
+ yyState = yyTable[yyN];
+ else
+ yyState = yyDgoto[yyM];
+ if (debug != null) debug.shift(yyStates[yyTop], yyState);
+ goto yyLoop;
+ }
+ }
+ }
+
+ static short [] yyLhs = { -1,
+ 0, 1, 1, 2, 2, 3, 3, 3, 4, 4,
+ 4, 4, 4, 5, 5, 5, 6, 6, 6, 6,
+ 7, 7, 8, 8, 9, 9, 9, 9, 9, 9,
+ 9, 10, 10, 10, 12, 12, 12, 12, 12, 13,
+ 13, 13, 16, 16, 16, 16, 11, 11, 19, 19,
+ 19, 19, 19, 21, 22, 22, 23, 23, 15, 15,
+ 20, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 17, 17, 14, 14, 14,
+ };
+ static short [] yyLen = { 2,
+ 1, 1, 3, 1, 3, 1, 3, 3, 1, 3,
+ 3, 3, 3, 1, 3, 3, 1, 3, 3, 3,
+ 1, 2, 1, 3, 1, 1, 2, 2, 1, 3,
+ 3, 1, 3, 3, 3, 3, 6, 1, 1, 0,
+ 1, 2, 1, 1, 1, 1, 1, 2, 2, 3,
+ 1, 1, 1, 4, 0, 2, 0, 3, 0, 2,
+ 3, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 0, 1, 1, 3, 3,
+ };
+ static short [] yyDefRed = { 0,
+ 0, 0, 38, 39, 41, 0, 0, 0, 0, 62,
+ 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
+ 73, 74, 52, 51, 0, 0, 0, 0, 0, 0,
+ 0, 17, 0, 23, 0, 0, 32, 0, 0, 47,
+ 53, 0, 0, 0, 0, 22, 0, 49, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 48, 0, 43,
+ 44, 45, 46, 0, 0, 42, 0, 0, 50, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 19, 20, 18, 24, 33, 34, 0, 0, 0, 36,
+ 0, 35, 0, 0, 56, 54, 78, 79, 61, 60,
+ 76, 0, 0, 0, 58, 37,
+ };
+ protected static short [] yyDgoto = { 25,
+ 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 48, 100, 75, 112, 39, 40, 101,
+ 41, 78, 105,
+ };
+ protected static short [] yySindex = { -188,
+ -85, -85, 0, 0, 0, -258, -188, -188, -297, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, -215, -257, -253, -265, -245,
+ -261, 0, -221, 0, -218, -252, 0, -256, -203, 0,
+ 0, -218, -218, -188, -209, 0, -200, 0, -188, -188,
+ -188, -188, -188, -188, -188, -188, -188, -188, -188, -188,
+ -188, -130, -85, -85, -85, -85, -188, 0, -204, 0,
+ 0, 0, 0, -204, -195, 0, -199, -194, 0, -268,
+ -257, -253, -265, -265, -245, -245, -245, -245, -261, -261,
+ 0, 0, 0, 0, 0, 0, -218, -218, -202, 0,
+ -204, 0, -229, -188, 0, 0, 0, 0, 0, 0,
+ 0, -191, -199, -204, 0, 0,
+ };
+ protected static short [] yyRindex = { -182,
+ 1, -182, 0, 0, 0, 0, -182, -182, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 253, 65, 23, 435, 319,
+ 244, 0, 222, 0, 90, 112, 0, 0, 0, 0,
+ 0, 134, 156, -267, 0, 0, 40, 0, -182, -182,
+ -182, -182, -182, -182, -182, -182, -182, -182, -182, -182,
+ -182, -182, -182, -182, -182, -182, -182, 0, 68, 0,
+ 0, 0, 0, 68, 0, 0, -190, 0, 0, 0,
+ 510, 501, 457, 479, 347, 369, 391, 413, 267, 289,
+ 0, 0, 0, 0, 0, 0, 178, 200, 0, 0,
+ 68, 0, -187, -182, 0, 0, 0, 0, 0, 0,
+ 0, 0, -190, 68, 0, 0,
+ };
+ protected static short [] yyGindex = { -7,
+ 0, 34, 35, -3, -29, -1, -6, 0, 24, 4,
+ 0, -12, 0, 49, -71, 0, 0, 0, 0, 52,
+ 0, 0, -21,
+ };
+ protected static short [] yyTable = { 45,
+ 26, 46, 102, 55, 42, 43, 65, 66, 47, 107,
+ 40, 44, 59, 60, 50, 67, 61, 53, 54, 55,
+ 56, 69, 4, 85, 86, 87, 88, 51, 52, 110,
+ 57, 58, 40, 40, 40, 40, 77, 108, 40, 77,
+ 63, 64, 116, 70, 71, 72, 73, 83, 84, 47,
+ 95, 96, 91, 92, 93, 89, 90, 49, 62, 99,
+ 76, 79, 80, 67, 2, 104, 109, 59, 97, 98,
+ 1, 2, 3, 4, 103, 111, 106, 5, 6, 114,
+ 57, 7, 81, 75, 82, 94, 74, 68, 8, 25,
+ 9, 115, 0, 0, 0, 40, 113, 0, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
+ 22, 29, 0, 0, 0, 23, 24, 40, 40, 40,
+ 40, 0, 0, 40, 0, 0, 0, 0, 1, 2,
+ 3, 4, 0, 27, 0, 5, 6, 0, 0, 7,
+ 0, 0, 0, 0, 0, 0, 0, 0, 9, 0,
+ 0, 0, 0, 0, 0, 28, 10, 11, 12, 13,
+ 14, 15, 16, 17, 18, 19, 20, 21, 22, 0,
+ 0, 0, 0, 23, 24, 3, 4, 30, 0, 0,
+ 5, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 31,
+ 0, 10, 11, 12, 13, 14, 15, 16, 17, 18,
+ 19, 20, 21, 22, 0, 0, 0, 0, 0, 0,
+ 0, 21, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 14, 0, 0, 0, 0, 0, 0,
+ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 26, 15, 0, 0, 26,
+ 0, 26, 26, 26, 26, 26, 26, 26, 26, 0,
+ 26, 26, 26, 26, 26, 26, 26, 4, 16, 0,
+ 0, 4, 0, 4, 4, 4, 0, 0, 77, 77,
+ 40, 40, 40, 40, 77, 0, 40, 77, 77, 0,
+ 77, 77, 77, 77, 77, 77, 77, 77, 9, 77,
+ 77, 77, 77, 77, 77, 77, 59, 59, 0, 2,
+ 0, 0, 59, 2, 0, 2, 59, 2, 59, 59,
+ 59, 59, 59, 59, 59, 59, 12, 59, 59, 59,
+ 59, 59, 59, 59, 25, 0, 0, 0, 25, 0,
+ 25, 25, 25, 25, 25, 25, 25, 25, 13, 25,
+ 25, 25, 25, 25, 25, 25, 29, 0, 0, 0,
+ 29, 0, 29, 29, 29, 29, 29, 29, 29, 29,
+ 10, 29, 29, 29, 29, 29, 29, 29, 27, 0,
+ 0, 0, 27, 0, 27, 27, 27, 27, 27, 27,
+ 27, 27, 11, 27, 27, 27, 27, 27, 27, 27,
+ 28, 0, 0, 0, 28, 0, 28, 28, 28, 28,
+ 28, 28, 28, 28, 6, 28, 28, 28, 28, 28,
+ 28, 28, 30, 0, 0, 0, 30, 0, 30, 30,
+ 30, 30, 30, 30, 30, 30, 7, 30, 30, 30,
+ 30, 30, 30, 30, 31, 0, 0, 0, 31, 0,
+ 31, 31, 31, 31, 31, 31, 31, 31, 8, 31,
+ 31, 31, 31, 31, 31, 31, 21, 0, 0, 0,
+ 21, 0, 21, 21, 21, 21, 21, 21, 21, 21,
+ 5, 0, 21, 21, 21, 21, 21, 21, 14, 3,
+ 0, 0, 14, 0, 14, 14, 14, 1, 0, 14,
+ 14, 1, 0, 1, 14, 14, 14, 14, 14, 14,
+ 0, 15, 0, 0, 0, 15, 0, 15, 15, 15,
+ 0, 0, 15, 15, 0, 0, 0, 15, 15, 15,
+ 15, 15, 15, 16, 0, 0, 0, 16, 0, 16,
+ 16, 16, 0, 0, 16, 16, 0, 0, 0, 16,
+ 16, 16, 16, 16, 16, 0, 0, 0, 0, 0,
+ 0, 0, 0, 9, 0, 0, 0, 9, 0, 9,
+ 9, 9, 0, 0, 0, 0, 0, 0, 0, 9,
+ 9, 9, 9, 9, 9, 0, 0, 0, 0, 0,
+ 0, 12, 0, 0, 0, 12, 0, 12, 12, 12,
+ 0, 0, 0, 0, 0, 0, 0, 12, 12, 12,
+ 12, 12, 12, 13, 0, 0, 0, 13, 0, 13,
+ 13, 13, 0, 0, 0, 0, 0, 0, 0, 13,
+ 13, 13, 13, 13, 13, 10, 0, 0, 0, 10,
+ 0, 10, 10, 10, 0, 0, 0, 0, 0, 0,
+ 0, 10, 10, 10, 10, 10, 10, 11, 0, 0,
+ 0, 11, 0, 11, 11, 11, 0, 0, 0, 0,
+ 0, 0, 0, 11, 11, 11, 11, 11, 11, 6,
+ 0, 0, 0, 6, 0, 6, 6, 6, 0, 0,
+ 0, 0, 0, 0, 0, 6, 6, 0, 0, 0,
+ 0, 7, 0, 0, 0, 7, 0, 7, 7, 7,
+ 0, 0, 0, 0, 0, 0, 0, 7, 7, 0,
+ 0, 0, 0, 8, 0, 0, 0, 8, 0, 8,
+ 8, 8, 0, 0, 0, 0, 0, 0, 0, 8,
+ 8, 0, 0, 0, 0, 5, 0, 0, 0, 5,
+ 0, 5, 5, 5, 3, 0, 0, 0, 3, 0,
+ 3, 0, 3,
+ };
+ protected static short [] yyCheck = { 7,
+ 0, 8, 74, 271, 1, 2, 259, 260, 306, 278,
+ 278, 270, 274, 275, 272, 268, 278, 283, 284, 285,
+ 286, 278, 0, 53, 54, 55, 56, 281, 282, 101,
+ 276, 277, 300, 301, 302, 303, 44, 306, 306, 0,
+ 259, 260, 114, 300, 301, 302, 303, 51, 52, 306,
+ 63, 64, 59, 60, 61, 57, 58, 273, 280, 67,
+ 264, 271, 263, 268, 0, 265, 269, 0, 65, 66,
+ 259, 260, 261, 262, 270, 305, 271, 266, 267, 271,
+ 271, 270, 49, 271, 50, 62, 38, 36, 277, 0,
+ 279, 113, -1, -1, -1, 278, 104, -1, 287, 288,
+ 289, 290, 291, 292, 293, 294, 295, 296, 297, 298,
+ 299, 0, -1, -1, -1, 304, 305, 300, 301, 302,
+ 303, -1, -1, 306, -1, -1, -1, -1, 259, 260,
+ 261, 262, -1, 0, -1, 266, 267, -1, -1, 270,
+ -1, -1, -1, -1, -1, -1, -1, -1, 279, -1,
+ -1, -1, -1, -1, -1, 0, 287, 288, 289, 290,
+ 291, 292, 293, 294, 295, 296, 297, 298, 299, -1,
+ -1, -1, -1, 304, 305, 261, 262, 0, -1, -1,
+ 266, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, 0,
+ -1, 287, 288, 289, 290, 291, 292, 293, 294, 295,
+ 296, 297, 298, 299, -1, -1, -1, -1, -1, -1,
+ -1, 0, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, 0, -1, -1, -1, -1, -1, -1,
+ -1, -1, 0, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 265, 0, -1, -1, 269,
+ -1, 271, 272, 273, 274, 275, 276, 277, 278, -1,
+ 280, 281, 282, 283, 284, 285, 286, 265, 0, -1,
+ -1, 269, -1, 271, 272, 273, -1, -1, 259, 260,
+ 300, 301, 302, 303, 265, -1, 306, 268, 269, -1,
+ 271, 272, 273, 274, 275, 276, 277, 278, 0, 280,
+ 281, 282, 283, 284, 285, 286, 259, 260, -1, 265,
+ -1, -1, 265, 269, -1, 271, 269, 273, 271, 272,
+ 273, 274, 275, 276, 277, 278, 0, 280, 281, 282,
+ 283, 284, 285, 286, 265, -1, -1, -1, 269, -1,
+ 271, 272, 273, 274, 275, 276, 277, 278, 0, 280,
+ 281, 282, 283, 284, 285, 286, 265, -1, -1, -1,
+ 269, -1, 271, 272, 273, 274, 275, 276, 277, 278,
+ 0, 280, 281, 282, 283, 284, 285, 286, 265, -1,
+ -1, -1, 269, -1, 271, 272, 273, 274, 275, 276,
+ 277, 278, 0, 280, 281, 282, 283, 284, 285, 286,
+ 265, -1, -1, -1, 269, -1, 271, 272, 273, 274,
+ 275, 276, 277, 278, 0, 280, 281, 282, 283, 284,
+ 285, 286, 265, -1, -1, -1, 269, -1, 271, 272,
+ 273, 274, 275, 276, 277, 278, 0, 280, 281, 282,
+ 283, 284, 285, 286, 265, -1, -1, -1, 269, -1,
+ 271, 272, 273, 274, 275, 276, 277, 278, 0, 280,
+ 281, 282, 283, 284, 285, 286, 265, -1, -1, -1,
+ 269, -1, 271, 272, 273, 274, 275, 276, 277, 278,
+ 0, -1, 281, 282, 283, 284, 285, 286, 265, 0,
+ -1, -1, 269, -1, 271, 272, 273, 265, -1, 276,
+ 277, 269, -1, 271, 281, 282, 283, 284, 285, 286,
+ -1, 265, -1, -1, -1, 269, -1, 271, 272, 273,
+ -1, -1, 276, 277, -1, -1, -1, 281, 282, 283,
+ 284, 285, 286, 265, -1, -1, -1, 269, -1, 271,
+ 272, 273, -1, -1, 276, 277, -1, -1, -1, 281,
+ 282, 283, 284, 285, 286, -1, -1, -1, -1, -1,
+ -1, -1, -1, 265, -1, -1, -1, 269, -1, 271,
+ 272, 273, -1, -1, -1, -1, -1, -1, -1, 281,
+ 282, 283, 284, 285, 286, -1, -1, -1, -1, -1,
+ -1, 265, -1, -1, -1, 269, -1, 271, 272, 273,
+ -1, -1, -1, -1, -1, -1, -1, 281, 282, 283,
+ 284, 285, 286, 265, -1, -1, -1, 269, -1, 271,
+ 272, 273, -1, -1, -1, -1, -1, -1, -1, 281,
+ 282, 283, 284, 285, 286, 265, -1, -1, -1, 269,
+ -1, 271, 272, 273, -1, -1, -1, -1, -1, -1,
+ -1, 281, 282, 283, 284, 285, 286, 265, -1, -1,
+ -1, 269, -1, 271, 272, 273, -1, -1, -1, -1,
+ -1, -1, -1, 281, 282, 283, 284, 285, 286, 265,
+ -1, -1, -1, 269, -1, 271, 272, 273, -1, -1,
+ -1, -1, -1, -1, -1, 281, 282, -1, -1, -1,
+ -1, 265, -1, -1, -1, 269, -1, 271, 272, 273,
+ -1, -1, -1, -1, -1, -1, -1, 281, 282, -1,
+ -1, -1, -1, 265, -1, -1, -1, 269, -1, 271,
+ 272, 273, -1, -1, -1, -1, -1, -1, -1, 281,
+ 282, -1, -1, -1, -1, 265, -1, -1, -1, 269,
+ -1, 271, 272, 273, 265, -1, -1, -1, 269, -1,
+ 271, -1, 273,
+ };
+
+ // line 412 "Parser.jay"
+ }
+ // line 950 "-"
+namespace yydebug {
+ using System;
+ public interface yyDebug {
+ void push (int state, Object value);
+ void lex (int state, int token, string name, Object value);
+ void shift (int from, int to, int errorFlag);
+ void pop (int state);
+ void discard (int state, int token, string name, Object value);
+ void reduce (int from, int to, int rule, string text, int len);
+ void shift (int from, int to);
+ void accept (Object value);
+ void error (string message);
+ void reject ();
+ }
+
+ class yyDebugSimple : yyDebug {
+ void println (string s){
+ Console.WriteLine (s);
+ }
+
+ public void push (int state, Object value) {
+ println ("push\tstate "+state+"\tvalue "+value);
+ }
+
+ public void lex (int state, int token, string name, Object value) {
+ println("lex\tstate "+state+"\treading "+name+"\tvalue "+value);
+ }
+
+ public void shift (int from, int to, int errorFlag) {
+ switch (errorFlag) {
+ default: // normally
+ println("shift\tfrom state "+from+" to "+to);
+ break;
+ case 0: case 1: case 2: // in error recovery
+ println("shift\tfrom state "+from+" to "+to
+ +"\t"+errorFlag+" left to recover");
+ break;
+ case 3: // normally
+ println("shift\tfrom state "+from+" to "+to+"\ton error");
+ break;
+ }
+ }
+
+ public void pop (int state) {
+ println("pop\tstate "+state+"\ton error");
+ }
+
+ public void discard (int state, int token, string name, Object value) {
+ println("discard\tstate "+state+"\ttoken "+name+"\tvalue "+value);
+ }
+
+ public void reduce (int from, int to, int rule, string text, int len) {
+ println("reduce\tstate "+from+"\tuncover "+to
+ +"\trule ("+rule+") "+text);
+ }
+
+ public void shift (int from, int to) {
+ println("goto\tfrom state "+from+" to "+to);
+ }
+
+ public void accept (Object value) {
+ println("accept\tvalue "+value);
+ }
+
+ public void error (string message) {
+ println("error\t"+message);
+ }
+
+ public void reject () {
+ println("reject");
+ }
+
+ }
+}
+// %token constants
+ class Token {
+ public const int ERROR = 257;
+ public const int EOF = 258;
+ public const int SLASH = 259;
+ public const int SLASH2 = 260;
+ public const int DOT = 261;
+ public const int DOT2 = 262;
+ public const int COLON = 263;
+ public const int COLON2 = 264;
+ public const int COMMA = 265;
+ public const int AT = 266;
+ public const int FUNCTION_NAME = 267;
+ public const int BRACKET_OPEN = 268;
+ public const int BRACKET_CLOSE = 269;
+ public const int PAREN_OPEN = 270;
+ public const int PAREN_CLOSE = 271;
+ public const int AND = 272;
+ public const int OR = 273;
+ public const int DIV = 274;
+ public const int MOD = 275;
+ public const int PLUS = 276;
+ public const int MINUS = 277;
+ public const int ASTERISK = 278;
+ public const int DOLLAR = 279;
+ public const int BAR = 280;
+ public const int EQ = 281;
+ public const int NE = 282;
+ public const int LE = 283;
+ public const int GE = 284;
+ public const int LT = 285;
+ public const int GT = 286;
+ public const int ANCESTOR = 287;
+ public const int ANCESTOR_OR_SELF = 288;
+ public const int ATTRIBUTE = 289;
+ public const int CHILD = 290;
+ public const int DESCENDANT = 291;
+ public const int DESCENDANT_OR_SELF = 292;
+ public const int FOLLOWING = 293;
+ public const int FOLLOWING_SIBLING = 294;
+ public const int NAMESPACE = 295;
+ public const int PARENT = 296;
+ public const int PRECEDING = 297;
+ public const int PRECEDING_SIBLING = 298;
+ public const int SELF = 299;
+ public const int COMMENT = 300;
+ public const int TEXT = 301;
+ public const int PROCESSING_INSTRUCTION = 302;
+ public const int NODE = 303;
+ public const int NUMBER = 304;
+ public const int LITERAL = 305;
+ public const int NCName = 306;
+ public const int yyErrorCode = 256;
+ }
+ namespace yyParser {
+ using System;
+ /** thrown for irrecoverable syntax errors and stack overflow.
+ */
+ public class yyException : System.Exception {
+ public yyException (string message) : base (message) {
+ }
+ }
+
+ /** must be implemented by a scanner object to supply input to the parser.
+ */
+ public interface yyInput {
+ /** move on to next token.
+ @return false if positioned beyond tokens.
+ @throws IOException on input error.
+ */
+ bool advance (); // throws java.io.IOException;
+ /** classifies current token.
+ Should not be called if advance() returned false.
+ @return current %token or single character.
+ */
+ int token ();
+ /** associated with current token.
+ Should not be called if advance() returned false.
+ @return value for token().
+ */
+ Object value ();
+ }
+ }
+} // close outermost namespace, that MUST HAVE BEEN opened in the prolog
diff --git a/mcs/class/System.XML/System.Xml.XPath/Parser.jay b/mcs/class/System.XML/System.Xml.XPath/Parser.jay
new file mode 100644
index 00000000000..3d686da8f6a
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.XPath/Parser.jay
@@ -0,0 +1,412 @@
+%{
+// XPath parser
+//
+// Author - Piers Haken <piersh@friskit.com>
+//
+
+// TODO: FUNCTION_CALL should be a QName, not just a NCName
+// TODO: PROCESSING_INSTRUCTION's optional parameter
+// TODO: flatten argument/predicate lists in place
+
+using System;
+using System.Xml.XPath;
+using Test.Xml.XPath;
+
+namespace Mono.Xml.XPath
+{
+ public class XPathParser
+ {
+ internal object yyparseSafe (Tokenizer tok)
+ {
+ return yyparseSafe (tok, null);
+ }
+
+ internal object yyparseSafe (Tokenizer tok, object yyDebug)
+ {
+ try
+ {
+ return yyparse (tok, yyDebug);
+ }
+ catch (XPathException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw new XPathException ("Error during parse", e);
+ }
+ }
+
+ internal object yyparseDebug (Tokenizer tok)
+ {
+ return yyparseSafe (tok, new yydebug.yyDebugSimple ());
+ }
+
+%}
+
+%token ERROR
+%token EOF
+
+%token SLASH
+%token SLASH2
+%token DOT
+%token DOT2
+%token COLON
+%token COLON2
+%token COMMA
+%token AT
+
+%token FUNCTION_NAME
+
+%token BRACKET_OPEN
+%token BRACKET_CLOSE
+%token PAREN_OPEN
+%token PAREN_CLOSE
+
+%token AND
+%token OR
+%token DIV
+%token MOD
+%token PLUS
+%token MINUS
+%token ASTERISK
+%token DOLLAR
+%token BAR
+%token EQ
+%token NE
+%token LE
+%token GE
+%token LT
+%token GT
+
+%token ANCESTOR
+%token ANCESTOR_OR_SELF
+%token ATTRIBUTE
+%token CHILD
+%token DESCENDANT
+%token DESCENDANT_OR_SELF
+%token FOLLOWING
+%token FOLLOWING_SIBLING
+%token NAMESPACE
+%token PARENT
+%token PRECEDING
+%token PRECEDING_SIBLING
+%token SELF
+
+%token COMMENT
+%token TEXT
+%token PROCESSING_INSTRUCTION
+%token NODE
+
+%token NUMBER
+%token LITERAL
+%token NCName
+
+
+%start Expr
+
+
+%left AND
+%left OR
+%left EQ
+%left NE
+%left LE
+%left GE
+%left LT
+%left GT
+
+%left DIV
+%left MOD
+%left PLUS
+%left MINUS
+
+%%
+
+
+Expr
+ : OrExpr
+ ;
+
+OrExpr
+ : AndExpr
+ | OrExpr OR AndExpr
+ {
+ $$ = new ExprOR ((Expression) $1, (Expression) $3);
+ }
+ ;
+
+AndExpr
+ : EqualityExpr
+ | AndExpr AND EqualityExpr
+ {
+ $$ = new ExprAND ((Expression) $1, (Expression) $3);
+ }
+ ;
+
+EqualityExpr
+ : RelationalExpr
+ | EqualityExpr EQ RelationalExpr
+ {
+ $$ = new ExprEQ ((Expression) $1, (Expression) $3);
+ }
+ | EqualityExpr NE RelationalExpr
+ {
+ $$ = new ExprNE ((Expression) $1, (Expression) $3);
+ }
+ ;
+
+RelationalExpr
+ : AdditiveExpr
+ | RelationalExpr LT AdditiveExpr
+ {
+ $$ = new ExprLT ((Expression) $1, (Expression) $3);
+ }
+ | RelationalExpr GT AdditiveExpr
+ {
+ $$ = new ExprGT ((Expression) $1, (Expression) $3);
+ }
+ | RelationalExpr LE AdditiveExpr
+ {
+ $$ = new ExprLE ((Expression) $1, (Expression) $3);
+ }
+ | RelationalExpr GE AdditiveExpr
+ {
+ $$ = new ExprGE ((Expression) $1, (Expression) $3);
+ }
+ ;
+
+AdditiveExpr
+ : MultiplicativeExpr
+ | AdditiveExpr PLUS MultiplicativeExpr
+ {
+ $$ = new ExprPLUS ((Expression) $1, (Expression) $3);
+ }
+ | AdditiveExpr MINUS MultiplicativeExpr
+ {
+ $$ = new ExprMINUS ((Expression) $1, (Expression) $3);
+ }
+ ;
+
+MultiplicativeExpr
+ : UnaryExpr
+ | MultiplicativeExpr ASTERISK UnaryExpr
+ {
+ $$ = new ExprMULT ((Expression) $1, (Expression) $3);
+ }
+ | MultiplicativeExpr DIV UnaryExpr
+ {
+ $$ = new ExprDIV ((Expression) $1, (Expression) $3);
+ }
+ | MultiplicativeExpr MOD UnaryExpr
+ {
+ $$ = new ExprMOD ((Expression) $1, (Expression) $3);
+ }
+ ;
+
+UnaryExpr
+ : UnionExpr
+ | MINUS UnaryExpr
+ {
+ $$ = new ExprNEG ((Expression) $2);
+ }
+ ;
+
+UnionExpr
+ : PathExpr
+ | UnionExpr BAR PathExpr
+ {
+ $$ = new ExprUNION ((NodeSet) $1, (NodeSet) $3);
+ }
+ ;
+
+PathExpr
+ : RelativeLocationPath
+ | SLASH
+ {
+ $$ = new ExprRoot ();
+ }
+ | SLASH RelativeLocationPath
+ {
+ $$ = new ExprSLASH (new ExprRoot (), (NodeSet) $2);
+ }
+ | SLASH2 RelativeLocationPath
+ {
+ ExprStep exprStep = new ExprStep (new NodeTypeTest (Axes.DescendantOrSelf, XPathNodeType.All));
+ $$ = new ExprSLASH (new ExprSLASH (new ExprRoot (), exprStep), (NodeSet) $2);
+ }
+ | FilterExpr
+ | FilterExpr SLASH RelativeLocationPath
+ {
+ $$ = new ExprSLASH ((Expression) $1, (NodeSet) $3);
+ }
+ | FilterExpr SLASH2 RelativeLocationPath
+ {
+ ExprStep exprStep = new ExprStep (new NodeTypeTest (Axes.DescendantOrSelf, XPathNodeType.All));
+ $$ = new ExprSLASH (new ExprSLASH ((Expression) $1, exprStep), (NodeSet) $3);
+ }
+ ;
+
+RelativeLocationPath
+ : Step
+ | RelativeLocationPath SLASH Step
+ {
+ $$ = new ExprSLASH ((Expression) $1, (NodeSet) $3);
+ }
+ | RelativeLocationPath SLASH2 Step
+ {
+ ExprStep exprStep = new ExprStep (new NodeTypeTest (Axes.DescendantOrSelf, XPathNodeType.All));
+ $$ = new ExprSLASH (new ExprSLASH ((Expression) $1, exprStep), (NodeSet) $3);
+ }
+ ;
+
+Step
+ : AxisSpecifier QName ZeroOrMorePredicates
+ {
+ $$ = new ExprStep (new NodeNameTest ((Axes) $1, (QName) $2), (ExprPredicates) $3);
+ }
+ | AxisSpecifier ASTERISK ZeroOrMorePredicates
+ {
+ $$ = new ExprStep (new NodeTypeTest ((Axes) $1), (ExprPredicates) $3);
+ }
+ | AxisSpecifier NodeType PAREN_OPEN OptionalLiteral PAREN_CLOSE ZeroOrMorePredicates
+ {
+ $$ = new ExprStep (new NodeTypeTest ((Axes) $1, (XPathNodeType) $2, (String) $4), (ExprPredicates) $6);
+ }
+ | DOT
+ {
+ $$ = new ExprStep (new NodeTypeTest (Axes.Self, XPathNodeType.All));
+ }
+ | DOT2
+ {
+ $$ = new ExprStep (new NodeTypeTest (Axes.Parent, XPathNodeType.All));
+ }
+ ;
+
+AxisSpecifier
+ : /* empty */
+ {
+ $$ = Axes.Child;
+ }
+ | AT
+ {
+ $$ = Axes.Attribute;
+ }
+ | AxisName COLON2
+ {
+ $$ = $1;
+ }
+ ;
+
+NodeType
+ : COMMENT { $$ = XPathNodeType.Comment; }
+ | TEXT { $$ = XPathNodeType.Text; }
+ | PROCESSING_INSTRUCTION { $$ = XPathNodeType.ProcessingInstruction; }
+ | NODE { $$ = XPathNodeType.All; }
+ ;
+
+
+FilterExpr
+ : PrimaryExpr
+ | FilterExpr Predicate
+ {
+ $$ = new ExprFilter ((Expression) $1, (Expression) $2);
+ }
+ ;
+
+PrimaryExpr
+ : DOLLAR QName
+ {
+ $$ = new ExprVariable ((QName) $2);
+ }
+ | PAREN_OPEN Expr PAREN_CLOSE
+ {
+ $$ = $2;
+ }
+ | LITERAL
+ {
+ $$ = new ExprLiteral ((String) $1);
+ }
+ | NUMBER
+ {
+ $$ = new ExprNumber ((double) $1);
+ }
+ | FunctionCall
+ ;
+
+FunctionCall
+ : FUNCTION_NAME PAREN_OPEN OptionalArgumentList PAREN_CLOSE
+ {
+ $$ = new ExprFunctionCall ((String) $1, (FunctionArguments) $3);
+ }
+ ;
+
+OptionalArgumentList
+ : /* empty */
+ | Expr OptionalArgumentListTail
+ {
+ $$ = new FunctionArguments ((Expression) $1, (FunctionArguments) $2);
+ }
+ ;
+
+OptionalArgumentListTail
+ : /* empty */
+ | COMMA Expr OptionalArgumentListTail
+ {
+ $$ = new FunctionArguments ((Expression) $2, (FunctionArguments) $3);
+ }
+ ;
+
+
+ZeroOrMorePredicates
+ : /* empty */
+ | Predicate ZeroOrMorePredicates
+ {
+ $$ = new ExprPredicates ((Expression) $1, (ExprPredicates) $2);
+ }
+ ;
+
+Predicate
+ : BRACKET_OPEN Expr BRACKET_CLOSE
+ {
+ $$ = $2;
+ }
+ ;
+
+AxisName
+ : ANCESTOR { $$ = Axes.Ancestor; }
+ | ANCESTOR_OR_SELF { $$ = Axes.AncestorOrSelf; }
+ | ATTRIBUTE { $$ = Axes.Attribute; }
+ | CHILD { $$ = Axes.Child; }
+ | DESCENDANT { $$ = Axes.Descendant; }
+ | DESCENDANT_OR_SELF { $$ = Axes.DescendantOrSelf; }
+ | FOLLOWING { $$ = Axes.Following; }
+ | FOLLOWING_SIBLING { $$ = Axes.FollowingSibling; }
+ | NAMESPACE { $$ = Axes.Namespace; }
+ | PARENT { $$ = Axes.Parent; }
+ | PRECEDING { $$ = Axes.Preceding; }
+ | PRECEDING_SIBLING { $$ = Axes.PrecedingSibling; }
+ | SELF { $$ = Axes.Self; }
+ ;
+
+OptionalLiteral
+ : /* empty */
+ | LITERAL
+ ;
+
+QName
+ : NCName
+ {
+ $$ = new NCName ((String) $1);
+ }
+ | NCName COLON ASTERISK
+ {
+ $$ = new QName ((String) $1, null);
+ }
+ | NCName COLON NCName
+ {
+ $$ = new QName ((String) $1, (String) $3);
+ }
+ ;
+
+%%
+ }
diff --git a/mcs/class/System.XML/System.Xml.XPath/Tokenizer.cs b/mcs/class/System.XML/System.Xml.XPath/Tokenizer.cs
new file mode 100644
index 00000000000..56e58512bcc
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.XPath/Tokenizer.cs
@@ -0,0 +1,334 @@
+//
+// System.Xml.XPath.Tokenizer
+//
+// Author:
+// Piers Haken (piersh@friskit.com)
+//
+// (C) 2002 Piers Haken
+//
+using System;
+using System.IO;
+using System.Text;
+using System.Collections;
+using Mono.Xml.XPath;
+using Mono.Xml.XPath.yyParser;
+
+namespace System.Xml.XPath
+{
+ internal class Tokenizer : Mono.Xml.XPath.yyParser.yyInput
+ {
+ private char [] m_rgchInput;
+ private int m_ich;
+ private int m_cch;
+ private int m_iToken;
+ private Object m_objToken;
+ private static Hashtable s_mapTokens = new Hashtable ();
+ private static readonly Object [] s_rgTokenMap =
+ {
+ Token.AND, "and",
+ Token.OR, "or",
+ Token.DIV, "div",
+ Token.MOD, "mod",
+ Token.ANCESTOR, "ancestor",
+ Token.ANCESTOR_OR_SELF, "ancestor-or-self",
+ Token.ATTRIBUTE, "attribute",
+ Token.CHILD, "child",
+ Token.DESCENDANT, "descendant",
+ Token.DESCENDANT_OR_SELF, "descendant-or-self",
+ Token.FOLLOWING, "following",
+ Token.FOLLOWING_SIBLING, "following-sibling",
+ Token.NAMESPACE, "namespace",
+ Token.PARENT, "parent",
+ Token.PRECEDING, "preceding",
+ Token.PRECEDING_SIBLING, "preceding-sibling",
+ Token.SELF, "self",
+ Token.COMMENT, "comment",
+ Token.TEXT, "text",
+ Token.PROCESSING_INSTRUCTION, "processing-instruction",
+ Token.NODE, "node",
+ };
+ private const char EOL = '\0';
+
+ static Tokenizer ()
+ {
+ for (int i = 0; i < s_rgTokenMap.Length; i += 2)
+ s_mapTokens.Add (s_rgTokenMap [i + 1], s_rgTokenMap [i]);
+ }
+
+ public Tokenizer (string strInput)
+ {
+ m_rgchInput = strInput.ToCharArray ();
+ m_ich = 0;
+ m_cch = strInput.Length;
+ SkipWhitespace ();
+ }
+
+ private char Peek ()
+ {
+ if (m_ich >= m_cch)
+ return EOL;
+ return m_rgchInput [m_ich];
+ }
+
+ private char GetChar ()
+ {
+ if (m_ich >= m_cch)
+ return EOL;
+ return m_rgchInput [m_ich++];
+ }
+
+ private char PutBack ()
+ {
+ if (m_ich == 0)
+ throw new XPathException ("invalid tokenizer state"); // TODO: better description
+ return m_rgchInput [--m_ich];
+ }
+
+ private void SkipWhitespace ()
+ {
+ while (IsWhitespace (Peek ()))
+ GetChar ();
+ }
+
+ [MonoTODO]
+ private int ParseNumber ()
+ {
+ StringBuilder sb = new StringBuilder ();
+
+ while (IsDigit (Peek ()))
+ sb.Append ((char) GetChar ());
+
+ // TODO: doesn't handle '3.' error case
+ if (Peek () == '.')
+ {
+ sb.Append ((char) GetChar ());
+ while (IsDigit (Peek ()))
+ sb.Append ((char) GetChar ());
+ }
+ m_objToken = Double.Parse (sb.ToString ());
+ return Token.NUMBER;
+ }
+
+ private int ParseLiteral ()
+ {
+ StringBuilder sb = new StringBuilder ();
+
+ char chInit = GetChar ();
+ char ch;
+ while ((ch = Peek ()) != chInit)
+ {
+ if (ch == EOL)
+ return Token.ERROR;
+ sb.Append ((char) GetChar ());
+ }
+ GetChar ();
+ m_objToken = sb.ToString ();
+ return Token.LITERAL;
+ }
+
+ private int ParseIdentifier ()
+ {
+ StringBuilder sb = new StringBuilder ();
+
+ char ch;
+ while ((ch = Peek ()) == '_' || ch == '-' || Char.IsLetterOrDigit (ch))
+ sb.Append ((char) GetChar ());
+
+ String strToken = sb.ToString ();
+ Object objToken = s_mapTokens [strToken];
+ if (objToken != null)
+ return (int) objToken;
+
+ m_objToken = strToken;
+
+ SkipWhitespace ();
+ if (Peek () == '(')
+ return Token.FUNCTION_NAME;
+
+ return Token.NCName;
+ }
+
+ private static bool IsWhitespace (char ch)
+ {
+ // return Char.IsWhiteSpace (ch);
+ return (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r');
+ }
+
+ private static bool IsDigit (char ch)
+ {
+ // return Char.IsDigit (ch);
+ return ch >= '0' && ch <= '9';
+ }
+
+
+ int ParseToken ()
+ {
+ char ch = Peek ();
+ switch (ch)
+ {
+ case EOL:
+ return Token.EOF;
+
+ case '/':
+ GetChar ();
+ if (Peek () == '/')
+ {
+ GetChar ();
+ return Token.SLASH2;
+ }
+ return Token.SLASH;
+
+ case '.':
+ GetChar ();
+ if (Peek () == '.')
+ {
+ GetChar ();
+ return Token.DOT2;
+ }
+ else if (IsDigit (Peek ()))
+ {
+ PutBack ();
+ return ParseNumber ();
+ }
+ return Token.DOT;
+
+ case ':':
+ GetChar ();
+ if (Peek () == ':')
+ {
+ GetChar ();
+ return Token.COLON2;
+ }
+ return Token.COLON;
+
+ case ',':
+ GetChar ();
+ return Token.COMMA;
+
+ case '@':
+ GetChar ();
+ return Token.AT;
+
+ case '[':
+ GetChar ();
+ return Token.BRACKET_OPEN;
+
+ case ']':
+ GetChar ();
+ return Token.BRACKET_CLOSE;
+
+ case '(':
+ GetChar ();
+ return Token.PAREN_OPEN;
+
+ case ')':
+ GetChar ();
+ return Token.PAREN_CLOSE;
+
+ case '+':
+ GetChar ();
+ return Token.PLUS;
+
+ case '-':
+ GetChar ();
+ return Token.MINUS;
+
+ case '*':
+ GetChar ();
+ return Token.ASTERISK;
+
+ case '$':
+ GetChar ();
+ return Token.DOLLAR;
+
+ case '|':
+ GetChar ();
+ return Token.BAR;
+
+ case '=':
+ GetChar ();
+ return Token.EQ;
+
+ case '!':
+ GetChar ();
+ if (Peek () == '=')
+ {
+ GetChar ();
+ return Token.NE;
+ }
+ break;
+
+ case '>':
+ GetChar ();
+ if (Peek () == '=')
+ {
+ GetChar ();
+ return Token.GE;
+ }
+ return Token.GT;
+
+ case '<':
+ GetChar ();
+ if (Peek () == '=')
+ {
+ GetChar ();
+ return Token.LE;
+ }
+ return Token.LT;
+
+ case '\'':
+ return ParseLiteral ();
+
+ case '\"':
+ return ParseLiteral ();
+
+ default:
+ {
+ if (IsDigit (ch))
+ {
+ return ParseNumber ();
+ }
+ else
+ {
+ return ParseIdentifier ();
+ }
+ }
+ }
+ return Token.ERROR;
+ }
+
+ ///////////////////////////
+ // yyParser.yyInput methods
+ ///////////////////////////
+
+ /** move on to next token.
+ @return false if positioned beyond tokens.
+ @throws IOException on input error.
+ */
+ public bool advance ()
+ {
+ m_objToken = null;
+ m_iToken = ParseToken ();
+ SkipWhitespace ();
+ return (m_iToken != Token.EOF);
+ }
+
+ /** classifies current token.
+ Should not be called if advance() returned false.
+ @return current %token or single character.
+ */
+ public int token ()
+ {
+ return m_iToken;
+ }
+
+ /** associated with current token.
+ Should not be called if advance() returned false.
+ @return value for token().
+ */
+ public Object value ()
+ {
+ return m_objToken;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.XPath/XPathDocument.cs b/mcs/class/System.XML/System.Xml.XPath/XPathDocument.cs
new file mode 100644
index 00000000000..a48f9473ca5
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.XPath/XPathDocument.cs
@@ -0,0 +1,68 @@
+//
+// System.Xml.XPath.XPathDocument
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// (C) Copyright 2002 Tim Coleman
+//
+
+using System.IO;
+using System.Xml;
+
+namespace System.Xml.XPath
+{
+ [MonoTODO]
+ public class XPathDocument : IXPathNavigable
+ {
+ XmlDocument _doc = new XmlDocument ();
+
+#region Constructors
+
+ public XPathDocument (Stream stream)
+ {
+ _doc.Load (stream);
+ }
+
+ public XPathDocument (string uri)
+ {
+ _doc.Load (uri);
+ }
+
+ public XPathDocument (TextReader reader)
+ {
+ _doc.Load (reader);
+ }
+
+ public XPathDocument (XmlReader reader)
+ {
+ _doc.Load (reader);
+ }
+
+ public XPathDocument (string uri, XmlSpace space)
+ {
+ if (space == XmlSpace.Preserve)
+ _doc.PreserveWhitespace = true;
+ _doc.Load (uri);
+ }
+
+ public XPathDocument (XmlReader reader, XmlSpace space)
+ {
+ if (space == XmlSpace.Preserve)
+ _doc.PreserveWhitespace = true;
+ _doc.Load (reader);
+ }
+
+#endregion
+
+#region Methods
+
+ public XPathNavigator CreateNavigator ()
+ {
+ return _doc.CreateNavigator ();
+ }
+
+#endregion
+ }
+}
+
diff --git a/mcs/class/System.XML/System.Xml.XPath/XPathException.cs b/mcs/class/System.XML/System.Xml.XPath/XPathException.cs
new file mode 100644
index 00000000000..8a64b449d62
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.XPath/XPathException.cs
@@ -0,0 +1,27 @@
+//
+// System.Xml.XPath.XPathException
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// (C) Copyright 2002 Tim Coleman
+//
+
+using System.Runtime.Serialization;
+
+namespace System.Xml.XPath
+{
+ [Serializable]
+ public class XPathException : SystemException
+ {
+ #region Constructors
+
+ protected XPathException (SerializationInfo info, StreamingContext context) : base (info, context) {}
+
+ public XPathException (string message, Exception innerException) : base (message, innerException) {}
+
+ internal XPathException (string message) : base (message, null) {}
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.XPath/XPathExpression.cs b/mcs/class/System.XML/System.Xml.XPath/XPathExpression.cs
new file mode 100644
index 00000000000..4d525b36e02
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.XPath/XPathExpression.cs
@@ -0,0 +1,50 @@
+//
+// System.Xml.XPath.XPathExpression
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2002 Jason Diamond http://injektilo.org/
+//
+
+using System.Collections;
+
+namespace System.Xml.XPath
+{
+ public abstract class XPathExpression
+ {
+ #region Constructor
+
+ internal XPathExpression ()
+ {
+ }
+
+ #endregion
+
+ #region Properties
+
+ public abstract string Expression { get; }
+
+ public abstract XPathResultType ReturnType { get; }
+
+ #endregion
+
+ #region Methods
+
+ public abstract void AddSort (object expr, IComparer comparer);
+
+ public abstract void AddSort (
+ object expr,
+ XmlSortOrder order,
+ XmlCaseOrder caseOrder,
+ string lang,
+ XmlDataType dataType
+ );
+
+ public abstract XPathExpression Clone ();
+
+ public abstract void SetContext (XmlNamespaceManager nsManager);
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.XPath/XPathNamespaceScope.cs b/mcs/class/System.XML/System.Xml.XPath/XPathNamespaceScope.cs
new file mode 100644
index 00000000000..34a55e92662
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.XPath/XPathNamespaceScope.cs
@@ -0,0 +1,18 @@
+//
+// System.Xml.XPath.XPathNamespaceScope
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2002 Jason Diamond http://injektilo.org/
+//
+
+namespace System.Xml.XPath
+{
+ public enum XPathNamespaceScope
+ {
+ All = 0,
+ ExcludeXml = 1,
+ Local =2,
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs b/mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs
new file mode 100644
index 00000000000..4cabe71079b
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs
@@ -0,0 +1,261 @@
+//
+// System.Xml.XPath.XPathNavigator
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2002 Jason Diamond http://injektilo.org/
+//
+
+using System;
+using Mono.Xml.XPath;
+
+namespace System.Xml.XPath
+{
+ public abstract class XPathNavigator : ICloneable
+ {
+ #region Constructor
+
+ protected XPathNavigator ()
+ {
+ }
+
+ #endregion
+
+ #region Properties
+
+ public abstract string BaseURI { get; }
+
+ public abstract bool HasAttributes { get; }
+
+ public abstract bool HasChildren { get; }
+
+ public abstract bool IsEmptyElement { get; }
+
+ public abstract string LocalName { get; }
+
+ public abstract string Name { get; }
+
+ public abstract string NamespaceURI { get; }
+
+ public abstract XmlNameTable NameTable { get; }
+
+ public abstract XPathNodeType NodeType { get; }
+
+ public abstract string Prefix { get; }
+
+ public abstract string Value { get; }
+
+ public abstract string XmlLang { get; }
+
+ #endregion
+
+ #region Methods
+
+ public abstract XPathNavigator Clone ();
+
+ [MonoTODO]
+ public virtual XmlNodeOrder ComparePosition (XPathNavigator nav)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public virtual XPathExpression Compile (string xpath)
+ {
+ Tokenizer tokenizer = new Tokenizer (xpath);
+ XPathParser parser = new XPathParser ();
+ Expression expr = (Expression) parser.yyparseSafe (tokenizer);
+// Expression expr = (Expression) parser.yyparseDebug (tokenizer);
+ return new CompiledExpression (expr);
+ }
+
+ public virtual object Evaluate (string xpath)
+ {
+ return Evaluate (Compile (xpath));
+ }
+
+ public virtual object Evaluate (XPathExpression expr)
+ {
+ return Evaluate (expr, null);
+ }
+
+ public virtual object Evaluate (XPathExpression expr, XPathNodeIterator context)
+ {
+ if (context == null)
+ context = new NullIterator (this, new DefaultContext ());
+ return ((CompiledExpression) expr).Evaluate ((BaseIterator) context);
+ }
+
+ public abstract string GetAttribute (string localName, string namespaceURI);
+
+ public abstract string GetNamespace (string name);
+
+ object ICloneable.Clone ()
+ {
+ return Clone ();
+ }
+
+ public virtual bool IsDescendant (XPathNavigator nav)
+ {
+ if (nav != null)
+ {
+ nav = nav.Clone ();
+ while (nav.MoveToParent ())
+ {
+ if (IsSamePosition (nav))
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public abstract bool IsSamePosition (XPathNavigator other);
+
+ public virtual bool Matches (string xpath)
+ {
+ return Matches (Compile (xpath));
+ }
+
+ public virtual bool Matches (XPathExpression expr)
+ {
+ XPathNodeIterator nodes = Select (expr);
+
+ while (nodes.MoveNext ()) {
+ if (IsSamePosition (nodes.Current))
+ return true;
+ }
+
+ XPathNavigator navigator = Clone ();
+
+ while (navigator.MoveToParent ()) {
+ nodes = navigator.Select (expr);
+
+ while (nodes.MoveNext ()) {
+ if (IsSamePosition (nodes.Current))
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public abstract bool MoveTo (XPathNavigator other);
+
+ public abstract bool MoveToAttribute (string localName, string namespaceURI);
+
+ public abstract bool MoveToFirst ();
+
+ public abstract bool MoveToFirstAttribute ();
+
+ public abstract bool MoveToFirstChild ();
+
+ public bool MoveToFirstNamespace ()
+ {
+ return MoveToFirstNamespace (XPathNamespaceScope.All);
+ }
+
+ public abstract bool MoveToFirstNamespace (XPathNamespaceScope namespaceScope);
+
+ public abstract bool MoveToId (string id);
+
+ public abstract bool MoveToNamespace (string name);
+
+ public abstract bool MoveToNext ();
+
+ public abstract bool MoveToNextAttribute ();
+
+ public bool MoveToNextNamespace ()
+ {
+ return MoveToNextNamespace (XPathNamespaceScope.All);
+ }
+
+ public abstract bool MoveToNextNamespace (XPathNamespaceScope namespaceScope);
+
+ public abstract bool MoveToParent ();
+
+ public abstract bool MoveToPrevious ();
+
+ public abstract void MoveToRoot ();
+
+ public virtual XPathNodeIterator Select (string xpath)
+ {
+ return Select (Compile (xpath));
+ }
+
+ public virtual XPathNodeIterator Select (XPathExpression expr)
+ {
+ BaseIterator iter = new NullIterator (this, new DefaultContext ());
+ return ((CompiledExpression) expr).EvaluateNodeSet (iter);
+ }
+
+ public virtual XPathNodeIterator SelectAncestors (XPathNodeType type, bool matchSelf)
+ {
+ Axes axis = (matchSelf) ? Axes.AncestorOrSelf : Axes.Ancestor;
+ NodeTest test = new NodeTypeTest (axis, type);
+ return SelectTest (test);
+ }
+
+ [MonoTODO]
+ public virtual XPathNodeIterator SelectAncestors (string name, string namespaceURI, bool matchSelf)
+ {
+ if (namespaceURI != null && namespaceURI != "")
+ throw new NotImplementedException ();
+
+ Axes axis = (matchSelf) ? Axes.AncestorOrSelf : Axes.Ancestor;
+ QName qname = new QName ("", name);
+ NodeTest test = new NodeNameTest (axis, qname);
+ return SelectTest (test);
+ }
+
+ public virtual XPathNodeIterator SelectChildren (XPathNodeType type)
+ {
+ NodeTest test = new NodeTypeTest (Axes.Child, type);
+ return SelectTest (test);
+ }
+
+ [MonoTODO]
+ public virtual XPathNodeIterator SelectChildren (string name, string namespaceURI)
+ {
+ if (namespaceURI != null && namespaceURI != "")
+ throw new NotImplementedException ();
+
+ Axes axis = Axes.Child;
+ QName qname = new QName ("", name);
+ NodeTest test = new NodeNameTest (axis, qname);
+ return SelectTest (test);
+ }
+
+ public virtual XPathNodeIterator SelectDescendants (XPathNodeType type, bool matchSelf)
+ {
+ Axes axis = (matchSelf) ? Axes.DescendantOrSelf : Axes.Descendant;
+ NodeTest test = new NodeTypeTest (axis, type);
+ return SelectTest (test);
+ }
+
+ [MonoTODO]
+ public virtual XPathNodeIterator SelectDescendants (string name, string namespaceURI, bool matchSelf)
+ {
+ if (namespaceURI != null && namespaceURI != "")
+ throw new NotImplementedException ();
+
+ Axes axis = (matchSelf) ? Axes.DescendantOrSelf : Axes.Descendant;
+ QName qname = new QName ("", name);
+ NodeTest test = new NodeNameTest (axis, qname);
+ return SelectTest (test);
+ }
+
+ internal XPathNodeIterator SelectTest (NodeTest test)
+ {
+ Expression expr = new ExprStep (test, null);
+ BaseIterator iter = new NullIterator (this, new DefaultContext ());
+ return expr.EvaluateNodeSet (iter);
+ }
+
+ public override string ToString ()
+ {
+ return Value;
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.XPath/XPathNodeIterator.cs b/mcs/class/System.XML/System.Xml.XPath/XPathNodeIterator.cs
new file mode 100644
index 00000000000..d27f65a0f12
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.XPath/XPathNodeIterator.cs
@@ -0,0 +1,63 @@
+//
+// System.Xml.XPath.XPathNodeIterator
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2002 Jason Diamond http://injektilo.org/
+//
+
+using System;
+
+namespace System.Xml.XPath
+{
+ public abstract class XPathNodeIterator : ICloneable
+ {
+ private int _count = -1;
+
+ #region Constructor
+
+ protected XPathNodeIterator ()
+ {
+ }
+
+ #endregion
+
+ #region Properties
+
+ public virtual int Count
+ {
+ get
+ {
+ if (_count == -1)
+ {
+ // compute and cache the count
+ XPathNodeIterator tmp = Clone ();
+ while (tmp.MoveNext ())
+ ;
+ _count = tmp.CurrentPosition;
+ }
+ return _count;
+ }
+ }
+
+ public abstract XPathNavigator Current { get; }
+
+ public abstract int CurrentPosition { get; }
+
+ #endregion
+
+ #region Methods
+
+ public abstract XPathNodeIterator Clone ();
+
+ object ICloneable.Clone ()
+ {
+ return Clone ();
+ }
+
+ public abstract bool MoveNext ();
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.XPath/XPathNodeType.cs b/mcs/class/System.XML/System.Xml.XPath/XPathNodeType.cs
new file mode 100644
index 00000000000..22720f838be
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.XPath/XPathNodeType.cs
@@ -0,0 +1,25 @@
+//
+// System.Xml.XPath.XPathNodeType
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2002 Jason Diamond http://injektilo.org/
+//
+
+namespace System.Xml.XPath
+{
+ public enum XPathNodeType
+ {
+ Root = 0,
+ Element = 1,
+ Attribute = 2,
+ Namespace = 3,
+ Text = 4,
+ SignificantWhitespace = 5,
+ Whitespace = 6,
+ ProcessingInstruction = 7,
+ Comment = 8,
+ All = 9,
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.XPath/XPathResultType.cs b/mcs/class/System.XML/System.Xml.XPath/XPathResultType.cs
new file mode 100644
index 00000000000..82ab383a1e3
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.XPath/XPathResultType.cs
@@ -0,0 +1,22 @@
+//
+// System.Xml.XPath.XPathResultType
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2002 Jason Diamond http://injektilo.org/
+//
+
+namespace System.Xml.XPath
+{
+ public enum XPathResultType
+ {
+ Number = 0,
+ String = 1,
+ Boolean = 2,
+ NodeSet = 3,
+ Navigator = 1,
+ Any = 5,
+ Error = 6,
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.XPath/XmlCaseOrder.cs b/mcs/class/System.XML/System.Xml.XPath/XmlCaseOrder.cs
new file mode 100755
index 00000000000..6e841b7467c
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.XPath/XmlCaseOrder.cs
@@ -0,0 +1,33 @@
+// XmlCaseOrder.cs
+//
+// This code was automatically generated from
+// ECMA CLI XML Library Specification.
+// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
+// Created: Wed, 5 Sep 2001 06:47:03 UTC
+// Source file: all.xml
+// URL: http://devresource.hp.com/devresource/Docs/TechPapers/CSharp/all.xml
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+
+
+namespace System.Xml.XPath {
+
+
+ /// <summary>
+ /// </summary>
+ public enum XmlCaseOrder {
+
+ /// <summary>
+ /// </summary>
+ None = 0,
+
+ /// <summary>
+ /// </summary>
+ UpperFirst = 1,
+
+ /// <summary>
+ /// </summary>
+ LowerFirst = 2,
+ } // XmlCaseOrder
+
+} // System.Xml
diff --git a/mcs/class/System.XML/System.Xml.XPath/XmlDataType.cs b/mcs/class/System.XML/System.Xml.XPath/XmlDataType.cs
new file mode 100644
index 00000000000..4b8c8ea44ae
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.XPath/XmlDataType.cs
@@ -0,0 +1,17 @@
+//
+// System.Xml.XPath.XmlDataType
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2002 Jason Diamond http://injektilo.org/
+//
+
+namespace System.Xml.XPath
+{
+ public enum XmlDataType
+ {
+ Text = 1,
+ Number = 2,
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.XPath/XmlSortOrder.cs b/mcs/class/System.XML/System.Xml.XPath/XmlSortOrder.cs
new file mode 100644
index 00000000000..925aa15cd6c
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.XPath/XmlSortOrder.cs
@@ -0,0 +1,17 @@
+//
+// System.Xml.XPath.XmlSortOrder
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2002 Jason Diamond http://injektilo.org/
+//
+
+namespace System.Xml.XPath
+{
+ public enum XmlSortOrder
+ {
+ Ascending = 1,
+ Descending = 2,
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Xsl/ChangeLog b/mcs/class/System.XML/System.Xml.Xsl/ChangeLog
new file mode 100644
index 00000000000..fb4b40c200d
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Xsl/ChangeLog
@@ -0,0 +1,25 @@
+2002-09-23 Duncan Mak <duncan@ximian.com>
+
+ * XslTransform.cs (Laod): Implemented the simple version that
+ takes one XPathNavigator as argument.
+ (Save): New private method for recreating the XML in text from a
+ XPathNavigator
+ (WriteCurrentNode):
+ (WriteTree): private methods for generating the text XML from the
+ XPathNavigator tree.
+
+2002-09-20 Duncan Mak <duncan@ximian.com>
+
+ * XslTransform.cs (Load): Implemented the methods, not
+ including the ones that deal with XPathNavigator (hopefully those
+ will come later).
+ (Transform): Implemented the version that saves directly to a file.
+ (Save): New private method for recreating the XML in text from
+ from an XmlReader
+
+ We're now P/Invoking libxslt for doing XSLT work.
+
+2002-06-23 Piers Haken <piersh@friskit.com>
+
+ * XsltContext.cs: added 'PreserveWhitespace' abstract method
+
diff --git a/mcs/class/System.XML/System.Xml.Xsl/IXsltContextFunction.cs b/mcs/class/System.XML/System.Xml.Xsl/IXsltContextFunction.cs
new file mode 100644
index 00000000000..4f2dc25efd0
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Xsl/IXsltContextFunction.cs
@@ -0,0 +1,28 @@
+// System.Xml.Xsl.IXsltContextFunction
+//
+// Author: Tim Coleman <tim@timcoleman.com>
+// (C) Copyright 2002 Tim Coleman
+
+using System;
+using System.Xml.XPath;
+
+namespace System.Xml.Xsl
+{
+ public interface IXsltContextFunction
+ {
+ #region Properties
+
+ XPathResultType [] ArgTypes { get; }
+ int Maxargs { get; }
+ int Minargs { get; }
+ XPathResultType ReturnType { get; }
+
+ #endregion
+
+ #region Methods
+
+ object Invoke (XsltContext xsltContext, object [] args, XPathNavigator docContext);
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Xsl/IXsltContextVariable.cs b/mcs/class/System.XML/System.Xml.Xsl/IXsltContextVariable.cs
new file mode 100644
index 00000000000..f1b4aa0f3b9
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Xsl/IXsltContextVariable.cs
@@ -0,0 +1,27 @@
+// System.Xml.Xsl.IXsltContextVariable
+//
+// Author: Tim Coleman <tim@timcoleman.com>
+// (C) Copyright 2002 Tim Coleman
+
+using System;
+using System.Xml.XPath;
+
+namespace System.Xml.Xsl
+{
+ public interface IXsltContextVariable
+ {
+ #region Properties
+
+ bool IsLocal { get; }
+ bool IsParam { get; }
+ XPathResultType VariableType { get; }
+
+ #endregion
+
+ #region Methods
+
+ object Evaluate (XsltContext xsltContext);
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Xsl/XslTransform.cs b/mcs/class/System.XML/System.Xml.Xsl/XslTransform.cs
new file mode 100644
index 00000000000..dee1a343945
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Xsl/XslTransform.cs
@@ -0,0 +1,314 @@
+// System.Xml.Xsl.XslTransform
+//
+// Author: Tim Coleman <tim@timcoleman.com>
+// (C) Copyright 2002 Tim Coleman
+
+using System;
+using System.Xml.XPath;
+using System.IO;
+using System.Text;
+using System.Runtime.InteropServices;
+
+namespace System.Xml.Xsl
+{
+ public sealed class XslTransform
+ {
+
+ #region Fields
+
+ XmlResolver xmlResolver;
+ string stylesheet_file;
+ #endregion
+
+ #region Constructors
+ public XslTransform ()
+ {
+ stylesheet_file = String.Empty;
+ }
+
+ #endregion
+
+ #region Properties
+
+ public XmlResolver XmlResolver {
+ set { xmlResolver = value; }
+ }
+
+ #endregion
+
+ #region Methods
+
+ // Loads the XSLT stylesheet contained in the IXPathNavigable.
+ public void Load (IXPathNavigable stylesheet)
+ {
+ Load (stylesheet.CreateNavigator ());
+ }
+
+ // Loads the XSLT stylesheet specified by a URL.
+ public void Load (string url)
+ {
+ stylesheet_file = url;
+ }
+
+ // Loads the XSLT stylesheet contained in the XmlReader
+ public void Load (XmlReader stylesheet)
+ {
+ stylesheet_file = Path.GetTempFileName ();
+ Save (stylesheet, stylesheet_file);
+ }
+
+ // Loads the XSLT stylesheet contained in the XPathNavigator
+ public void Load (XPathNavigator stylesheet)
+ {
+ stylesheet_file = Path.GetTempFileName ();
+ Save (stylesheet, stylesheet_file);
+ }
+
+ [MonoTODO]
+ // Loads the XSLT stylesheet contained in the IXPathNavigable.
+ public void Load (IXPathNavigable stylesheet, XmlResolver resolver)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ // Loads the XSLT stylesheet specified by a URL.
+ public void Load (string url, XmlResolver resolver)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ // Loads the XSLT stylesheet contained in the XmlReader
+ public void Load (XmlReader stylesheet, XmlResolver resolver)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ // Loads the XSLT stylesheet contained in the XPathNavigator
+ public void Load (XPathNavigator stylesheet, XmlResolver resolver)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [DllImport ("libxslt.so")]
+ static extern IntPtr xsltParseStylesheetFile (string filename);
+
+ [DllImport ("libxslt.so")]
+ static extern IntPtr xsltApplyStylesheet (IntPtr stylePtr, IntPtr DocPtr, string [] parameters);
+
+ [DllImport ("libxslt.so")]
+ static extern IntPtr xmlNewDoc (string version);
+
+ [DllImport ("libxslt.so")]
+ static extern IntPtr xmlParseFile (string filename);
+
+ [DllImport ("libxslt.so")]
+ static extern int xmlSaveFile (string filename, IntPtr cur);
+
+ [MonoTODO]
+ // Transforms the XML data in the IXPathNavigable using
+ // the specified args and outputs the result to an XmlReader.
+ public XmlReader Transform (IXPathNavigable input, XsltArgumentList args)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ // Transforms the XML data in the input file and outputs
+ // the result to an output file.
+ public void Transform (string inputfile, string outputfile)
+ {
+ IntPtr xmlDocument = xmlParseFile (inputfile);
+ IntPtr xmlStylesheet = xsltParseStylesheetFile (stylesheet_file);
+ IntPtr xmlOutput = xmlNewDoc ("1.0");
+ string [] parameters = new string [] {};
+
+ xmlOutput = xsltApplyStylesheet (xmlStylesheet, xmlDocument, parameters);
+
+ xmlSaveFile (outputfile, xmlOutput);
+ }
+
+ [MonoTODO]
+ // Transforms the XML data in the XPathNavigator using
+ // the specified args and outputs the result to an XmlReader.
+ public XmlReader Transform (XPathNavigator input, XsltArgumentList args)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ // Transforms the XML data in the IXPathNavigable using
+ // the specified args and outputs the result to a Stream.
+ public void Transform (IXPathNavigable input, XsltArgumentList args, Stream output)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ // Transforms the XML data in the IXPathNavigable using
+ // the specified args and outputs the result to a TextWriter.
+ public void Transform (IXPathNavigable input, XsltArgumentList args, TextWriter output)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ // Transforms the XML data in the IXPathNavigable using
+ // the specified args and outputs the result to an XmlWriter.
+ public void Transform (IXPathNavigable input, XsltArgumentList args, XmlWriter output)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ // Transforms the XML data in the XPathNavigator using
+ // the specified args and outputs the result to a Stream.
+ public void Transform (XPathNavigator input, XsltArgumentList args, Stream output)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ // Transforms the XML data in the XPathNavigator using
+ // the specified args and outputs the result to a TextWriter.
+ public void Transform (XPathNavigator input, XsltArgumentList args, TextWriter output)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ // Transforms the XML data in the XPathNavigator using
+ // the specified args and outputs the result to an XmlWriter.
+ public void Transform (XPathNavigator input, XsltArgumentList args, XmlWriter output)
+ {
+ throw new NotImplementedException ();
+ }
+
+ static void Save (XmlReader rdr, string filename)
+ {
+ XmlTextWriter writer = new XmlTextWriter (filename, new UTF8Encoding ());
+
+ while (rdr.Read ()) {
+ switch (rdr.NodeType) {
+
+ case XmlNodeType.CDATA:
+ writer.WriteCData (rdr.Value);
+ break;
+
+ case XmlNodeType.Comment:
+ writer.WriteComment (rdr.Value);
+ break;
+
+ case XmlNodeType.DocumentType:
+ writer.WriteDocType (rdr.Value, null, null, null);
+ break;
+
+ case XmlNodeType.Element:
+ writer.WriteStartElement (rdr.Name, rdr.Value);
+
+ while (rdr.MoveToNextAttribute ())
+ writer.WriteAttributes (rdr, true);
+ break;
+
+ case XmlNodeType.EndElement:
+ writer.WriteEndElement ();
+ break;
+
+ case XmlNodeType.ProcessingInstruction:
+ writer.WriteProcessingInstruction (rdr.Name, rdr.Value);
+ break;
+
+ case XmlNodeType.Text:
+ writer.WriteString (rdr.Value);
+ break;
+
+ case XmlNodeType.Whitespace:
+ writer.WriteWhitespace (rdr.Value);
+ break;
+
+ case XmlNodeType.XmlDeclaration:
+ writer.WriteStartDocument ();
+ break;
+ }
+ }
+
+ writer.Close ();
+ }
+
+ static void Save (XPathNavigator navigator, string filename)
+ {
+ XmlTextWriter writer = new XmlTextWriter (filename, new UTF8Encoding ());
+ XPathNodeType type = XPathNodeType.All;
+
+ WriteTree (navigator, writer, type);
+ }
+
+ // Walks the XPathNavigator tree recursively
+ static void WriteTree (XPathNavigator navigator, XmlTextWriter writer, XPathNodeType type)
+ {
+ WriteCurrentNode (navigator, writer, ref type);
+
+ if (navigator.HasAttributes) {
+ navigator.MoveToFirstAttribute ();
+
+ do {
+ WriteCurrentNode (navigator, writer, ref type);
+ } while ( navigator.MoveToNextAttribute ());
+
+ navigator.MoveToParent ();
+ }
+
+ if (navigator.HasChildren) {
+ navigator.MoveToFirstChild ();
+
+ do {
+ WriteTree (navigator, writer, type);
+ } while (navigator.MoveToNext ());
+
+ navigator.MoveToParent ();
+ }
+ }
+
+ // Format the output
+ static void WriteCurrentNode (XPathNavigator navigator, XmlTextWriter writer, ref XPathNodeType current_type)
+ {
+ switch (navigator.NodeType) {
+ case XPathNodeType.Attribute:
+ current_type = XPathNodeType.Attribute;
+ writer.WriteAttributeString (navigator.LocalName, navigator.Value);
+ break;
+
+ case XPathNodeType.Comment:
+ writer.WriteComment (navigator.Value);
+ break;
+
+ case XPathNodeType.Element:
+ current_type = XPathNodeType.Element;
+ writer.WriteStartElement (navigator.Name);
+ break;
+
+ case XPathNodeType.ProcessingInstruction:
+ writer.WriteProcessingInstruction (navigator.Name, navigator.Value);
+ break;
+
+ case XPathNodeType.Text:
+ writer.WriteString (navigator.Value);
+
+ if (current_type == XPathNodeType.Element) {
+ writer.WriteEndElement ();
+ current_type = XPathNodeType.All;
+ }
+
+ break;
+
+ case XPathNodeType.SignificantWhitespace:
+ case XPathNodeType.Whitespace:
+ writer.WriteWhitespace (navigator.Value);
+ break;
+ }
+ }
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Xsl/XsltArgumentList.cs b/mcs/class/System.XML/System.Xml.Xsl/XsltArgumentList.cs
new file mode 100644
index 00000000000..e4ac3b138f0
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Xsl/XsltArgumentList.cs
@@ -0,0 +1,131 @@
+// System.Xml.Xsl.XsltArgumentList
+//
+// Author: Tim Coleman <tim@timcoleman.com>
+// (C) Copyright 2002 Tim Coleman
+
+using System;
+using System.Collections;
+using System.Xml;
+using System.Xml.XPath;
+
+namespace System.Xml.Xsl
+{
+ public sealed class XsltArgumentList
+ {
+ #region Fields
+
+ private Hashtable extensionObjects;
+ private Hashtable parameters;
+
+ #endregion
+
+ #region Constructors
+
+ public XsltArgumentList ()
+ {
+ extensionObjects = new Hashtable ();
+ parameters = new Hashtable ();
+ }
+
+ #endregion
+
+ #region Methods
+
+ public void AddExtensionObject (string namespaceUri, object extension)
+ {
+ if (namespaceUri == null)
+ throw new ArgumentException ("The namespaceUri is a null reference.");
+ if (namespaceUri == "http://www.w3.org/1999/XSL/Transform")
+ throw new ArgumentException ("The namespaceUri is http://www.w3.org/1999/XSL/Transform.");
+ if (extensionObjects.Contains (namespaceUri))
+ throw new ArgumentException ("The namespaceUri already has an extension object associated with it.");
+
+ extensionObjects [namespaceUri] = extension;
+ }
+
+ public void AddParam (string name, string namespaceUri, object parameter)
+ {
+
+ if (namespaceUri == null)
+ throw new ArgumentException ("The namespaceUri is a null reference.");
+
+ if (namespaceUri == "http://www.w3.org/1999/XSL/Transform")
+ throw new ArgumentException ("The namespaceUri is http://www.w3.org/1999/XSL/Transform.");
+
+ if (name == null)
+ throw new ArgumentException ("The parameter name is a null reference.");
+
+
+ // TODO:
+ // verify that the name is a valid name according to
+ // the W3C XML specification
+
+ XmlQualifiedName qName = new XmlQualifiedName (name, namespaceUri);
+
+ if (parameters.Contains (qName))
+ throw new ArgumentException ("The namespaceUri already has a parameter associated with it.");
+
+ parameter = ValidateParam (parameter);
+
+ parameters [qName] = parameter;
+ }
+
+ public void Clear ()
+ {
+ extensionObjects.Clear ();
+ parameters.Clear ();
+ }
+
+ public object GetExtensionObject (string namespaceUri)
+ {
+ return extensionObjects [namespaceUri];
+ }
+
+ public object GetParam (string name, string namespaceUri)
+ {
+ if (name == null)
+ throw (new ArgumentException ("The parameter name is a null reference."));
+ if (namespaceUri == null)
+ throw (new ArgumentException ("The namespaceUri is a null reference."));
+
+ XmlQualifiedName qName = new XmlQualifiedName (name, namespaceUri);
+ return parameters [qName];
+ }
+
+ public object RemoveExtensionObject (string namespaceUri)
+ {
+ object extensionObject = this.GetExtensionObject (namespaceUri);
+ extensionObjects.Remove (namespaceUri);
+ return extensionObject;
+ }
+
+ public object RemoveParam (string name, string namespaceUri)
+ {
+ XmlQualifiedName qName = new XmlQualifiedName (name, namespaceUri);
+ object parameter = this.GetParam (name, namespaceUri);
+ parameters.Remove (qName);
+ return parameter;
+ }
+
+ private object ValidateParam (object parameter)
+ {
+ if (parameter is string) return parameter;
+ if (parameter is bool) return parameter;
+ if (parameter is double) return parameter;
+ if (parameter is XPathNavigator) return parameter;
+ if (parameter is XPathNodeIterator) return parameter;
+
+ if (parameter is Int16) return (double) parameter;
+ if (parameter is UInt16) return (double) parameter;
+ if (parameter is Int32) return (double) parameter;
+ if (parameter is Int64) return (double) parameter;
+ if (parameter is UInt64) return (double) parameter;
+ if (parameter is Single) return (double) parameter;
+ if (parameter is decimal) return (double) parameter;
+
+ return parameter.ToString ();
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Xsl/XsltCompileException.cs b/mcs/class/System.XML/System.Xml.Xsl/XsltCompileException.cs
new file mode 100644
index 00000000000..7cd4011b763
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Xsl/XsltCompileException.cs
@@ -0,0 +1,56 @@
+// System.Xml.Xsl.XsltCompileException
+//
+// Author: Tim Coleman <tim@timcoleman.com>
+// (C) Copyright 2002 Tim Coleman
+
+using System;
+using System.Runtime.Serialization;
+
+namespace System.Xml.Xsl
+{
+ [Serializable]
+ public class XsltCompileException : XsltException
+ {
+ #region Fields
+
+ string message;
+
+ #endregion
+
+ #region Constructors
+
+ [MonoTODO]
+ protected XsltCompileException (SerializationInfo info, StreamingContext context )
+ : base (info, context)
+ {
+ }
+
+ [MonoTODO]
+ // I don't think this base() call is right, but what
+ // should the message be for XsltException?
+ public XsltCompileException (Exception inner, String sourceUri, int lineNumber, int linePosition)
+ : base (sourceUri, inner)
+ {
+ }
+
+
+ #endregion
+
+ #region Properties
+
+ public override string Message {
+ get { return message; }
+ }
+
+ #endregion
+
+ #region Methods
+
+ public override void GetObjectData (SerializationInfo info, StreamingContext context)
+ {
+ base.GetObjectData (info, context);
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Xsl/XsltContext.cs b/mcs/class/System.XML/System.Xml.Xsl/XsltContext.cs
new file mode 100644
index 00000000000..b47822ae7a3
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Xsl/XsltContext.cs
@@ -0,0 +1,45 @@
+// System.Xml.Xsl.XsltContext
+//
+// Author: Tim Coleman <tim@timcoleman.com>
+// (C) Copyright 2002 Tim Coleman
+
+using System;
+using System.Xml;
+using System.Xml.XPath;
+
+namespace System.Xml.Xsl
+{
+ public abstract class XsltContext : XmlNamespaceManager
+ {
+ #region Constructors
+
+ // should this really be calling new NameTable() in the
+ // base() call?
+ public XsltContext ()
+ : base (new NameTable ())
+ {
+ }
+
+ public XsltContext (NameTable table)
+ : base (table)
+ {
+ }
+
+ #endregion
+
+ #region Properties
+
+ public abstract bool Whitespace { get; }
+ public abstract bool PreserveWhitespace (XPathNavigator nav);
+
+ #endregion
+
+ #region Methods
+
+ public abstract int CompareDocument (string baseUri, string nextbaseUri);
+ public abstract IXsltContextFunction ResolveFunction (string prefix, string name, XPathResultType [] ArgTypes);
+ public abstract IXsltContextVariable ResolveVariable (string prefix, string name);
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml.Xsl/XsltException.cs b/mcs/class/System.XML/System.Xml.Xsl/XsltException.cs
new file mode 100644
index 00000000000..29e6adad0b6
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml.Xsl/XsltException.cs
@@ -0,0 +1,72 @@
+// System.Xml.Xsl.XsltException
+//
+// Author: Tim Coleman <tim@timcoleman.com>
+// (C) Copyright 2002 Tim Coleman
+
+using System;
+using System.Runtime.Serialization;
+
+namespace System.Xml.Xsl
+{
+ [Serializable]
+ public class XsltException : SystemException
+ {
+ #region Fields
+
+ string message;
+ int lineNumber;
+ int linePosition;
+ string sourceUri;
+
+ #endregion
+
+ #region Constructors
+
+ public XsltException (string message, Exception innerException)
+ : base (message, innerException)
+ {
+ this.message = message;
+ }
+
+ protected XsltException (SerializationInfo info, StreamingContext context)
+ {
+ lineNumber = info.GetInt32 ("lineNumber");
+ linePosition = info.GetInt32 ("linePosition");
+ sourceUri = info.GetString ("sourceUri");
+ }
+
+ #endregion
+
+ #region Properties
+
+ public int LineNumber {
+ get { return lineNumber; }
+ }
+
+ public int LinePosition {
+ get { return linePosition; }
+ }
+
+ public override string Message {
+ get { return message; }
+ }
+
+ public string SourceUri {
+ get { return sourceUri; }
+ }
+
+ #endregion
+
+ #region Methods
+
+ public override void GetObjectData (SerializationInfo info, StreamingContext context)
+ {
+ base.GetObjectData (info, context);
+ info.AddValue ("lineNumber", lineNumber);
+ info.AddValue ("linePosition", linePosition);
+ info.AddValue ("sourceUri", sourceUri);
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/ChangeLog b/mcs/class/System.XML/System.Xml/ChangeLog
new file mode 100644
index 00000000000..5fd0d8d1035
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/ChangeLog
@@ -0,0 +1,1293 @@
+2003-01-19 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlNamespaceManager.cs : fundamental change of LookupPrefix to return
+ null when no matching uri.
+ * XmlElement.cs : removed unnecessary xmlns output.
+ * XmlNode.cs : GetPrefixOfNamespace fix along with the change above.
+ * XmlTextWriter.cs : LookupPrefix and WriteStartElementInternal fix
+ along with the change above, and moved timing of 'xmlns' output
+ to CloseStartElement.
+ * XmlWriter.cs: modified WriteStartAttribute, same as yesterday.
+
+2003-01-18 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlWriter.cs: modified WriteStartElement (see test for detail).
+ Added WriteNode.
+
+2003-01-13 Ville Palo <vi64pa@koti.soon.fi>
+
+ * XmlDocument.cs: Added CheckName () method to check names validity.
+
+2003-01-11 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * XmlTextReader.cs:
+ (ReadOuterXml): use Depth property which return elementDepth, not depth.
+
+2003-01-11 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlElement.cs : (by ville) XmlElement.set_InnerText event bugfix.
+ * XmlTextReader.cs : some fix for ReadOuterXml().
+
+2003-01-08 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlTextReader.cs : bugfix for attributes related to creation of
+ XmlAttribute *node*.
+
+2003-01-08 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlTextReader.cs : bugfix for attribute values which have entity
+ references.
+
+2002-12-28 Ville Palo <vi64pa@koti.soon.fi>
+
+ * XmlDocument.cs: XmlTextWriter.Formatting == Indented when
+ calling Save () -methods.
+
+2002-12-28 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlNodeReader.cs : primitive reading implementation.
+
+2002-12-28 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlElement.cs : quick fix for the incomplete patch of #35308 below.
+
+2002-12-28 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlDocument.cs : removed inconsistent line-feed output.
+ * XmlElement.cs, XmlTextWriter.cs :
+ fixed for bugzilla 35308 (default ns output)
+ * XmlWhitespace.cs : limited output only when preserving whitespace.
+
+2002-12-24 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlAttribute.cs, XmlDocument.cs, XmlTextReader.cs:
+ Implemented XmlTextReader.ReadAttributeValue().
+ Added internal ReadAttributeNodeValue().
+ Fixed XmlAttribute.InnerXml to use these methods.
+
+ * XmlDocument.cs, XmlDocumentFragment.cs, XmlElement.cs, XmlNode.cs:
+ Implemented XmlDocument.ReadNode() and removed ConstructDOM().
+ Other changes are replacing them.
+
+2002-12-24 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlDocument.cs: patch by Ville (fixed default PreserveWhitespace)
+
+2002-12-21 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlElement.cs, XmlTextWriter.cs, XmlWriter.cs:
+ patch by JD Conley <jconley@winfessor.com>.
+ (Fix for xmlns attribute output.)
+
+2002-12-05 Ville Palo <vi64p@koti.soon.fi>
+
+ * XmlQualifiedName.cs: Little fix to ToString () -method
+
+2002-12-04 Tim Haynes <thaynes@openlinksw.com>
+
+ * class/System.XML/System.Xml/XmlElement.cs: Made more refined
+ checks on attributeNode to fix 32262.
+
+2002-12-03 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlDocument.cs (CreateNavigator(XmlNode)) : reverted
+ * XmlTextWriter.cs (WriteStartElementInternal):
+ fixed when default namespace was specified, all descendants
+ fail to omit the default namespace declarations.
+ * XmlAttribute.cs,
+ XmlDocument.cs,
+ XmlNode.cs (internal XmlLang/XmlSpace) : implemented(defined)
+ * XmlAttribute.cs,
+ XmlDocumentFragment.cs,
+ XmlElement.cs (set_InnerXml): now uses XmlLang/XmlSpace
+ * XmlElement.cs (set_IsEmpty) : implemented
+ (WriteTo) : removed my improper indenting (Writer already done)
+ * XmlNode.cs (BaseURI) : fixed if ParentNode is null, NullPointerEx
+ (ConstructDOM) : implemented when xmlReader isn't XmlTextReader
+ ...and renamed XmlDocument.ConventionalParser to ReusableReader ;-)
+
+2002-12-01 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlNode.cs (RemoveChild):
+ bugfixed when XmlNode is Document OwnerDocument is null
+ * XmlDeclaration.cs (Value):
+ bugfixed regular expression pattern.
+ * XmlDocument.cs (CreateNavigator): bugfixed access modifier.
+
+2002-11-24 Duncan Mak <duncan@ximian.com>
+
+ * XmlImplementation.cs (HasFeature): Fixed a typo. Thanks for
+ Fabricio Barros Cabral (fx) on #mono for spotting it. This is his
+ first patch to Mono! ;-)
+
+2002-11-19 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * XmlNode.cs:
+ (AppendChild): readded refChild != null condition before throwing
+ "cannot insert this node in this position" exception. There's probably
+ a better solution. Fixes #34191.
+ (RemoveAll): changed following Atsushi instructions.
+
+
+2002-11-13 Duncan Mak <duncan@ximian.com>
+
+ * XmlElement.cs (IsEmpty): A temporary check-in to keep gtk-sharp
+ compiling.
+
+2002-11-14 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlDocument.cs : unified all constructors, added ConventionalParser,
+ implemented CloneNode() and CreateEntityReference(),
+ * XmlEntityReference.cs : set_Value, WriteContentTo, WriteTo
+ set BaseURI to MonoTODO
+ * XmlNode.cs : implemented PrependChild, modified ConstructDOM,
+ bugfix InsertAfter (incorrect prepending) and InsertBefore
+ (more than one DocumentElements hadn't caused errors)
+ * XmlTextReader.cs : unified all constructors,
+ added internal SetReaderContext(), SetReaderFragment()
+ bugfix (syntax check of PUBLIC / getting internal subset)
+
+2002-11-13 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ XmlAttribute.cs : set_InnerText, set_InnerXml, some check for set_Prefix
+ XmlAttributeCollection.cs : (indexer) this[localName, namespaceURI]
+ XmlCharacterData.cs : exchanged Data and Value
+ (for processing events and inheritance)
+ XmlDocumentFragment.cs : set_InnerXml
+ XmlSignificantWhitespace.cs : set_Value
+ XmlTextReader.cs : ReadAttributeValue
+
+2002-11-04 Atsushi Enomoto <gigna@kit.hi-ho.ne.jp>
+
+ XmlAttribute.cs: fixed missing internal 'OwnerElement''SetOwnerElement'
+
+2002-11-03 Atsushi Enomoto <gigna@kit.hi-ho.ne.jp>
+
+ * XmlAttributeCollection.cs : checks owner element.
+ implemented CopyTo, InsertAfter, InsertBefore, Prepend,
+ Remove, RemoveAt, SetNamedItem.
+ removed some logics that sets 'Parent' (that should be null)
+ * XmlDocument.cs : set_InnerXml, [PreserveWhitespace(incomplete)]
+ * XmlDocumentFragment.cs : get_InnerXml, WriteContentTo, WriteTo
+ * XmlElement.cs : implemented WriteTo, set_InnerText.
+ Fixed WriteTo() to add xmlns:* attributes when
+ writer.LookupPrefix() returned mismatching.
+ * XmlNamedNodeMap.cs : compare not only name but localname and nsuri.
+ Removing different prefixes for the same uri now runs correct.
+ added SetNamedItem(XmlNode node, int position_to_insert).
+ * XmlNode.cs : ConstructDOM (logically) creates XmlEntityReference,
+ XmlWhitespace, and XmlSignificantWhitespace
+
+2002-10-31 Atsushi Enomoto <gigna@kit.hi-ho.ne.jp>
+
+ * XmlDocument.cs : implemented CreateDocumentFragment()
+ * XmlElement.cs, XmlLinkedNode.cs :
+ moved LastLinkedChild from XmlElement to XmlLinkedNode.
+ * XmlEntityReference.cs : must throw NotImplementedException.
+ * XmlNode.cs :
+ + implemented InsertBefore() and then implemented InsertAfter()
+ and modified AppendChild() to call it.
+ + added logic to check ReadOnly, parent document equivalence,
+ and inserting any 'content' before/after DocumentElement.
+ + implemented Clone() [it is equals to CloneNode() by MS doc.]
+ + added logic in RemoveChild() to check parent of oldChild.
+ + fixed ConstructNamespaceManager() to internal only.
+
+2002-10-29 Atsushi Enomoto <gigna@kit.hi-ho.ne.jp>
+
+ * XmlAttribute.cs : add internal 'IsDefault' property
+ (equals to !Specified)
+ * XmlImplementation.cs : added 'internalNameTable' property.
+ * XmlDocument.cs :
+ + now allows "" for 'standalone' in CreateXmlDeclaration.
+ + implemented 'Implementation' property and constructor with it.
+ + added logic for appending name table (but still no use)
+ + implemented property 'DocumentType'
+ (but without internalSubset parsing. wait for next update.)
+ * XmlNode.cs :
+ + modified AppendChild() and RemoveChild() to support fragment.
+ + modified AppendChild() to remove newChild from its parent
+ when newChild is already in the other place.
+ + modified RemoveChild() to set parentNode null.
+ + modified ConstructDOM() to create DocumentType,
+ and fixed access modifier ('internal protected' to 'internal')
+ * XmlLinkedNode.cs : fixed 'NextSibling' to return null
+ when its parent is null.
+ * XmlDocumentFragment.cs : added internal override 'LastLinkedChild'
+ property to enable AppendChild() for this class.
+ * XmlTextReader.cs : appended private publicId and systemId fields.
+
+2002-10-28 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * XmlTextReader.cs: make it work when the underlying Stream is not
+ 'seekable'.
+
+2002-10-26 Piers Haken <piersh@friskit.com>
+
+ * XmlNode.cs: add virtual property XPathNodeType
+ * XmlAttribute.cs:
+ * XmlComment.cs:
+ * XmlDocument.cs:
+ * XmlElement.cs::
+ * XmlProcessingInstruction.cs:
+ * XmlSignificantWhitespace.cs:
+ * XmlText.cs:
+ * XmlWhitespace.cs: implement XPathNodeType property
+ * XmlDocumentNavigator.cs: use XPathNodeType property instead of switch
+
+2002-10-26 Piers Haken <piersh@friskit.com>
+
+ * XmlDocumentNavigator.cs: return invalid XPathNodeType (-1) for unknown node types.
+
+2002-10-23 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * XmlTextReader.cs: don't increment depth for entity references.
+
+2002-10-22 Tim Haynes <thaynes@openlinksw.com>
+
+ * - Fixed the duplication of xmlns:xx = yy when serializing the
+ XML for serialization
+
+ Fixed the unnecessary parsing/serializing when adding assemblies
+ for serialization
+
+ Avoided setting the XmlNode.InnerXml property
+ (as it's not implemented)
+
+ Fixed the usage/implementation of
+ XmlElement.GetElementsByTagName()
+
+2002-10-21 Duncan Mak <duncan@ximian.com>
+
+ * XmlDocument.cs:
+ * XmlElement.cs:
+ * XmlNode.cs:
+ * XmlTextReader.cs: Implementation for XmlNode.InnerXml from
+ Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>.
+
+2002-10-18 Duncan Mak <duncan@ximian.com>
+
+ * XmlDocument.cs: Applied a patch by Atsushi Enomoto
+ <ginga@kit.hi-ho.ne.jp>.
+
+2002-10-12 A.Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlDocument.cs (ImportNode): Implemented
+
+2002-10-06 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * XmlDocument.cs: one more Load method implemented.
+ * XmlTextReader.cs: Depth now works.
+
+2002-09-22 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * XmlConvert.cs: IsInvalid is now internal.
+ * XmlNamespaceManager.cs: implemented RemoveNamespace
+ * XmlTextReader.cs: return BaseURI and Encoding from the parser.
+ * XmlTextWriter.cs: implemented WriteName and WriteNmToken.
+
+2002-09-19 Matt Hunter <mahunter@tconl.com>
+
+ * XmlElement.cs: Implementing SetAttributeNode(localName,namespaceURI)
+ * XmlAttributeCollection.cs: Implemented Append (XmlAttribute)
+
+2002-09-19 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * XmlConvert.cs: finished implementation.
+ * XmlTextReader.cs: fixed #30239.
+ * XmlTextWriter.cs: fixed #30240.
+
+2002-09-15 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * XmlTextReader.cs: line and position begin with 1.
+
+2002-09-13 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * XmlException.cs: added a new internal constructor for IXmlLineInfo
+ and output line and position info in Message.
+
+ * XmlReader.cs: implemented missing bits.
+
+2002-09-12 Piers Haken <piersh@friksit.com>
+
+ * XmlDocumentNavigator.cs: implement MoveToId()
+
+2002-09-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * XmlTextWriter.cs: fixed bug #29886.
+
+2002-08-26 Ravi Pratap <ravi@ximian.com>
+
+
+ * XmlAttribute.cs (InnerText): Implement getting this property.
+
+ * XmlNode.cs (InnerText): Ensure that we append only values of
+ text nodes.
+
+2002-08-26 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * XmlWriter.cs: made ws and namespaceManager protected. mcs has a bug
+ that allowed compiling this.
+ [ FIXME: filed bug #29435. mcs should have failed on this ]
+
+2002-08-25 Tim Coleman <tim@timcoleman.com>
+ * XmlNode.cs:
+ Change CreateNavigator to not be virtual.
+ * XmlElement.cs:
+ Add set_Prefix and InnerText accessors.
+ * XmlEntityReference.cs:
+ Add set_Value accessor.
+ * XmlTextWriter.cs:
+ Make objects which should be private private.
+ * XmlWriter.cs:
+ Remove WriteStartElementInternal abstract definition.
+ * XmlValidatingReader.cs:
+ New stubs added.
+
+2002-08-22 Jason Diamond <jason@injektilo.org>
+
+ * XmlAttributeCollection.cs, XmlElement.cs: Implementation of RemoveAll
+ and RemoveAllAttributes courtesy of Matt Hunter <xrkune@tconl.com>.
+
+2002-08-22 Jason Diamond <jason@injektilo.org>
+
+ * XmlElement.cs: Correction to previous GetElementsByTagName patch
+ courtesy of Matt Hunter <xrkune@tconl.com>.
+
+2002-08-22 Jason Diamond <jason@injektilo.org>
+
+ * XmlDocument.cs, XmlElement.cs: Added implementation of namepsace
+ qualified GetElementsByTagName courtesy of Matt Hunter
+ <xrkune@tconl.com>.
+
+2002-08-19 Jason Diamond <jason@injektilo.org>
+
+ * XmlDocument.cs, XmlElement.cs: Added implementation of
+ GetElementsByTagName courtesy of Matt Hunter <xrkune@tconl.com>.
+
+2002-08-16 Jason Diamond <jason@injektilo.org>
+
+ * XmlElement.cs: Fixed writing out qualified elements courtesy of
+ Marcus Bürgel <marcus.buergel@gmx.de>.
+
+2002-08-13 Tim Coleman <tim@timcoleman.com>
+ * XmlTextWriter.cs:
+ Partial implementation of WriteQualifiedName ().
+
+2002-08-07 Kral Ferch <kral_ferch@hotmail.com>
+ * XmlCharacterData.cs: Implemented AppendData(), DeleteData(),
+ InsertData(), and ReplaceData(). These methods fire the
+ NodeChanging and NodeChanged events.
+
+ * XmlDocument.cs: Fixed bugs in onNodeChanged() and onNodeChanging().
+
+ * XmlNode.cs: AppendChild() fires NodeInserting and NodeInserted events.
+ RemoveAll() and RemoveChild() fire NodeRemoving and NodeRemoved events.
+
+2002-08-03 Tim Coleman <tim@timcoleman.com>
+ * XmlNamespaceManager.cs:
+ .Net allows the empty namespace to be redefined
+ at a later point, but the current implementation
+ did not. This fixes a hashtable conflict.
+
+2002-07-26 Tim Coleman <tim@timcoleman.com>
+ * XmlTextWriter.cs:
+ When given a textwriter, check to see if it has a
+ null encoding. This was being done for other inputs
+ than a textwriter.
+
+Wed Jul 24 13:16:19 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * XmlTextReader.cs: rough line/column support.
+
+2002-07-23 Duncan Mak <duncan@ximian.com>
+
+ * XmlConvert.cs: Implement the ToDateTime method. ToDateTime
+ (string, string []) is particularly strange.
+
+ * XmlException.cs: Remember to call the base serialization
+ constructor.
+
+ * XmlNodeReader.cs: Keep a new variable to store the Depth.
+
+2002-07-14 Jason Diamond <jason@injektilo.org>
+
+ * XmlAttribute.cs: Removed ownerElement field since we can reuse
+ parentNode field.
+
+ * XmlDocumentNavigator.cs: MoveToParent now moves to the OwnerElement
+ if the current node is an attribute.
+
+ * XmlElement.cs: SetAttributeNode now sets the new attribute's
+ owner element.
+
+2002-07-12 Jason Diamond <jason@injektilo.org>
+
+ * XmlDocument.cs: If null was passed in for prefix or namespaceURI when
+ creating an element, use String.Empty instead.
+
+2002-07-12 Piers Haken <piersh@friksit.com>
+
+ * XmlAttributeCollection.cs: implement some ItemOf indexers
+ * XmlNamedNodeMap.cs: add internal 'Nodes' accessor for the nodeList field
+ * XmlNode.cs: SelectNodes: return empty XmlNodeList, not null
+
+2002-07-06 Ajay kumar Dwivedi <adwiv@yahoo.com>
+
+
+2002-10-26 Piers Haken <piersh@friskit.com>
+
+ * XmlDocumentNavigator.cs: return invalid XPathNodeType (-1) for unknown node types.
+
+2002-10-23 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * XmlTextReader.cs: don't increment depth for entity references.
+
+2002-10-22 Tim Haynes <thaynes@openlinksw.com>
+
+ * - Fixed the duplication of xmlns:xx = yy when serializing the
+ XML for serialization
+
+ Fixed the unnecessary parsing/serializing when adding assemblies
+ for serialization
+
+ Avoided setting the XmlNode.InnerXml property
+ (as it's not implemented)
+
+ Fixed the usage/implementation of
+ XmlElement.GetElementsByTagName()
+
+2002-10-21 Duncan Mak <duncan@ximian.com>
+
+ * XmlDocument.cs:
+ * XmlElement.cs:
+ * XmlNode.cs:
+ * XmlTextReader.cs: Implementation for XmlNode.InnerXml from
+ Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>.
+
+2002-10-18 Duncan Mak <duncan@ximian.com>
+
+ * XmlDocument.cs: Applied a patch by Atsushi Enomoto
+ <ginga@kit.hi-ho.ne.jp>.
+
+2002-10-12 A.Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlDocument.cs (ImportNode): Implemented
+
+2002-10-06 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * XmlDocument.cs: one more Load method implemented.
+ * XmlTextReader.cs: Depth now works.
+
+2002-09-22 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * XmlConvert.cs: IsInvalid is now internal.
+ * XmlNamespaceManager.cs: implemented RemoveNamespace
+ * XmlTextReader.cs: return BaseURI and Encoding from the parser.
+ * XmlTextWriter.cs: implemented WriteName and WriteNmToken.
+
+2002-09-19 Matt Hunter <mahunter@tconl.com>
+
+ * XmlElement.cs: Implementing SetAttributeNode(localName,namespaceURI)
+ * XmlAttributeCollection.cs: Implemented Append (XmlAttribute)
+
+2002-09-19 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * XmlConvert.cs: finished implementation.
+ * XmlTextReader.cs: fixed #30239.
+ * XmlTextWriter.cs: fixed #30240.
+
+2002-09-15 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * XmlTextReader.cs: line and position begin with 1.
+
+2002-09-13 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * XmlException.cs: added a new internal constructor for IXmlLineInfo
+ and output line and position info in Message.
+
+ * XmlReader.cs: implemented missing bits.
+
+2002-09-12 Piers Haken <piersh@friksit.com>
+
+ * XmlDocumentNavigator.cs: implement MoveToId()
+
+2002-09-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * XmlTextWriter.cs: fixed bug #29886.
+
+2002-08-26 Ravi Pratap <ravi@ximian.com>
+
+
+ * XmlAttribute.cs (InnerText): Implement getting this property.
+
+ * XmlNode.cs (InnerText): Ensure that we append only values of
+ text nodes.
+
+2002-08-26 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * XmlWriter.cs: made ws and namespaceManager protected. mcs has a bug
+ that allowed compiling this.
+ [ FIXME: filed bug #29435. mcs should have failed on this ]
+
+2002-08-25 Tim Coleman <tim@timcoleman.com>
+ * XmlNode.cs:
+ Change CreateNavigator to not be virtual.
+ * XmlElement.cs:
+ Add set_Prefix and InnerText accessors.
+ * XmlEntityReference.cs:
+ Add set_Value accessor.
+ * XmlTextWriter.cs:
+ Make objects which should be private private.
+ * XmlWriter.cs:
+ Remove WriteStartElementInternal abstract definition.
+ * XmlValidatingReader.cs:
+ New stubs added.
+
+2002-08-22 Jason Diamond <jason@injektilo.org>
+
+ * XmlAttributeCollection.cs, XmlElement.cs: Implementation of RemoveAll
+ and RemoveAllAttributes courtesy of Matt Hunter <xrkune@tconl.com>.
+
+2002-08-22 Jason Diamond <jason@injektilo.org>
+
+ * XmlElement.cs: Correction to previous GetElementsByTagName patch
+ courtesy of Matt Hunter <xrkune@tconl.com>.
+
+2002-08-22 Jason Diamond <jason@injektilo.org>
+
+ * XmlDocument.cs, XmlElement.cs: Added implementation of namepsace
+ qualified GetElementsByTagName courtesy of Matt Hunter
+ <xrkune@tconl.com>.
+
+2002-08-19 Jason Diamond <jason@injektilo.org>
+
+ * XmlDocument.cs, XmlElement.cs: Added implementation of
+ GetElementsByTagName courtesy of Matt Hunter <xrkune@tconl.com>.
+
+2002-08-16 Jason Diamond <jason@injektilo.org>
+
+ * XmlElement.cs: Fixed writing out qualified elements courtesy of
+ Marcus Bürgel <marcus.buergel@gmx.de>.
+
+2002-08-13 Tim Coleman <tim@timcoleman.com>
+ * XmlTextWriter.cs:
+ Partial implementation of WriteQualifiedName ().
+
+2002-08-07 Kral Ferch <kral_ferch@hotmail.com>
+ * XmlCharacterData.cs: Implemented AppendData(), DeleteData(),
+ InsertData(), and ReplaceData(). These methods fire the
+ NodeChanging and NodeChanged events.
+
+ * XmlDocument.cs: Fixed bugs in onNodeChanged() and onNodeChanging().
+
+ * XmlNode.cs: AppendChild() fires NodeInserting and NodeInserted events.
+ RemoveAll() and RemoveChild() fire NodeRemoving and NodeRemoved events.
+
+2002-08-03 Tim Coleman <tim@timcoleman.com>
+ * XmlNamespaceManager.cs:
+ .Net allows the empty namespace to be redefined
+ at a later point, but the current implementation
+ did not. This fixes a hashtable conflict.
+
+2002-07-26 Tim Coleman <tim@timcoleman.com>
+ * XmlTextWriter.cs:
+ When given a textwriter, check to see if it has a
+ null encoding. This was being done for other inputs
+ than a textwriter.
+
+Wed Jul 24 13:16:19 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * XmlTextReader.cs: rough line/column support.
+
+2002-07-23 Duncan Mak <duncan@ximian.com>
+
+ * XmlConvert.cs: Implement the ToDateTime method. ToDateTime
+ (string, string []) is particularly strange.
+
+ * XmlException.cs: Remember to call the base serialization
+ constructor.
+
+ * XmlNodeReader.cs: Keep a new variable to store the Depth.
+
+2002-07-14 Jason Diamond <jason@injektilo.org>
+
+ * XmlAttribute.cs: Removed ownerElement field since we can reuse
+ parentNode field.
+
+ * XmlDocumentNavigator.cs: MoveToParent now moves to the OwnerElement
+ if the current node is an attribute.
+
+ * XmlElement.cs: SetAttributeNode now sets the new attribute's
+ owner element.
+
+2002-07-12 Jason Diamond <jason@injektilo.org>
+
+ * XmlDocument.cs: If null was passed in for prefix or namespaceURI when
+ creating an element, use String.Empty instead.
+
+2002-07-12 Piers Haken <piersh@friksit.com>
+
+ * XmlAttributeCollection.cs: implement some ItemOf indexers
+ * XmlNamedNodeMap.cs: add internal 'Nodes' accessor for the nodeList field
+ * XmlNode.cs: SelectNodes: return empty XmlNodeList, not null
+
+2002-07-06 Ajay kumar Dwivedi <adwiv@yahoo.com>
+
+ * XmlTextWriter: Fixed Indentation. IndentationOverridden should
+ not be set when inside a attribute.
+
+2002-07-06 Ajay kumar Dwivedi <adwiv@yahoo.com>
+
+ * XmlTextWriter: In WriteStartElement, if namespace is null and
+ prefix is null|empty do not write out xmlns=""
+
+ * XmlWriter: WriteStartElement calls the virtual method with null
+ argument instead of empty string.
+
+2002-07-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * XmlTextReader.cs: implemented .ctor (Stream).
+
+2002-06-26 Duncan Mak <duncan@ximian.com>
+
+ * XmlNodeReader.cs: Implementation of most of the properties, and
+ some of the related methods.
+
+2002-06-23 Piers Haken <piersh@friskit.com>
+
+ * XmlDocumentNavigator.cs: implement Clone()
+ * XmlElement.cs: remove bogus unimplemented override of InnerText
+ * XmlNode.cs: implment SelectNodes/SelectSingleNode
+ * XmlNodeArrayList.cs: new support class for SelectNodes
+
+2002-06-21 Ajay kumar Dwivedi <adwiv@yahoo.com>
+
+ * XmlQualifiedName: Name and Namespaces are never null. If null is passed
+ to the constructor, set them to empty strings.
+ Fixed the Operators.
+
+2002-06-18 Ajay kumar Dwivedi <adwiv@yahoo.com>
+
+ * XmlTextReader.cs: HasLineInfo returns false instead of throwing an
+ Exception.
+
+2002-06-14 Duncan Mak <duncan@ximian.com>
+
+ * XmlConvert.cs: Added CLSCompliant attributes to methods.
+
+2002-06-12 Duncan Mak <duncan@ximian.com>
+
+ * XmlCharacterData.cs (Value): Throw an ArgumentException in the
+ set block if the node is read-only.
+
+2002-06-10 Ajay kumar Dwivedi <adwiv@yahoo.com>
+ * XmlConstruct.cs : New Internal class with Helper methods for
+ Checking XmlConstructs
+ * XmlConvert.cs: Implemented most of the methods
+
+2002-06-08 Duncan Mak <duncan@ximian.com>
+
+ * XmlDocument.cs (Load):
+ Added bits to Load (string) for BaseURI support.
+
+ * XmlAttribute.cs (BaseURI):
+ * XmlDocument.cs (BaseURI):
+ * XmlEntity.cs (BaseURI): Implemented.
+
+2002-05-27 Jason Diamond <jason@injektilo.org>
+
+ * XmlDocumentNavigator.cs: Added file to directory.
+
+ * XmlNode.cs (CreateNavigator): Implemented.
+ (InnerText): Implemented.
+
+ * XmlDocument.cs (NamespaceURI, Prefix): Return String.Empty instead of
+ throwing exception.
+ (Load(XmlReader)): Allow for namespace qualified attributes.
+
+ * XmlElement.cs: Implemented GetAttribute(string, string) and both
+ GetAttributeNode overloads.
+ (SetAttributeNode(XmlAttribute)): Implemented.
+
+ * XmlNamedNodeMap.cs: Fixed copy/paste bugs in GetNamedItem(string, string)
+ and RemoveNamedItem(string, string).
+
+ * XmlLinkedNode.cs (PreviousSibling): Implemented.
+
+ * XmlTextReader.cs: Added code to maintain the order of attributes as
+ they're parsed. XML doesn't require this but Microsoft's parser does it and
+ matching them makes testing easier so now we have it, too.
+
+2002-05-26 Miguel de Icaza <miguel@ximian.com>
+
+ * XmlDocument.cs: Implement the Save methods.
+
+2002-05-08 Mike Kestner <mkestner@speakeasy.net>
+
+ * XmlNamedNodeMap.cs (SetNamedItem): Fixed a copy/paste bug.
+
+2002-04-28 Duncan Mak <duncan@ximian.com>
+
+ * XmlSignificantWhitespace.cs (Value):
+ * XmlWhitespace.cs (Value): Added MonoTODO to the 'set'
+ block. Added new private method, IsValidWhitespaceChar, for
+ checking.
+
+2002-04-16 Duncan Mak <duncan@ximian.com>
+
+ * XmlParserContext.cs (NameTable): Fixed a typo in the set block.
+
+2002-04-12 Duncan Mak <duncan@ximian.com>
+
+ * XmlAttribute.cs (Prefix): Added preliminary code for set block,
+ added comment on work that needs to be done here. A new MonoTODO item.
+
+ * XmlDocument.cs (ctor): Corrected constructor signature, changed
+ parameter from 'NameTable' to 'XmlNameTable'.
+
+ * XmlDocumentFragment.cs (InnerXml): Added missing set block.
+
+ * XmlCaseOrder.cs: Moved to System.Xml.XPath.
+
+2002-04-10 Duncan Mak <duncan@ximian.com>
+
+ * XmlNodeReader.cs: Initial stubs for the class.
+
+2002-04-08 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlAttributes.cs: InnerXml getter, WriteContentTo, and WriteTo
+ implementations.
+
+ * XmlDeclaration.cs: WriteTo implementation.
+
+ * XmlDocument.cs: InnerXml getter implementation.
+
+ * XmlElement.cs: InnerXml getter implementation.
+
+ * XmlNode.cs: Removed MonoTODO attrib on OuterXml.
+
+ * XmlSignificantWhitespace.cs: WriteTo implementation.
+
+ * XmlText.cs: WriteContentTo and WriteTo implementation.
+
+ * XmlTextWriter.cs: WriteRaw implementation.
+
+ * XmlWhitespace.cs: WriteContentTo and WriteTo implementations.
+
+2002-04-05 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlAttributes.cs: Added reminder MonoTODO to set NamespaceURI
+ if prefix in constructor is one of the default ones.
+
+ * XmlCharacterData.cs: Returns String.Empty for Value and Data
+ even when constructed with null.
+
+ * XmlDeclaration.cs: Value doesn't put encoding or standalone
+ in if they are empty.
+
+ * XmlDocument.cs: Implemented CreateNode methods and this caused
+ the changes in the other files in this checkin.
+
+ * XmlProcessingInstruction.cs: Returns String.Empty for Value and Data
+ even when constructed with null.
+
+ * XmlWhitespace.cs: Changed Value 'get' to return Data.
+
+2002-04-01 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlTextWriter.cs: Impls for WriteEndDocument and WriteFullEndElement.
+
+2002-03-31 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlTextWriter.cs: Impls for LookupPrefix, WriteBase64,
+ and WriteCharEntity.
+
+ * XmlWrite.cs: Fixed bug where attribute namespace decl
+ was pushing a scope onto the namespace manager when it shouldn't
+ have been.
+
+2002-03-31 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlTextWriter.cs: Some tweaks for WriteAttibuteString
+ in different states (no open start element, in WriteState.Content mode).
+
+2002-03-29 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlTextWriter.cs: XmlLang and XmlSpace properties
+ and WriteWhitespace.
+
+ * XmlTextWriterOpenElement.cs: scope support for XmlLang
+ and XmlSpace.
+
+2002-03-29 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlTextWriter.cs: Working on Attribute methods.
+
+ * XmlWriter.cs: Working on Attribute methods.
+
+2002-03-28 Duncan Mak <duncan@ximian.com>
+
+ * XmlDocument.cs (CreateWhitespace):
+ (CreateSignificantWhitespace): Removed extraneous call to the ToCharArray
+ method.
+
+ * XmlSignificantWhitespace.cs (Value): Removed MonoTODO attribute.
+
+2002-03-26 Duncan Mak <duncan@ximian.com>
+
+ * XmlDocument.cs (CreateDocumentType): Implemented.
+
+ * XmlNode.cs (Value): Implemented.
+
+ * XmlProcessingInstruction.cs (InnerText): Implemented. It works just
+ like XmlCharacterData.
+
+ * XmlDeclaration.cs (CloneNode):
+ * XmlDocument.cs (CreateXmlDeclaration): Added missing constructor
+ arguments.
+
+ * XmlCharacterData.cs (InnerText): Implemented. Funny that the
+ docs say it is the "The concatenated values of the node and all
+ the children of the node.". I wrote some test programs and
+ couldn't get any of the derived nodes to AppendChild. For now,
+ InnerText == Data == Value.
+ (Substring): Fixed typo.
+
+ * XmlDeclaration.cs (XmlDeclaration): Fixed the constructor parameter signature.
+
+ * XmlImplementation.cs (CreateDocument): Implemented.
+
+2002-03-25 Duncan Mak <duncan@ximian.com>
+
+ * XmlDeclaration.cs: Rewrote the class, fixed formatting, added
+ missing properties (InnerText, Value).
+
+ * XmlDocument.cs (CreateXmlDeclaration): Implemented.
+
+2002-03-23 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlTextWriter.cs: Impls for BaseStream and
+ Namespaces and WriteState.
+
+ * XmlWriter.cs: WriteState and WriteStartElementInternal.
+
+2002-03-23 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlNodeListChildren.cs: made class internal
+ instead of public. Shouldn't be visible outside
+ of System.Xml.
+
+ * XmlTextWriter.cs: Implementations for Formatting,
+ IndentChar, Indenting, QuoteChar, WriteStartDocument(standalone).
+ Suppresses encoding on xml declaration if null stream passed in.
+ Formats output including suppressing indentation for elements in
+ mixed content mode.
+
+ * XmlTextWriterOpenElement.cs: Initial checkin.
+ XmlTextWriter uses stack of these objects to track
+ state.
+
+2002-03-22 Mike Kestner <mkestner@speakeasy.net>
+
+ * XmlElement.cs: impl HasAttribute(string name).
+
+2002-03-22 Duncan Mak <duncan@ximian.com>
+
+ * XmlElement.cs: Reformatted.
+ (CloneNode) Corrected.
+
+ * XmlDocument.cs (CreateWhitespace):
+ (CreateSignificantWhitespace): Implemented.
+
+ * XmlAttribute.cs (CloneNode): Changed the child's CloneNode to
+ true, because Attributes have ChildNodes.
+
+2002-03-21 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlTextWriter.cs: WriteStartDocument tracks state, writes out
+ xml declaration along with encoding. WriteEndElement throws
+ exception if no WriteStartElement exists.
+
+2002-03-20 Duncan Mak <duncan@ximian.com>
+
+ * XmlEntityReference.cs (CloneNode): Implemented.
+
+ * XmlException.cs (Message): Implemented. We need to cache the
+ message string because SystemException doesn't expose 'message'
+ from Exception.
+
+ * XmlText.cs (Value): Added in the missing Value property.
+
+2002-03-20 Duncan Mak <duncan@ximian.com>
+
+ * XmlAttribute.cs (CloneNode): Implemented.
+
+ * XmlDocumentFragment.cs (CloneNode): Implemented.
+
+ * XmlElement.cs (CloneNode): Implemented.
+
+2002-03-19 Duncan Mak <duncan@ximian.com>
+
+ * XmlNotation.cs: Added to CVS.
+
+ * XmlAttribute.cs (CloneNode): First crack at the CloneNode method.
+
+ * XmlCDataSection.cs (CloneNode): Implemented.
+
+ * XmlDocumentFragment.cs: Reformatted and added the missing properties
+ (InnerXml, OwnerDocument, ParentNode).
+ (CloneNode): Implemented.
+
+ * XmlSignificantWhitespace.cs (CloneNode): Implemented.
+ (Value) Implemented the 'get' property.
+
+ * XmlWhitespace.cs (Module): implemented.
+
+2002-03-19 Jason Diamond <jason@injektilo.org>
+
+ * XmlDocument.cs: Fixed typo in Load that was duplicating the LocalName
+ in the prefix.
+
+2002-03-18 Jason Diamond <jason@injektilo.org>
+
+ * XmlTextReader.cs: Don't restore properties after reading last
+ attribute on an element.
+
+ * XmlDocument.cs: Move back to element after reading attributes
+ so that IsEmptyElement test succeeds.
+
+2002-03-18 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlNamespaceManager.cs: Implemented LookupPrefix.
+
+ * XmlTextWriter.cs: Implemented namespace and prefix support.
+
+2002-03-18 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlTextReader.cs: Restores properties after
+ reading last attribute on an element.
+
+ * XmlNode.cs: AppendChild sets the parent
+ on the child.
+
+2002-03-17 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlCDataSection.cs: Formatting, Implementation for WriteTo.
+
+ * XmlComment.cs: Implementations for WriteTo and WriteContentTo.
+
+ * XmlElement.cs: Fixed bug in WriteTo.
+
+ * XmlProcessingInstruction.cs: Formatting.
+
+ * XmlTextWriter.cs: Implementations for Close, WriteCData, WriteComment,
+ fixes for WriteEndElement, WriteProcessingInstruction.
+
+2002-03-17 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlDocument.cs: Implementations for WriteTo() and WriteContentTo(),
+ had Load() add PIs to the document, moved onXXX methods to alphabetical
+ order in the file.
+
+ * XmlElement.cs: Implementations for WriteTo() and WriteContentTo().
+
+ * XmlNode.cs: Implementations for InnerXml Get and OuterXml.
+
+ * XmlProcessingInstruction.cs: Implementations for WriteTo() and
+ WriteContentTo().
+
+ * XmlTextWriter.cs: Implementations for WriteEndElement,
+ WriteProcessingInstruction, WriteStartElement, and WriteString.
+
+ * XmlWriter.cs: Implemented WriteStartElement() methods.
+
+2002-03-15 Duncan Mak <duncan@ximian.com>
+
+ * XmlEntity.cs: Added to CVS. Need to implement BaseURI and
+ InnerText once I know what they do.
+
+ * XmlDocumentType.cs (XmlDocumentType): Fix the constructor now
+ that we can properly chain constructors.
+ (CloneNode): implemented.
+ (WriteContentTo): Removed MonoTODO attribute as this method has no
+ effect in this class.
+
+ * XmlProcessingInstruction.cs (Value): Added the missing Set
+ block.
+ (InnerText): Added in, but not implemented.
+
+2002-03-14 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlTextWriter.cs: implemented constructors and
+ WriteCData and WriteComment.
+
+2002-03-14 Duncan Mak <duncan@ximian.com>
+
+ * XmlDocument.cs: Moved the NodeChanged EventHandler to its own
+ file, and updated the callbacks to reflect the change.
+ (XmlDocument): Added the NameTable constructor.
+ (NameTable): Also the NameTable property.
+
+ * XmlNodeChangedEventHandler.cs: Added, replacing the version that
+ was in XmlDocument.cs. It has two arguments now (object,
+ EventArgs) , instead of one (object).
+
+2002-03-14 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlWriter.cs: Formatting.
+
+ * XmlTextWriter.cs: Initial checkin.
+
+2002-03-14 Duncan Mak <duncan@ximian.com>
+
+ * Validation.cs: Removed, replaced by ValidationType.cs.
+
+ * ValidationType.cs: Added.
+
+2002-03-13 Duncan Mak <duncan@ximian.com>
+
+ * XmlException.cs: Made it [Serializable], implemented good ol'
+ GetObjectData, and the serialization constructor.
+
+ * XmlNamedNodeMap.cs (SetNamedItem): Check for the Name property.
+ (SetNamedItem): Reverted (added back in) the patch with the
+ ReadOnly checks. "Don't doubt yourself, my son... you were right!"
+
+ * XmlNamedNodeMap.cs (GetEnumerator): piggyback on the ArrayList implementation.
+ (GetNamedItem (string, string)): implemented.
+ (RemoveNamedItem): implemented.
+ (SetNamedItem): implemented.
+
+2002-03-12 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlAttribute.cs: Moved a method from amongst properties down to
+ it's alphabetical position in the methods section.
+
+ * XmlNode.cs: Passes in 'this' to XmlNodeList constructor instead of
+ last linked child. Set XmlNode base class to return false for IsReadOnly().
+ Implemented GetEnumerator() and RemoveChild().
+
+ * XmlNodeListChildren.cs: Now stores the parent instead of the last child.
+ This is to support the behavior that the Enumerator doesn't become invalid
+ when changes to the children occur. Flushed out rest of implementation for
+ MoveNext, Current, and Reset.
+
+2002-03-12 Duncan Mak <duncan@ximian.com>
+
+ * XmlCharacterData.cs: Reformatted the properties for better readability.
+
+ * XmlLinkedNode.cs: Removed the awful boxy comments.
+
+ * XmlNamedNodeMap.cs (Count):
+ (Item): Implemented. Tests will be coming.
+
+ * XmlEntityReference.cs:
+ * XmlSignificantWhitespace.cs: Implemented these classes except for
+ the Clone, WriteContentTo and WriteTo methods. Will have to
+ investigate into these later.
+
+2002-03-11 Duncan Mak <duncan@ximian.com>
+
+ * IHasXmlNode.cs: Added to CVS.
+
+2002-03-08 Jason Diamond <jason@injektilo.org>
+
+ * XmlParserContext.cs: Added missing constructors and missing Encoding
+ property.
+
+ * XmlTextReader.cs: Start using the XmlParserContext class.
+
+2002-03-08 Jason Diamond <jason@injektilo.org>
+
+ * XmlTextReader.cs: Implemented MoveToElement and MoveToFirstAttribute.
+
+2002-03-08 Mike Kestner <mkestner@speakeasy.net>
+
+ * XmlNode.cs (Item): Implemented both indexers.
+
+2002-03-08 Jason Diamond <jason@injektilo.org>
+
+ * DomEncodingType.cs, TreePosition.cs, XPathNodeType.cs, XmlDataType.cs,
+ XmlExceptionCode.cs, XmlSortOrder.cs, XmlUtil.cs: Removed files.
+
+2002-03-08 Jason Diamond <jason@injektilo.org>
+
+ * XmlAttribute.cs: Attribute nodes are supposed to store their values
+ as child nodes so updated to reflect that.
+
+ * XmlDocument.cs, XmlElement.cs, XmlNode.cs: Moved code that was
+ duplicated in XmlDocument and XmlElement into XmlNode so that it
+ wouldn't have to be duplicated in XmlAttribute, too.
+
+2002-03-08 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlNodeList.cs, XmlDocument.cs, XmlLinkedNode.cs,
+ XmlNode.cs: Formatting.
+
+ * XmlNodeListChildren.cs: Implementation of XmlNodeList
+ for XmlNode.ChildNodes property.
+
+ * XmlNodeListAsArrayList.cs: Removed file. Using different
+ data structure (circular list) in XmlNode so this file
+ is no longer valid.
+
+ * XmlDocument.cs, XmlElement.cs: New ChildNodes tests found
+ bug in setter property of LastLinkedChild so fixed it.
+
+2002-03-06 Jason Diamond <jason@injektilo.org>
+
+ * XmlInputSource.cs, XmlNames_1_0.cs, XmlParse.cs: Removed files.
+ We already have a parser in XmlTextReader.
+
+ * XmlException.cs: Removed constructor accepting XmlInputSource.
+
+2002-03-06 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlNode.cs: Rewrote this class from scratch with
+ MonoToDo attribs and NotImplementedExceptions. Now defines an
+ internal LastLinkedNode property to aid the new implementation.
+ XmlNodes only have ref to owner doc and parent nodes now.
+
+ * XmlLinkedNode.cs: Added NextLinkedSibling internal property
+ and ref to next sibling to support walking our circular child
+ node list.
+
+ * XmlDocument.cs: Added ref to last child node and overrides
+ XmlNode's internal LastLinkedChild property to support walking
+ our circular child node list.
+
+2002-03-02 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlProcessingInstructions.cs: Class was empty. Implemented
+ constructor, properties, and CloneNode() method. Put in
+ MonoToDo attrib for remaining methods.
+
+ * XmlComment.cs: Reformatted and put in MonoToDo attribs.
+ Got rid of helper methods and fields since they were no
+ longer needed.
+
+ * XmlLinkedNode.cs: Reformatted and put in MonoToDo attribs.
+
+ * XmlDocument.cs: Added code to Load(XmlReader) to create XmlComment,
+ XmlCDataSection, and XmlProcessingInstruction nodes. Implemented
+ Createxxx() methods for those three node types.
+
+2002-03-02 Jason Diamond <jason@injektilo.org>
+
+ * XmlDocument.cs: Implemented the remaining CreateElement and
+ CreateAttribute methods.
+
+ * XmlAttribute.cs: Re-implemented.
+
+ * XmlElement.cs: Set owner element on attributes. Reformatted.
+
+2002-03-02 Jason Diamond <jason@injektilo.org>
+
+ * XmlTextReader.cs: Implemented MoveToNextAttribute().
+
+ * XmlDocument.cs: Reformatted. Adding missing methods and MonoTODO
+ attributes. Create attribute nodes while loading. Implemented
+ Load(string) and CreateTextNode().
+
+ * XmlCharacterData.cs, XmlText.cs: Re-implemented.
+
+ * XmlCDataSection.cs, XmlComment.cs: Call correct constructor in
+ XmlCharacterData.
+
+ * XmlNamedNodeMap.cs, XmlAttributeCollection.cs: Stubbed out.
+
+2002-03-02 Mike Kestner <mkestner@speakeasy.net>
+
+ * XmlAttribute.cs : Using fix.
+ * XmlDocument.cs (CreateAttribute(String)): Implement.
+
+2002-03-02 Jason Diamond <jason@injektilo.org>
+
+ * XmlNamespaceManager.cs: Atomize prefixes and namespaces strings in
+ the name table.
+
+2002-02-28 Jason Diamond <jason@injektilo.org>
+
+ * XmlDocument.cs, XmlNode.cs: Initial implementation of LoadXml
+ courtesy of Kral Ferch <kral.ferch@hotmail.com>.
+
+2002-02-28 Jason Diamond <jason@injektilo.org>
+
+ * XmlException.cs, XmlReader.cs, XmlTextReader.cs: Reformatted,
+ added missing members and MonoTODO attributes.
+
+ * XmlTextReader.cs: Throw XmlException instead of System.Exception.
+
+2002-02-27 Jason Diamond <jason@injektilo.org>
+
+ * XmlElement.cs: Reformatted, added missing members and MonoTODO
+ attributes.
+
+2002-02-26 Duncan Mak <duncan@ximian.com>
+
+ * XmlCDataSection.cs: Initial implementation.
+
+ * NameTable.cs: Fixed the whole thing. Wrote a NUnit test to test
+ it out. This should (hopefully) be correct.
+
+2002-02-26 Jason Diamond <jason@injektilo.org>
+
+ * XmlTextReader.cs: Apparently Microsoft's implementation treats
+ namespace declarations as attributes so we do now, too.
+
+ * XmlNamespaceManager.cs: HasNamespace fixed so that it only
+ checks the current scope.
+
+2002-02-26 Duncan Mak <duncan@ximian.com>
+
+ * XmlDocumentType.cs: Added a few hacks here and there to
+ temporarily fix the "I broke the build issue".
+
+2002-02-25 Jason Diamond <jason@injektilo.org>
+
+ * XmlDocument.cs, XmlElement.cs, XmlNode.xs, XmlNodeList.cs,
+ XmlNodeListAsArrayList.cs: Multiple fixes necessary to get
+ simple test to pass. The existing code is really shitty so I'll
+ probably start writing tests and refactoring before much else
+ can get done.
+
+2002-02-25 Duncan Mak <duncan@ximian.com>
+
+ * NameTable.cs: Implemented.
+
+ * XmlDeclaration.cs: It should inherit from XmlLinkedNode, not XmlNode.
+
+2002-02-24 Duncan Mak <duncan@ximian.com>
+
+ * XmlNodeOrder.cs: Added to CVS.
+
+ * XmlQualifiedName.cs: Fixed a warning from Equals ().
+
+ * XmlTokenizedType.cs: Added to CVS.
+
+ * XmlUrlResolver.cs: Added to CVS with one TODO task.
+
+2002-02-23 Duncan Mak <duncan@ximian.com>
+
+ * XmlQualifiedName.cs: Fixed ToString () and added the operators
+ (== and !=).
+
+2002-02-23 Jason Diamond <jason@injektilo.org>
+
+ * XmlTextReader.cs: Added support for qualified attributes.
+
+2002-02-23 Jason Diamond <jason@injektilo.org>
+
+ * XmlNamespaceManager.cs: Initial implementation.
+
+ * XmlTextReader.cs: Added support for NamespaceURI property on
+ elements.
+
+2002-02-23 Nick Drochak <ndrochak@gol.com>
+
+ * ChangeLog: Add the change log to this directory
+
+ * XmlQualifiedName.cs: Fixed compile errors so it would build. Still has
+ MonoTODO's
+
diff --git a/mcs/class/System.XML/System.Xml/Driver.cs b/mcs/class/System.XML/System.Xml/Driver.cs
new file mode 100644
index 00000000000..80f9cf32934
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/Driver.cs
@@ -0,0 +1,56 @@
+//
+// Driver.cs
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2001 Jason Diamond http://injektilo.org/
+//
+
+using System;
+using System.Xml;
+
+public class Driver
+{
+ public static void Main(string[] args)
+ {
+ XmlReader xmlReader = null;
+
+ if (args.Length < 1)
+ {
+ xmlReader = new XmlTextReader(Console.In);
+ }
+ else
+ {
+ xmlReader = new XmlTextReader(args[0]);
+ }
+
+ while (xmlReader.Read())
+ {
+ Console.WriteLine("NodeType = {0}", xmlReader.NodeType);
+ Console.WriteLine(" Name = {0}", xmlReader.Name);
+ Console.WriteLine(" IsEmptyElement = {0}", xmlReader.IsEmptyElement);
+ Console.WriteLine(" HasAttributes = {0}", xmlReader.HasAttributes);
+ Console.WriteLine(" AttributeCount = {0}", xmlReader.AttributeCount);
+ Console.WriteLine(" HasValue = {0}", xmlReader.HasValue);
+ Console.WriteLine(" Value = {0}", xmlReader.Value);
+ Console.WriteLine(" Depth = {0}", xmlReader.Depth);
+
+ if (xmlReader.HasAttributes)
+ {
+ while (xmlReader.MoveToNextAttribute())
+ {
+ Console.WriteLine(" AttributeName = {0}", xmlReader.Name);
+ Console.WriteLine(" AttributeValue = {0}", xmlReader.Value);
+
+ while (xmlReader.ReadAttributeValue())
+ {
+ Console.WriteLine(" AttributeValueNodeType = {0}", xmlReader.NodeType);
+ Console.WriteLine(" AttributeValueName = {0}", xmlReader.Name);
+ Console.WriteLine(" AttributeValueValue = {0}", xmlReader.Value);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/EntityHandling.cs b/mcs/class/System.XML/System.Xml/EntityHandling.cs
new file mode 100755
index 00000000000..c54b016b1e6
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/EntityHandling.cs
@@ -0,0 +1,29 @@
+// EntityHandling.cs
+//
+// This code was automatically generated from
+// ECMA CLI XML Library Specification.
+// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
+// Created: Wed, 5 Sep 2001 06:46:17 UTC
+// Source file: all.xml
+// URL: http://devresource.hp.com/devresource/Docs/TechPapers/CSharp/all.xml
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+
+
+namespace System.Xml {
+
+
+ /// <summary>
+ /// </summary>
+ public enum EntityHandling {
+
+ /// <summary>
+ /// </summary>
+ ExpandEntities = 1,
+
+ /// <summary>
+ /// </summary>
+ ExpandCharEntities = 2,
+ } // EntityHandling
+
+} // System.Xml
diff --git a/mcs/class/System.XML/System.Xml/Formatting.cs b/mcs/class/System.XML/System.Xml/Formatting.cs
new file mode 100755
index 00000000000..2586f58a04d
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/Formatting.cs
@@ -0,0 +1,29 @@
+// Formatting.cs
+//
+// This code was automatically generated from
+// ECMA CLI XML Library Specification.
+// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
+// Created: Wed, 5 Sep 2001 06:31:21 UTC
+// Source file: AllTypes.xml
+// URL: http://msdn.microsoft.com/net/ecma/AllTypes.xml
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+
+
+namespace System.Xml {
+
+
+ /// <summary>
+ /// </summary>
+ public enum Formatting {
+
+ /// <summary>
+ /// </summary>
+ None = 0,
+
+ /// <summary>
+ /// </summary>
+ Indented = 1,
+ } // Formatting
+
+} // System.Xml
diff --git a/mcs/class/System.XML/System.Xml/IHasXmlNode.cs b/mcs/class/System.XML/System.Xml/IHasXmlNode.cs
new file mode 100755
index 00000000000..6eaef10dcfa
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/IHasXmlNode.cs
@@ -0,0 +1,15 @@
+//
+// System.Xml.IHasXmlNode.cs
+//
+// Author: Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+namespace System.Xml
+{
+ public interface IHasXmlNode
+ {
+ XmlNode GetNode ();
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/IXmlLineInfo.cs b/mcs/class/System.XML/System.Xml/IXmlLineInfo.cs
new file mode 100644
index 00000000000..d49e1e93208
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/IXmlLineInfo.cs
@@ -0,0 +1,19 @@
+//
+// System.Xml.IXmlLineInfo.cs
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2001 Jason Diamond http://injektilo.org/
+//
+
+namespace System.Xml
+{
+ public interface IXmlLineInfo
+ {
+ int LineNumber { get; }
+ int LinePosition { get; }
+
+ bool HasLineInfo();
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/NameTable.cs b/mcs/class/System.XML/System.Xml/NameTable.cs
new file mode 100755
index 00000000000..c8533218040
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/NameTable.cs
@@ -0,0 +1,74 @@
+//
+// System.Xml.NameTable.cs
+//
+// Author: Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+using System;
+using System.Collections;
+
+namespace System.Xml
+{
+ public class NameTable : XmlNameTable
+ {
+ // Fields
+ Hashtable table;
+
+ // Constructor
+ public NameTable ()
+ : base ()
+ {
+ table = new Hashtable ();
+ }
+
+ // Method
+ public override string Add (string key)
+ {
+ if (table.Contains (key))
+ return (string) table [key];
+ else {
+ table.Add (key, key);
+ return key;
+ }
+ }
+
+ public override string Add (char[] key, int start, int len)
+ {
+ if (((0 > start) && (start >= key.Length))
+ || ((0 > len) && (len >= key.Length - len)))
+ throw new IndexOutOfRangeException ("The Index is out of range.");
+
+ if (len == 0)
+ return String.Empty;
+
+ string item = new string (key, start, len);
+
+ return Add (item);
+ }
+
+ public override string Get (string key)
+ {
+ if (! (table.Contains (key)))
+ return null;
+ else
+ return (string) table [key];
+
+ }
+
+ public override string Get (char[] array, int offset, int length)
+ {
+ if (((0 > offset) && (offset >= array.Length))
+ || ((0 > length) && (length >= array.Length - offset)))
+ throw new IndexOutOfRangeException ("The Index is out of range.");
+
+ if (length == 0)
+ return String.Empty;
+
+ string key = new string (array, offset, length);
+
+ return Get (key);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/Profile.cs b/mcs/class/System.XML/System.Xml/Profile.cs
new file mode 100644
index 00000000000..d16049576d1
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/Profile.cs
@@ -0,0 +1,47 @@
+// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// Profile.cs
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2001 Jason Diamond http://injektilo.org/
+//
+
+using System;
+using System.Xml;
+
+using System.IO;
+using System.Text;
+
+public class Profile
+{
+ public static void Main(string[] args)
+ {
+ XmlReader xmlReader = null;
+
+ if (args.Length < 1)
+ {
+ xmlReader = new XmlTextReader(Console.In);
+ }
+ else
+ {
+ xmlReader = new XmlTextReader(args[0]);
+ }
+
+ int nodes = 0;
+
+ DateTime start = DateTime.Now;
+
+ while (xmlReader.Read())
+ {
+ ++nodes;
+ }
+
+ DateTime end = DateTime.Now;
+
+ Console.WriteLine("time = {0}", end - start);
+
+ Console.WriteLine("nodes = {0}", nodes);
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/ReadState.cs b/mcs/class/System.XML/System.Xml/ReadState.cs
new file mode 100644
index 00000000000..6675af3990f
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/ReadState.cs
@@ -0,0 +1,41 @@
+// ReadState.cs
+//
+// This code was automatically generated from
+// ECMA CLI XML Library Specification.
+// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
+// Created: Wed, 5 Sep 2001 06:31:27 UTC
+// Source file: AllTypes.xml
+// URL: http://msdn.microsoft.com/net/ecma/AllTypes.xml
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+
+
+namespace System.Xml {
+
+
+ /// <summary>
+ /// </summary>
+ public enum ReadState {
+
+ /// <summary>
+ /// </summary>
+ Initial = 0,
+
+ /// <summary>
+ /// </summary>
+ Interactive = 1,
+
+ /// <summary>
+ /// </summary>
+ Error = 2,
+
+ /// <summary>
+ /// </summary>
+ EndOfFile = 3,
+
+ /// <summary>
+ /// </summary>
+ Closed = 4,
+ } // ReadState
+
+} // System.Xml
diff --git a/mcs/class/System.XML/System.Xml/TODOAttribute.cs b/mcs/class/System.XML/System.Xml/TODOAttribute.cs
new file mode 100644
index 00000000000..741cd760c1f
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/TODOAttribute.cs
@@ -0,0 +1,32 @@
+//
+// TODOAttribute.cs
+//
+// Author:
+// Ravi Pratap (ravi@ximian.com)
+//
+// (C) Ximian, Inc. http://www.ximian.com
+//
+
+namespace System.Xml {
+
+ /// <summary>
+ /// The TODO attribute is used to flag all incomplete bits in our class libraries
+ /// </summary>
+ ///
+ /// <remarks>
+ /// Use this to decorate any element which you think is not complete
+ /// </remarks>
+ [AttributeUsage (AttributeTargets.All)]
+ internal class MonoTODOAttribute : Attribute {
+
+ string comment;
+
+ public MonoTODOAttribute ()
+ {}
+
+ public MonoTODOAttribute (string comment)
+ {
+ this.comment = comment;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/ValidationType.cs b/mcs/class/System.XML/System.Xml/ValidationType.cs
new file mode 100755
index 00000000000..d746324e256
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/ValidationType.cs
@@ -0,0 +1,20 @@
+// System.Xml.ValidationType.cs
+//
+// Author:
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+//
+
+namespace System.Xml
+{
+ public enum ValidationType
+ {
+ None = 0,
+ Auto = 1,
+ DTD = 2,
+ XDR = 3,
+ Schema = 4,
+ }
+}
+
diff --git a/mcs/class/System.XML/System.Xml/WhitespaceHandling.cs b/mcs/class/System.XML/System.Xml/WhitespaceHandling.cs
new file mode 100644
index 00000000000..8e9962b367e
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/WhitespaceHandling.cs
@@ -0,0 +1,33 @@
+// WhitespaceHandling.cs
+//
+// This code was automatically generated from
+// ECMA CLI XML Library Specification.
+// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
+// Created: Wed, 5 Sep 2001 06:31:33 UTC
+// Source file: AllTypes.xml
+// URL: http://msdn.microsoft.com/net/ecma/AllTypes.xml
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+
+
+namespace System.Xml {
+
+
+ /// <summary>
+ /// </summary>
+ public enum WhitespaceHandling {
+
+ /// <summary>
+ /// </summary>
+ All = 0,
+
+ /// <summary>
+ /// </summary>
+ Significant = 1,
+
+ /// <summary>
+ /// </summary>
+ None = 2,
+ } // WhitespaceHandling
+
+} // System.Xml
diff --git a/mcs/class/System.XML/System.Xml/WriteState.cs b/mcs/class/System.XML/System.Xml/WriteState.cs
new file mode 100755
index 00000000000..7d387708782
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/WriteState.cs
@@ -0,0 +1,53 @@
+// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// System.Xml.WriteState
+//
+// Author:
+// Daniel Weber (daniel-weber@austin.rr.com)
+//
+// (C) 2001 Daniel Weber
+
+namespace System.Xml
+{
+
+
+ /// <summary>
+ /// </summary>
+ public enum WriteState {
+
+ /// <summary>
+ /// A write method has not been called.
+ /// </summary>
+ Start = 0,
+
+ /// <summary>
+ /// The prolog is being written.
+ /// </summary>
+ Prolog = 1,
+
+ /// <summary>
+ /// An element start tag is being written.
+ /// </summary>
+ Element = 2,
+
+ /// <summary>
+ /// An attribute is being written.
+ /// </summary>
+ Attribute = 3,
+
+ /// <summary>
+ /// Element content is being written.
+ /// </summary>
+ Content = 4,
+
+ /// <summary>
+ /// The close method has been called.
+ /// </summary>
+ Closed = 5,
+
+
+
+
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlAttribute.cs b/mcs/class/System.XML/System.Xml/XmlAttribute.cs
new file mode 100644
index 00000000000..167a9b18aba
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlAttribute.cs
@@ -0,0 +1,244 @@
+//
+// System.Xml.XmlAttribute
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2002 Jason Diamond http://injektilo.org/
+//
+
+using System;
+using System.Text;
+using System.Xml.XPath;
+
+namespace System.Xml
+{
+ public class XmlAttribute : XmlNode
+ {
+ #region Fields
+
+ private XmlLinkedNode lastChild;
+ private string localName;
+ private string namespaceURI;
+ private string prefix;
+ internal bool isDefault;
+ private XmlElement ownerElement;
+
+ #endregion
+
+ #region Constructor
+
+ [MonoTODO("need to set namespaceURI if prefix is recognized built-in ones like xmlns")]
+ protected internal XmlAttribute (
+ string prefix,
+ string localName,
+ string namespaceURI,
+ XmlDocument doc) : base (doc)
+ {
+ // What to be recognized is: xml:space, xml:lang, xml:base, and
+ // xmlns and xmlns:* (when XmlDocument.Namespaces = true only)
+ this.prefix = prefix;
+ this.localName = localName;
+ this.namespaceURI = namespaceURI;
+ }
+
+ #endregion
+
+ #region Properties
+
+ public override string BaseURI {
+ get {
+ return OwnerElement.BaseURI;
+ }
+ }
+
+ public override string InnerText {
+ get {
+ StringBuilder builder = new StringBuilder ();
+ AppendChildValues (this, builder);
+ return builder.ToString ();
+ }
+
+ set {
+ Value = value;
+ }
+ }
+
+ private void AppendChildValues (XmlNode parent, StringBuilder builder)
+ {
+ XmlNode node = parent.FirstChild;
+
+ while (node != null) {
+ builder.Append (node.Value);
+ AppendChildValues (node, builder);
+ node = node.NextSibling;
+ }
+ }
+
+ [MonoTODO ("Setter is incomplete(XmlTextReader.ReadAttribute is incomplete;No resolution for xml:lang/space")]
+ public override string InnerXml {
+ get {
+ // Not sure why this is an override. Passing through for now.
+ return base.InnerXml;
+ }
+
+ set {
+ XmlNamespaceManager nsmgr = ConstructNamespaceManager ();
+ XmlParserContext ctx = new XmlParserContext (OwnerDocument.NameTable, nsmgr, XmlLang, this.XmlSpace);
+ XmlTextReader xtr = OwnerDocument.ReusableReader;
+ xtr.SetReaderContext (BaseURI, ctx);
+ xtr.SetReaderFragment (new System.IO.StringReader ("'" + value.Replace ("'", "&apos;") + "'"), XmlNodeType.Attribute);
+
+ OwnerDocument.ReadAttributeNodeValue (xtr, this);
+ }
+ }
+
+ public override string LocalName {
+ get {
+ return localName;
+ }
+ }
+
+ public override string Name {
+ get {
+ return prefix != String.Empty ? prefix + ":" + localName : localName;
+ }
+ }
+
+ public override string NamespaceURI {
+ get {
+ return namespaceURI;
+ }
+ }
+
+ public override XmlNodeType NodeType {
+ get {
+ return XmlNodeType.Attribute;
+ }
+ }
+
+ internal override XPathNodeType XPathNodeType {
+ get {
+ return XPathNodeType.Attribute;
+ }
+ }
+
+ public override XmlDocument OwnerDocument {
+ get {
+ return base.OwnerDocument;
+ }
+ }
+
+ public virtual XmlElement OwnerElement {
+ get {
+ return ownerElement;
+ }
+ }
+
+ public override XmlNode ParentNode {
+ get {
+ // It always returns null (by specification).
+ return null;
+ }
+ }
+
+ [MonoTODO("setter incomplete (name character check, format check, wrong prefix&nsURI)")]
+ // We gotta do more in the set block here
+ // We need to do the proper tests and throw
+ // the correct Exceptions
+ //
+ // Wrong cases are: (1)check readonly, (2)check character validity,
+ // (3)check format validity, (4)this is attribute and qualifiedName != "xmlns"
+ // (5)when argument is 'xml' or 'xmlns' and namespaceURI doesn't match
+ public override string Prefix {
+ set {
+ if(IsReadOnly)
+ throw new XmlException ("This node is readonly.");
+
+ XmlNamespaceManager nsmgr = ConstructNamespaceManager ();
+ string nsuri = nsmgr.LookupNamespace (value);
+ if(nsuri == null)
+ throw new XmlException ("Namespace URI not found for this prefix");
+
+ prefix = value;
+ }
+
+ get {
+ return prefix;
+ }
+ }
+
+ [MonoTODO("There are no code which sets 'specified = true', so this logic is without checking.")]
+ public virtual bool Specified {
+ get {
+ return !isDefault;
+ }
+ }
+
+ public override string Value {
+ get {
+ XmlNode firstChild = FirstChild;
+ if (firstChild == null)
+ return String.Empty;
+ return firstChild.Value;
+ }
+
+ set {
+ XmlNode firstChild = FirstChild;
+ if (firstChild == null)
+ AppendChild (OwnerDocument.CreateTextNode (value));
+ else
+ firstChild.Value = value;
+ }
+ }
+
+ internal override string XmlLang {
+ get { return OwnerElement.XmlLang; }
+ }
+
+ internal override XmlSpace XmlSpace {
+ get { return OwnerElement.XmlSpace; }
+ }
+
+ #endregion
+
+ #region Methods
+
+ public override XmlNode CloneNode (bool deep)
+ {
+ XmlNode node = new XmlAttribute (prefix, localName, namespaceURI,
+ OwnerDocument);
+ if (deep) {
+ while ((node != null) && (node.HasChildNodes)) {
+ AppendChild (node.NextSibling.CloneNode (true));
+ node = node.NextSibling;
+ }
+ }
+
+ return node;
+ }
+
+ // Parent of XmlAttribute must be null
+ internal void SetOwnerElement (XmlElement el) {
+ ownerElement = el;
+ }
+
+ public override void WriteContentTo (XmlWriter w)
+ {
+ w.WriteString (Value);
+ }
+
+ public override void WriteTo (XmlWriter w)
+ {
+ w.WriteAttributeString (prefix, localName, namespaceURI, Value);
+ }
+
+ #endregion
+
+ internal override XmlLinkedNode LastLinkedChild {
+ get { return lastChild; }
+
+ set { lastChild = value; }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlAttributeCollection.cs b/mcs/class/System.XML/System.Xml/XmlAttributeCollection.cs
new file mode 100644
index 00000000000..5c9694da556
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlAttributeCollection.cs
@@ -0,0 +1,207 @@
+//
+// System.Xml.XmlAttributeCollection
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+// Atsushi Enomoto (ginga@kit.hi-ho.ne.jp)
+//
+// (C) 2002 Jason Diamond http://injektilo.org/
+// (C) 2002 Atsushi Enomoto
+//
+
+using System;
+using System.Collections;
+
+namespace System.Xml
+{
+ public class XmlAttributeCollection : XmlNamedNodeMap, ICollection
+ {
+ XmlElement ownerElement;
+
+ internal XmlAttributeCollection (XmlNode parent) : base (parent)
+ {
+ ownerElement = parent as XmlElement;
+ if(ownerElement == null)
+ throw new XmlException ("invalid construction for XmlAttributeCollection.");
+ }
+
+ bool ICollection.IsSynchronized {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ bool IsReadOnly {
+ get {
+ return ownerElement.IsReadOnly;
+ }
+ }
+
+ [MonoTODO]
+ [System.Runtime.CompilerServices.IndexerName ("ItemOf")]
+ public virtual XmlAttribute this [string name] {
+ get {
+ return (XmlAttribute) GetNamedItem (name);
+ }
+ }
+
+ [MonoTODO]
+ [System.Runtime.CompilerServices.IndexerName ("ItemOf")]
+ public virtual XmlAttribute this [int i] {
+ get {
+ return (XmlAttribute) Nodes [i];
+ }
+ }
+
+ [MonoTODO]
+ [System.Runtime.CompilerServices.IndexerName ("ItemOf")]
+ public virtual XmlAttribute this [string localName, string namespaceURI] {
+ get {
+ return (XmlAttribute) GetNamedItem (localName, namespaceURI);
+ }
+ }
+
+ object ICollection.SyncRoot {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+
+ public virtual XmlAttribute Append (XmlAttribute node)
+ {
+ XmlNode xmlNode = this.SetNamedItem (node);
+ return node;
+ }
+
+ public void CopyTo (XmlAttribute[] array, int index)
+ {
+ // assuming that Nodes is a correct collection.
+ for(int i=0; i<Nodes.Count; i++)
+ array [index + i] = Nodes [i] as XmlAttribute;
+ }
+
+ [MonoTODO] // I don't know why this method is required...
+ void ICollection.CopyTo (Array array, int index)
+ {
+ // assuming that Nodes is a correct collection.
+ array.CopyTo (Nodes.ToArray (typeof(XmlAttribute)), index);
+ }
+
+ public virtual XmlAttribute InsertAfter (XmlAttribute newNode, XmlAttribute refNode)
+ {
+ if(newNode.OwnerDocument != this.ownerElement.OwnerDocument)
+ throw new ArgumentException ("different document created this newNode.");
+
+ ownerElement.OwnerDocument.onNodeInserting (newNode, null);
+
+ int pos = Nodes.Count + 1;
+ if(refNode != null)
+ {
+ for(int i=0; i<Nodes.Count; i++)
+ {
+ XmlNode n = Nodes [i] as XmlNode;
+ if(n == refNode)
+ {
+ pos = i + 1;
+ break;
+ }
+ }
+ if(pos > Nodes.Count)
+ throw new XmlException ("refNode not found in this collection.");
+ }
+ else
+ pos = 0;
+ SetNamedItem (newNode, pos);
+
+ ownerElement.OwnerDocument.onNodeInserted (newNode, null);
+
+ return newNode;
+ }
+
+ public virtual XmlAttribute InsertBefore (XmlAttribute newNode, XmlAttribute refNode)
+ {
+ if(newNode.OwnerDocument != this.ownerElement.OwnerDocument)
+ throw new ArgumentException ("different document created this newNode.");
+
+ ownerElement.OwnerDocument.onNodeInserting (newNode, null);
+
+ int pos = Nodes.Count;
+ if(refNode != null)
+ {
+ for(int i=0; i<Nodes.Count; i++)
+ {
+ XmlNode n = Nodes [i] as XmlNode;
+ if(n == refNode)
+ {
+ pos = i;
+ break;
+ }
+ }
+ if(pos == Nodes.Count)
+ throw new XmlException ("refNode not found in this collection.");
+ }
+ SetNamedItem (newNode, pos);
+
+ ownerElement.OwnerDocument.onNodeInserted (newNode, null);
+
+ return newNode;
+ }
+
+ public virtual XmlAttribute Prepend (XmlAttribute node)
+ {
+ return this.InsertAfter (node, null);
+ }
+
+ public virtual XmlAttribute Remove (XmlAttribute node)
+ {
+ if(node == null || node.OwnerDocument != this.ownerElement.OwnerDocument)
+ throw new ArgumentException ("node is null or different document created this node.");
+
+ XmlAttribute retAttr = null;
+ foreach(XmlAttribute attr in Nodes)
+ {
+ if(attr == node)
+ {
+ retAttr = attr;
+ break;
+ }
+ }
+
+ if(retAttr != null)
+ {
+ ownerElement.OwnerDocument.onNodeRemoving (node, null);
+ base.RemoveNamedItem (retAttr.LocalName, retAttr.NamespaceURI);
+ ownerElement.OwnerDocument.onNodeRemoved (node, null);
+ }
+ return retAttr;
+ }
+
+ public virtual void RemoveAll ()
+ {
+ while(Count > 0)
+ Remove ((XmlAttribute)Nodes [0]);
+ }
+
+ public virtual XmlAttribute RemoveAt (int i)
+ {
+ if(Nodes.Count <= i)
+ return null;
+ return Remove ((XmlAttribute)Nodes [i]);
+ }
+
+ public override XmlNode SetNamedItem (XmlNode node)
+ {
+ return SetNamedItem(node, -1);
+ }
+
+ [MonoTODO("event handling")]
+ internal new XmlNode SetNamedItem (XmlNode node, int pos)
+ {
+ if(IsReadOnly)
+ throw new XmlException ("this AttributeCollection is read only.");
+
+ return base.SetNamedItem (node, pos);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlCDataSection.cs b/mcs/class/System.XML/System.Xml/XmlCDataSection.cs
new file mode 100644
index 00000000000..fae85718883
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlCDataSection.cs
@@ -0,0 +1,54 @@
+//
+// System.Xml.XmlCDataSection.cs
+//
+// Author: Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+namespace System.Xml
+{
+ public class XmlCDataSection : XmlCharacterData
+ {
+ #region Constructors
+
+ protected internal XmlCDataSection (string data, XmlDocument doc)
+ : base (data, doc)
+ {
+ }
+
+ #endregion
+
+ #region Properties
+
+ public override string LocalName {
+ get { return "#cdata-section"; }
+ }
+
+ public override string Name {
+ get { return "#cdata-section"; }
+ }
+
+ public override XmlNodeType NodeType {
+ get { return XmlNodeType.CDATA; }
+ }
+
+ #endregion
+
+ #region Methods
+
+ public override XmlNode CloneNode (bool deep)
+ {
+ return new XmlCDataSection (Data, OwnerDocument); // CDATA nodes have no children.
+ }
+
+ public override void WriteContentTo (XmlWriter w) { }
+
+ public override void WriteTo (XmlWriter w)
+ {
+ w.WriteCData (Data);
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlChar.cs b/mcs/class/System.XML/System.Xml/XmlChar.cs
new file mode 100644
index 00000000000..3bdd932c82b
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlChar.cs
@@ -0,0 +1,205 @@
+// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// System.Xml.XmlChar.cs
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2001 Jason Diamond http://injektilo.org/
+//
+
+namespace System.Xml
+{
+ internal class XmlChar
+ {
+ internal static bool IsWhitespace(int ch)
+ {
+ return ch == 0x20 || ch == 0x9 || ch == 0xD || ch == 0xA;
+ }
+
+ internal static bool IsFirstNameChar(int ch)
+ {
+ bool result = false;
+
+ if (ch >= 0 && ch <= 0xFFFF)
+ {
+ result = (nameBitmap[(firstNamePages[ch >> 8] << 3) + ((ch & 0xFF) >> 5)] & (1 << (ch & 0x1F))) != 0;
+ }
+
+ return result;
+ }
+
+ internal static bool IsNameChar(int ch)
+ {
+ bool result = false;
+
+ if (ch >= 0 && ch <= 0xFFFF)
+ {
+ result = (nameBitmap[(namePages[ch >> 8] << 3) + ((ch & 0xFF) >> 5)] & (1 << (ch & 0x1F))) != 0;
+ }
+
+ return result;
+ }
+
+ internal static bool IsPubidChar(int ch)
+ {
+ return IsWhitespace(ch) | ('a' <= ch && ch <= 'z') | ('A' <= ch && ch <= 'Z') | ('0' <= ch && ch <= '9') | "-'()+,./:=?;!*#@$_%".IndexOf((char)ch) >= 0;
+ }
+
+ private static byte[] firstNamePages =
+ {
+ 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00,
+ 0x00, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+ 0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
+ 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x15, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ };
+
+ private static byte[] namePages =
+ {
+ 0x19, 0x03, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x00,
+ 0x00, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
+ 0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
+ 0x26, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x27, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ };
+
+ private static uint[] nameBitmap =
+ {
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+ 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+ 0x00000000, 0x04000000, 0x87FFFFFE, 0x07FFFFFE,
+ 0x00000000, 0x00000000, 0xFF7FFFFF, 0xFF7FFFFF,
+ 0xFFFFFFFF, 0x7FF3FFFF, 0xFFFFFDFE, 0x7FFFFFFF,
+ 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFE00F, 0xFC31FFFF,
+ 0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
+ 0xFFFFFFFF, 0xF80001FF, 0x00000003, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xFFFFD740, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
+ 0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
+ 0xFFFF0003, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
+ 0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
+ 0x0000007F, 0x00000000, 0xFFFF0000, 0x000707FF,
+ 0x00000000, 0x07FFFFFE, 0x000007FE, 0xFFFE0000,
+ 0xFFFFFFFF, 0x7CFFFFFF, 0x002F7FFF, 0x00000060,
+ 0xFFFFFFE0, 0x23FFFFFF, 0xFF000000, 0x00000003,
+ 0xFFF99FE0, 0x03C5FDFF, 0xB0000000, 0x00030003,
+ 0xFFF987E0, 0x036DFDFF, 0x5E000000, 0x001C0000,
+ 0xFFFBAFE0, 0x23EDFDFF, 0x00000000, 0x00000001,
+ 0xFFF99FE0, 0x23CDFDFF, 0xB0000000, 0x00000003,
+ 0xD63DC7E0, 0x03BFC718, 0x00000000, 0x00000000,
+ 0xFFFDDFE0, 0x03EFFDFF, 0x00000000, 0x00000003,
+ 0xFFFDDFE0, 0x03EFFDFF, 0x40000000, 0x00000003,
+ 0xFFFDDFE0, 0x03FFFDFF, 0x00000000, 0x00000003,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xFFFFFFFE, 0x000D7FFF, 0x0000003F, 0x00000000,
+ 0xFEF02596, 0x200D6CAE, 0x0000001F, 0x00000000,
+ 0x00000000, 0x00000000, 0xFFFFFEFF, 0x000003FF,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0xFFFFFFFF, 0xFFFF003F, 0x007FFFFF,
+ 0x0007DAED, 0x50000000, 0x82315001, 0x002C62AB,
+ 0x40000000, 0xF580C900, 0x00000007, 0x02010800,
+ 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+ 0x0FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x03FFFFFF,
+ 0x3F3FFFFF, 0xFFFFFFFF, 0xAAFF3F3F, 0x3FFFFFFF,
+ 0xFFFFFFFF, 0x5FDFFFFF, 0x0FCF1FDC, 0x1FDC1FFF,
+ 0x00000000, 0x00004C40, 0x00000000, 0x00000000,
+ 0x00000007, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000080, 0x000003FE, 0xFFFFFFFE, 0xFFFFFFFF,
+ 0x001FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x07FFFFFF,
+ 0xFFFFFFE0, 0x00001FFF, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+ 0xFFFFFFFF, 0x0000003F, 0x00000000, 0x00000000,
+ 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+ 0xFFFFFFFF, 0x0000000F, 0x00000000, 0x00000000,
+ 0x00000000, 0x07FF6000, 0x87FFFFFE, 0x07FFFFFE,
+ 0x00000000, 0x00800000, 0xFF7FFFFF, 0xFF7FFFFF,
+ 0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
+ 0xFFFFFFFF, 0xF80001FF, 0x00030003, 0x00000000,
+ 0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000003,
+ 0xFFFFD7C0, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
+ 0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
+ 0xFFFF007B, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
+ 0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
+ 0xFFFE007F, 0xBBFFFFFB, 0xFFFF0016, 0x000707FF,
+ 0x00000000, 0x07FFFFFE, 0x0007FFFF, 0xFFFF03FF,
+ 0xFFFFFFFF, 0x7CFFFFFF, 0xFFEF7FFF, 0x03FF3DFF,
+ 0xFFFFFFEE, 0xF3FFFFFF, 0xFF1E3FFF, 0x0000FFCF,
+ 0xFFF99FEE, 0xD3C5FDFF, 0xB080399F, 0x0003FFCF,
+ 0xFFF987E4, 0xD36DFDFF, 0x5E003987, 0x001FFFC0,
+ 0xFFFBAFEE, 0xF3EDFDFF, 0x00003BBF, 0x0000FFC1,
+ 0xFFF99FEE, 0xF3CDFDFF, 0xB0C0398F, 0x0000FFC3,
+ 0xD63DC7EC, 0xC3BFC718, 0x00803DC7, 0x0000FF80,
+ 0xFFFDDFEE, 0xC3EFFDFF, 0x00603DDF, 0x0000FFC3,
+ 0xFFFDDFEC, 0xC3EFFDFF, 0x40603DDF, 0x0000FFC3,
+ 0xFFFDDFEC, 0xC3FFFDFF, 0x00803DCF, 0x0000FFC3,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xFFFFFFFE, 0x07FF7FFF, 0x03FF7FFF, 0x00000000,
+ 0xFEF02596, 0x3BFF6CAE, 0x03FF3F5F, 0x00000000,
+ 0x03000000, 0xC2A003FF, 0xFFFFFEFF, 0xFFFE03FF,
+ 0xFEBF0FDF, 0x02FE3FFF, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x1FFF0000, 0x00000002,
+ 0x000000A0, 0x003EFFFE, 0xFFFFFFFE, 0xFFFFFFFF,
+ 0x661FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x77FFFFFF
+ };
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlCharacterData.cs b/mcs/class/System.XML/System.Xml/XmlCharacterData.cs
new file mode 100644
index 00000000000..a9fc7d267a6
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlCharacterData.cs
@@ -0,0 +1,134 @@
+//
+// System.Xml.XmlCharacterData.cs
+//
+// Authors:
+// Jason Diamond <jason@injektilo.org>
+// Kral Ferch <kral_ferch@hotmail.com>
+//
+// (C) 2002 Jason Diamond, Kral Ferch
+//
+
+using System;
+
+namespace System.Xml
+{
+ public abstract class XmlCharacterData : XmlLinkedNode
+ {
+ private string data;
+
+ #region Constructor
+
+ protected internal XmlCharacterData (string data, XmlDocument doc)
+ : base (doc)
+ {
+ if (data == null)
+ data = String.Empty;
+
+ this.data = data;
+ }
+
+ #endregion
+
+ #region Properties
+
+ public virtual string Data {
+ get { return data; }
+
+ set {
+ OwnerDocument.onNodeChanging (this, this.ParentNode);
+
+ if (IsReadOnly)
+ throw new ArgumentException ("Node is read-only.");
+
+ data = value;
+
+ OwnerDocument.onNodeChanged (this, this.ParentNode);
+ }
+ }
+
+ public override string InnerText {
+ get { return data; }
+
+ set { Data = value; } // invokes events
+ }
+
+ public virtual int Length {
+ get { return data != null ? data.Length : 0; }
+ }
+
+ public override string Value {
+ get { return data; }
+
+ set {
+ Data = value;
+ }
+ }
+
+ #endregion
+
+ #region Methods
+
+ public virtual void AppendData (string strData)
+ {
+ OwnerDocument.onNodeChanging (this, this.ParentNode);
+ data += strData;
+ OwnerDocument.onNodeChanged (this, this.ParentNode);
+ }
+
+ public virtual void DeleteData (int offset, int count)
+ {
+ OwnerDocument.onNodeChanging (this, this.ParentNode);
+
+ if (offset < 0)
+ throw new ArgumentOutOfRangeException ("offset", "Must be non-negative and must not be greater than the length of this instance.");
+
+ int newCount = data.Length - offset;
+
+ if ((offset + count) < data.Length)
+ newCount = count;
+
+ data = data.Remove (offset, newCount);
+
+ OwnerDocument.onNodeChanged (this, this.ParentNode);
+ }
+
+ public virtual void InsertData (int offset, string strData)
+ {
+ OwnerDocument.onNodeChanging (this, this.ParentNode);
+
+ if ((offset < 0) || (offset > data.Length))
+ throw new ArgumentOutOfRangeException ("offset", "Must be non-negative and must not be greater than the length of this instance.");
+
+ data = data.Insert(offset, strData);
+
+ OwnerDocument.onNodeChanged (this, this.ParentNode);
+ }
+
+ public virtual void ReplaceData (int offset, int count, string strData)
+ {
+ OwnerDocument.onNodeChanging (this, this.ParentNode);
+
+ if ((offset < 0) || (offset > data.Length))
+ throw new ArgumentOutOfRangeException ("offset", "Must be non-negative and must not be greater than the length of this instance.");
+
+ if (strData == null)
+ throw new ArgumentNullException ("strData", "Must be non-null.");
+
+ string newData = data.Substring (0, offset) + strData;
+
+ if ((offset + count) < data.Length)
+ newData += data.Substring (offset + count);
+
+ data = newData;
+
+ OwnerDocument.onNodeChanged (this, this.ParentNode);
+ }
+
+ public virtual string Substring (int offset, int count)
+ {
+ return data.Substring (offset, count);
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlComment.cs b/mcs/class/System.XML/System.Xml/XmlComment.cs
new file mode 100644
index 00000000000..a515a1a95f9
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlComment.cs
@@ -0,0 +1,65 @@
+//
+// System.Xml.XmlComment
+//
+// Author:
+// Kral Ferch <kral_ferch@hotmail.com>
+//
+// (C) 2002 Kral Ferch
+//
+
+using System;
+using System.Xml.XPath;
+
+namespace System.Xml
+{
+ public class XmlComment : XmlCharacterData
+ {
+ #region Constructors
+
+ protected internal XmlComment (string comment, XmlDocument doc)
+ : base (comment, doc)
+ {
+ }
+
+ #endregion
+
+ #region Properties
+
+ public override string LocalName {
+ get { return "#comment"; }
+ }
+
+ public override string Name {
+ get { return "#comment"; }
+ }
+
+ public override XmlNodeType NodeType {
+ get { return XmlNodeType.Comment; }
+ }
+
+ internal override XPathNodeType XPathNodeType {
+ get {
+ return XPathNodeType.Comment;
+ }
+ }
+
+ #endregion
+
+ #region Methods
+
+ public override XmlNode CloneNode (bool deep)
+ {
+ // discard deep because Comments have no children.
+ return new XmlComment(Value, OwnerDocument);
+ }
+
+ public override void WriteContentTo (XmlWriter w) { }
+
+ public override void WriteTo (XmlWriter w)
+ {
+ w.WriteComment (Data);
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlConstructs.cs b/mcs/class/System.XML/System.Xml/XmlConstructs.cs
new file mode 100755
index 00000000000..7f23eba5e44
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlConstructs.cs
@@ -0,0 +1,545 @@
+using System;
+
+namespace System.Xml
+{
+ /// <summary>
+ /// http://www.w3.org/TR/REC-xml
+ /// </summary>
+ /// <remarks>
+ /// Includes code and Ideas from org.apache.xerces.util.XMLChar class of Xerces 2.0.1
+ /// However, No surrogate support is included in this class.
+ /// This class is currently public. Make it internal after testing completes
+ /// </remarks>
+ public class XmlConstructs
+ {
+ /** Character flags. */
+ internal static byte[] CHARS = new byte[1 << 16];
+
+ /** Valid character mask. */
+ internal static int VALID = 0x01;
+
+ /** Space character mask. */
+ internal static int SPACE = 0x02;
+
+ /** Name start character mask. */
+ internal static int NAME_START = 0x04;
+
+ /** Name character mask. */
+ internal static int NAME = 0x08;
+
+ /** Pubid character mask. */
+ internal static int PUBID = 0x10;
+ /**
+ * Content character mask. Special characters are those that can
+ * be considered the start of markup, such as '&lt;' and '&amp;'.
+ * The various newline characters are considered special as well.
+ * All other valid XML characters can be considered content.
+ * <p>
+ * This is an optimization for the inner loop of character scanning.
+ */
+ internal static int CONTENT = 0x20;
+
+ /** NCName start character mask. */
+ internal static int NCNAME_START = 0x40;
+
+ /** NCName character mask. */
+ internal static int NCNAME = 0x80;
+
+ static XmlConstructs()
+ {
+ //
+ // [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] |
+ // [#xE000-#xFFFD] | [#x10000-#x10FFFF]
+ //
+ int[] charRange = {
+ 0x0009, 0x000A, 0x000D, 0x000D, 0x0020, 0xD7FF, 0xE000, 0xFFFD,
+ };
+
+ //
+ // [3] S ::= (#x20 | #x9 | #xD | #xA)+
+ //
+ int[] spaceChar = {
+ 0x0020, 0x0009, 0x000D, 0x000A,
+ };
+
+ //
+ // [4] NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' |
+ // CombiningChar | Extender
+ //
+ int[] nameChar = {
+ 0x002D, 0x002E, // '-' and '.'
+ };
+
+ //
+ // [5] Name ::= (Letter | '_' | ':') (NameChar)*
+ //
+
+ int[] nameStartChar = {
+ 0x003A, 0x005F, // ':' and '_'
+ };
+
+ //
+ // [13] PubidChar ::= #x20 | 0xD | 0xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]
+ //
+
+ int[] pubidChar = {
+ 0x000A, 0x000D, 0x0020, 0x0021, 0x0023, 0x0024, 0x0025, 0x003D,
+ 0x005F
+ };
+
+ int[] pubidRange = {
+ 0x0027, 0x003B, 0x003F, 0x005A, 0x0061, 0x007A
+ };
+
+ //
+ // [84] Letter ::= BaseChar | Ideographic
+ //
+
+ int[] letterRange = {
+ // BaseChar
+ 0x0041, 0x005A, 0x0061, 0x007A, 0x00C0, 0x00D6, 0x00D8, 0x00F6,
+ 0x00F8, 0x0131, 0x0134, 0x013E, 0x0141, 0x0148, 0x014A, 0x017E,
+ 0x0180, 0x01C3, 0x01CD, 0x01F0, 0x01F4, 0x01F5, 0x01FA, 0x0217,
+ 0x0250, 0x02A8, 0x02BB, 0x02C1, 0x0388, 0x038A, 0x038E, 0x03A1,
+ 0x03A3, 0x03CE, 0x03D0, 0x03D6, 0x03E2, 0x03F3, 0x0401, 0x040C,
+ 0x040E, 0x044F, 0x0451, 0x045C, 0x045E, 0x0481, 0x0490, 0x04C4,
+ 0x04C7, 0x04C8, 0x04CB, 0x04CC, 0x04D0, 0x04EB, 0x04EE, 0x04F5,
+ 0x04F8, 0x04F9, 0x0531, 0x0556, 0x0561, 0x0586, 0x05D0, 0x05EA,
+ 0x05F0, 0x05F2, 0x0621, 0x063A, 0x0641, 0x064A, 0x0671, 0x06B7,
+ 0x06BA, 0x06BE, 0x06C0, 0x06CE, 0x06D0, 0x06D3, 0x06E5, 0x06E6,
+ 0x0905, 0x0939, 0x0958, 0x0961, 0x0985, 0x098C, 0x098F, 0x0990,
+ 0x0993, 0x09A8, 0x09AA, 0x09B0, 0x09B6, 0x09B9, 0x09DC, 0x09DD,
+ 0x09DF, 0x09E1, 0x09F0, 0x09F1, 0x0A05, 0x0A0A, 0x0A0F, 0x0A10,
+ 0x0A13, 0x0A28, 0x0A2A, 0x0A30, 0x0A32, 0x0A33, 0x0A35, 0x0A36,
+ 0x0A38, 0x0A39, 0x0A59, 0x0A5C, 0x0A72, 0x0A74, 0x0A85, 0x0A8B,
+ 0x0A8F, 0x0A91, 0x0A93, 0x0AA8, 0x0AAA, 0x0AB0, 0x0AB2, 0x0AB3,
+ 0x0AB5, 0x0AB9, 0x0B05, 0x0B0C, 0x0B0F, 0x0B10, 0x0B13, 0x0B28,
+ 0x0B2A, 0x0B30, 0x0B32, 0x0B33, 0x0B36, 0x0B39, 0x0B5C, 0x0B5D,
+ 0x0B5F, 0x0B61, 0x0B85, 0x0B8A, 0x0B8E, 0x0B90, 0x0B92, 0x0B95,
+ 0x0B99, 0x0B9A, 0x0B9E, 0x0B9F, 0x0BA3, 0x0BA4, 0x0BA8, 0x0BAA,
+ 0x0BAE, 0x0BB5, 0x0BB7, 0x0BB9, 0x0C05, 0x0C0C, 0x0C0E, 0x0C10,
+ 0x0C12, 0x0C28, 0x0C2A, 0x0C33, 0x0C35, 0x0C39, 0x0C60, 0x0C61,
+ 0x0C85, 0x0C8C, 0x0C8E, 0x0C90, 0x0C92, 0x0CA8, 0x0CAA, 0x0CB3,
+ 0x0CB5, 0x0CB9, 0x0CE0, 0x0CE1, 0x0D05, 0x0D0C, 0x0D0E, 0x0D10,
+ 0x0D12, 0x0D28, 0x0D2A, 0x0D39, 0x0D60, 0x0D61, 0x0E01, 0x0E2E,
+ 0x0E32, 0x0E33, 0x0E40, 0x0E45, 0x0E81, 0x0E82, 0x0E87, 0x0E88,
+ 0x0E94, 0x0E97, 0x0E99, 0x0E9F, 0x0EA1, 0x0EA3, 0x0EAA, 0x0EAB,
+ 0x0EAD, 0x0EAE, 0x0EB2, 0x0EB3, 0x0EC0, 0x0EC4, 0x0F40, 0x0F47,
+ 0x0F49, 0x0F69, 0x10A0, 0x10C5, 0x10D0, 0x10F6, 0x1102, 0x1103,
+ 0x1105, 0x1107, 0x110B, 0x110C, 0x110E, 0x1112, 0x1154, 0x1155,
+ 0x115F, 0x1161, 0x116D, 0x116E, 0x1172, 0x1173, 0x11AE, 0x11AF,
+ 0x11B7, 0x11B8, 0x11BC, 0x11C2, 0x1E00, 0x1E9B, 0x1EA0, 0x1EF9,
+ 0x1F00, 0x1F15, 0x1F18, 0x1F1D, 0x1F20, 0x1F45, 0x1F48, 0x1F4D,
+ 0x1F50, 0x1F57, 0x1F5F, 0x1F7D, 0x1F80, 0x1FB4, 0x1FB6, 0x1FBC,
+ 0x1FC2, 0x1FC4, 0x1FC6, 0x1FCC, 0x1FD0, 0x1FD3, 0x1FD6, 0x1FDB,
+ 0x1FE0, 0x1FEC, 0x1FF2, 0x1FF4, 0x1FF6, 0x1FFC, 0x212A, 0x212B,
+ 0x2180, 0x2182, 0x3041, 0x3094, 0x30A1, 0x30FA, 0x3105, 0x312C,
+ 0xAC00, 0xD7A3,
+ // Ideographic
+ 0x3021, 0x3029, 0x4E00, 0x9FA5,
+ };
+ int[] letterChar = {
+ // BaseChar
+ 0x0386, 0x038C, 0x03DA, 0x03DC, 0x03DE, 0x03E0, 0x0559, 0x06D5,
+ 0x093D, 0x09B2, 0x0A5E, 0x0A8D, 0x0ABD, 0x0AE0, 0x0B3D, 0x0B9C,
+ 0x0CDE, 0x0E30, 0x0E84, 0x0E8A, 0x0E8D, 0x0EA5, 0x0EA7, 0x0EB0,
+ 0x0EBD, 0x1100, 0x1109, 0x113C, 0x113E, 0x1140, 0x114C, 0x114E,
+ 0x1150, 0x1159, 0x1163, 0x1165, 0x1167, 0x1169, 0x1175, 0x119E,
+ 0x11A8, 0x11AB, 0x11BA, 0x11EB, 0x11F0, 0x11F9, 0x1F59, 0x1F5B,
+ 0x1F5D, 0x1FBE, 0x2126, 0x212E,
+ // Ideographic
+ 0x3007,
+ };
+
+ //
+ // [87] CombiningChar ::= ...
+ //
+
+ int[] combiningCharRange = {
+ 0x0300, 0x0345, 0x0360, 0x0361, 0x0483, 0x0486, 0x0591, 0x05A1,
+ 0x05A3, 0x05B9, 0x05BB, 0x05BD, 0x05C1, 0x05C2, 0x064B, 0x0652,
+ 0x06D6, 0x06DC, 0x06DD, 0x06DF, 0x06E0, 0x06E4, 0x06E7, 0x06E8,
+ 0x06EA, 0x06ED, 0x0901, 0x0903, 0x093E, 0x094C, 0x0951, 0x0954,
+ 0x0962, 0x0963, 0x0981, 0x0983, 0x09C0, 0x09C4, 0x09C7, 0x09C8,
+ 0x09CB, 0x09CD, 0x09E2, 0x09E3, 0x0A40, 0x0A42, 0x0A47, 0x0A48,
+ 0x0A4B, 0x0A4D, 0x0A70, 0x0A71, 0x0A81, 0x0A83, 0x0ABE, 0x0AC5,
+ 0x0AC7, 0x0AC9, 0x0ACB, 0x0ACD, 0x0B01, 0x0B03, 0x0B3E, 0x0B43,
+ 0x0B47, 0x0B48, 0x0B4B, 0x0B4D, 0x0B56, 0x0B57, 0x0B82, 0x0B83,
+ 0x0BBE, 0x0BC2, 0x0BC6, 0x0BC8, 0x0BCA, 0x0BCD, 0x0C01, 0x0C03,
+ 0x0C3E, 0x0C44, 0x0C46, 0x0C48, 0x0C4A, 0x0C4D, 0x0C55, 0x0C56,
+ 0x0C82, 0x0C83, 0x0CBE, 0x0CC4, 0x0CC6, 0x0CC8, 0x0CCA, 0x0CCD,
+ 0x0CD5, 0x0CD6, 0x0D02, 0x0D03, 0x0D3E, 0x0D43, 0x0D46, 0x0D48,
+ 0x0D4A, 0x0D4D, 0x0E34, 0x0E3A, 0x0E47, 0x0E4E, 0x0EB4, 0x0EB9,
+ 0x0EBB, 0x0EBC, 0x0EC8, 0x0ECD, 0x0F18, 0x0F19, 0x0F71, 0x0F84,
+ 0x0F86, 0x0F8B, 0x0F90, 0x0F95, 0x0F99, 0x0FAD, 0x0FB1, 0x0FB7,
+ 0x20D0, 0x20DC, 0x302A, 0x302F,
+ };
+
+ int[] combiningCharChar = {
+ 0x05BF, 0x05C4, 0x0670, 0x093C, 0x094D, 0x09BC, 0x09BE, 0x09BF,
+ 0x09D7, 0x0A02, 0x0A3C, 0x0A3E, 0x0A3F, 0x0ABC, 0x0B3C, 0x0BD7,
+ 0x0D57, 0x0E31, 0x0EB1, 0x0F35, 0x0F37, 0x0F39, 0x0F3E, 0x0F3F,
+ 0x0F97, 0x0FB9, 0x20E1, 0x3099, 0x309A,
+ };
+
+ //
+ // [88] Digit ::= ...
+ //
+
+ int[] digitRange = {
+ 0x0030, 0x0039, 0x0660, 0x0669, 0x06F0, 0x06F9, 0x0966, 0x096F,
+ 0x09E6, 0x09EF, 0x0A66, 0x0A6F, 0x0AE6, 0x0AEF, 0x0B66, 0x0B6F,
+ 0x0BE7, 0x0BEF, 0x0C66, 0x0C6F, 0x0CE6, 0x0CEF, 0x0D66, 0x0D6F,
+ 0x0E50, 0x0E59, 0x0ED0, 0x0ED9, 0x0F20, 0x0F29,
+ };
+
+ //
+ // [89] Extender ::= ...
+ //
+
+ int[] extenderRange = {
+ 0x3031, 0x3035, 0x309D, 0x309E, 0x30FC, 0x30FE,
+ };
+
+ int[] extenderChar = {
+ 0x00B7, 0x02D0, 0x02D1, 0x0387, 0x0640, 0x0E46, 0x0EC6, 0x3005,
+ };
+
+ //
+ // SpecialChar ::= '<', '&', '\n', '\r', ']'
+ //
+
+ int[] specialChar = {
+ '<', '&', '\n', '\r', ']',
+ };
+
+ //
+ // Initialize
+ //
+
+ // set valid characters
+ for (int i = 0; i < charRange.Length; i += 2)
+ {
+ for (int j = charRange[i]; j <= charRange[i + 1]; j++)
+ {
+ CHARS[j] = (byte)(CHARS[j] | VALID | CONTENT);
+ }
+ }
+
+ // remove special characters
+ for (int i = 0; i < specialChar.Length; i++)
+ {
+ CHARS[specialChar[i]] = (byte)(CHARS[specialChar[i]] & ~CONTENT);
+ }
+
+ // set space characters
+ for (int i = 0; i < spaceChar.Length; i++)
+ {
+ CHARS[spaceChar[i]] = (byte)(CHARS[spaceChar[i]] | SPACE);
+ }
+
+ // set name start characters
+ for (int i = 0; i < nameStartChar.Length; i++)
+ {
+ CHARS[nameStartChar[i]] = (byte)(CHARS[nameStartChar[i]] | NAME_START | NAME |
+ NCNAME_START | NCNAME);
+ }
+ for (int i = 0; i < letterRange.Length; i += 2)
+ {
+ for (int j = letterRange[i]; j <= letterRange[i + 1]; j++)
+ {
+ CHARS[j] = (byte)(CHARS[j] | NAME_START | NAME | NCNAME_START | NCNAME);
+ }
+ }
+ for (int i = 0; i < letterChar.Length; i++)
+ {
+ CHARS[letterChar[i]] = (byte)(CHARS[letterChar[i]] | NAME_START | NAME |
+ NCNAME_START | NCNAME);
+ }
+
+ // set name characters
+ for (int i = 0; i < nameChar.Length; i++)
+ {
+ CHARS[nameChar[i]] = (byte)(CHARS[nameChar[i]] | NAME | NCNAME);
+ }
+ for (int i = 0; i < digitRange.Length; i += 2)
+ {
+ for (int j = digitRange[i]; j <= digitRange[i + 1]; j++)
+ {
+ CHARS[j] = (byte)(CHARS[j] | NAME | NCNAME);
+ }
+ }
+ for (int i = 0; i < combiningCharRange.Length; i += 2)
+ {
+ for (int j = combiningCharRange[i]; j <= combiningCharRange[i + 1]; j++)
+ {
+ CHARS[j] = (byte)(CHARS[j] | NAME | NCNAME);
+ }
+ }
+ for (int i = 0; i < combiningCharChar.Length; i++)
+ {
+ CHARS[combiningCharChar[i]] = (byte)(CHARS[combiningCharChar[i]] | NAME | NCNAME);
+ }
+ for (int i = 0; i < extenderRange.Length; i += 2)
+ {
+ for (int j = extenderRange[i]; j <= extenderRange[i + 1]; j++)
+ {
+ CHARS[j] = (byte)(CHARS[j] | NAME | NCNAME);
+ }
+ }
+ for (int i = 0; i < extenderChar.Length; i++)
+ {
+ CHARS[extenderChar[i]] = (byte)(CHARS[extenderChar[i]] | NAME | NCNAME);
+ }
+
+ // remove ':' from allowable NCNAME_START and NCNAME chars
+ CHARS[':'] = (byte)(CHARS[':'] & ~(NCNAME_START | NCNAME));
+
+ // set Pubid characters
+ for (int i = 0; i < pubidChar.Length; i++)
+ {
+ CHARS[pubidChar[i]] = (byte)(CHARS[pubidChar[i]] | PUBID);
+ }
+ for (int i = 0; i < pubidRange.Length; i += 2)
+ {
+ for (int j = pubidRange[i]; j <= pubidRange[i + 1]; j++)
+ {
+ CHARS[j] = (byte)(CHARS[j] | PUBID);
+ }
+ }
+ }
+
+ private XmlConstructs()
+ {
+ }
+
+
+ //Static Methods
+
+ /// <summary>
+ /// Returns true if the specified character is valid.
+ /// </summary>
+ /// <param name="c">The character to check.</param>
+ public static bool IsValid(char c)
+ {
+ return (CHARS[c] & VALID) != 0;
+ }
+
+ /// <summary>
+ /// Returns true if the specified character is invalid.
+ /// </summary>
+ /// <param name="c">The character to check.</param>
+ public static bool IsInvalid(char c)
+ {
+ return !IsValid(c);
+ }
+
+ /// <summary>
+ /// Returns true if the specified character can be considered content.
+ /// </summary>
+ /// <param name="c">The character to check.</param>
+ public static bool IsContent(char c)
+ {
+ return (CHARS[c] & CONTENT) != 0;
+ }
+
+ /// <summary>
+ /// Returns true if the specified character can be considered markup.
+ /// Markup characters include '&lt;', '&amp;', and '%'.
+ /// </summary>
+ /// <param name="c">The character to check.</param>
+ public static bool IsMarkup(char c)
+ {
+ return c == '<' || c == '&' || c == '%';
+ }
+
+ /// <summary>
+ /// Returns true if the specified character is a space character
+ /// as defined by production [3] in the XML 1.0 specification.
+ /// </summary>
+ /// <param name="c">The character to check.</param>
+ /// <returns></returns>
+ public static bool IsSpace(char c)
+ {
+ return (CHARS[c] & SPACE) != 0;
+ }
+
+ /// <summary>
+ /// Returns true if the specified character is a valid name start
+ /// character as defined by production [5] in the XML 1.0 specification.
+ /// </summary>
+ /// <param name="c">The character to check.</param>
+ public static bool IsNameStart(char c)
+ {
+ return (CHARS[c] & NAME_START) != 0;
+ }
+
+ /// <summary>
+ /// Returns true if the specified character is a valid name
+ /// character as defined by production [4] in the XML 1.0 specification.
+ /// </summary>
+ /// <param name="c">The character to check.</param>
+ public static bool IsName(char c)
+ {
+ return (CHARS[c] & NAME) != 0;
+ }
+
+ /// <summary>
+ /// Returns true if the specified character is a valid NCName start
+ /// character as defined by production [4] in Namespaces in XML
+ /// recommendation.
+ /// </summary>
+ /// <param name="c">The character to check.</param>
+ /// <returns></returns>
+ public static bool IsNCNameStart(char c)
+ {
+ return (CHARS[c] & NCNAME_START) != 0;
+ }
+
+ /// <summary>
+ /// Returns true if the specified character is a valid NCName
+ /// character as defined by production [5] in Namespaces in XML
+ /// recommendation.
+ /// </summary>
+ /// <param name="c"></param>
+ /// <returns></returns>
+ public static bool IsNCName(char c)
+ {
+ return (CHARS[c] & NCNAME) != 0;
+ }
+
+ /// <summary>
+ /// Returns true if the specified character is a valid Pubid
+ /// character as defined by production [13] in the XML 1.0 specification.
+ /// </summary>
+ /// <param name="c">The character to check</param>
+ public static bool IsPubid(char c)
+ {
+ return (CHARS[c] & PUBID) != 0;
+ }
+
+ /// <summary>
+ /// Check to see if a string is a valid Name according to [5]
+ /// in the XML 1.0 Recommendation
+ /// </summary>
+ /// <param name="name">The string to check</param>
+ public static bool IsValidName(String name, out Exception err)
+ {
+ err = null;
+ if (name.Length == 0)
+ {
+ err = new XmlException("Name can not be an empty string",null);
+ return false;
+ }
+ char ch = name[0];
+ if( IsNameStart(ch) == false)
+ {
+ err = new XmlException("The character '"+ch+"' cannot start a Name",null);
+ return false;
+ }
+ for (int i = 1; i < name.Length; i++ )
+ {
+ ch = name[i];
+ if( IsName( ch ) == false )
+ {
+ err = new XmlException("The character '"+ch+"' is not allowed in a Name",null);
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /// <summary>
+ /// Check to see if a string is a valid NCName according to [4]
+ /// from the XML Namespaces 1.0 Recommendation
+ /// </summary>
+ /// <param name="ncName">The string to check</param>
+ public static bool IsValidNCName(String ncName, out Exception err)
+ {
+ err = null;
+ if (ncName.Length == 0)
+ {
+ err = new XmlException("NCName can not be an empty string",null);
+ return false;
+ }
+ char ch = ncName[0];
+ if( IsNCNameStart(ch) == false)
+ {
+ err = new XmlException("The character '"+ch+"' cannot start a NCName",null);
+ return false;
+ }
+ for (int i = 1; i < ncName.Length; i++ )
+ {
+ ch = ncName[i];
+ if( IsNCName( ch ) == false )
+ {
+ err = new XmlException("The character '"+ch+"' is not allowed in a NCName",null);
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /// <summary>
+ /// Check to see if a string is a valid Nmtoken according to [7]
+ /// in the XML 1.0 Recommendation
+ /// </summary>
+ /// <param name="nmtoken">The string to check.</param>
+ public static bool IsValidNmtoken(String nmtoken, out Exception err)
+ {
+ err = null;
+ if (nmtoken.Length == 0)
+ {
+ err = new XmlException("NMTOKEN can not be an empty string", null);
+ return false;
+ }
+ for (int i = 0; i < nmtoken.Length; i++ )
+ {
+ char ch = nmtoken[i];
+ if( ! IsName( ch ) )
+ {
+ err = new XmlException("The character '"+ch+"' is not allowed in a NMTOKEN",null);
+ return false;
+ }
+ }
+ return true;
+ }
+
+ // encodings
+
+ /// <summary>
+ /// Returns true if the encoding name is a valid IANA encoding.
+ /// This method does not verify that there is a decoder available
+ /// for this encoding, only that the characters are valid for an
+ /// IANA encoding name.
+ /// </summary>
+ /// <param name="ianaEncoding">The encoding to check.</param>
+ /// <returns></returns>
+ public static bool IsValidIANAEncoding(String ianaEncoding)
+ {
+ if (ianaEncoding != null)
+ {
+ int length = ianaEncoding.Length;
+ if (length > 0)
+ {
+ char c = ianaEncoding[0];
+ if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
+ {
+ for (int i = 1; i < length; i++)
+ {
+ c = ianaEncoding[i];
+ if ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') &&
+ (c < '0' || c > '9') && c != '.' && c != '_' &&
+ c != '-')
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlConvert.cs b/mcs/class/System.XML/System.Xml/XmlConvert.cs
new file mode 100755
index 00000000000..fa35d16acab
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlConvert.cs
@@ -0,0 +1,329 @@
+//
+// System.Xml.XmlConvert
+//
+// Authors:
+// Dwivedi, Ajay kumar (Adwiv@Yahoo.com)
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+using System;
+using System.Text;
+using System.Globalization;
+
+namespace System.Xml {
+
+ public class XmlConvert {
+
+ static string encodedColon = "_x003A_";
+
+ public XmlConvert()
+ {}
+
+ private static string TryDecoding (string s)
+ {
+ if (s == null || s.Length < 6)
+ return s;
+
+ char c = '\uFFFF';
+ try {
+ c = (char) Int32.Parse (s.Substring (1, 4), NumberStyles.HexNumber);
+ } catch {
+ return s [0] + DecodeName (s.Substring (1));
+ }
+
+ if (s.Length == 6)
+ return c.ToString ();
+ return c + DecodeName (s.Substring (6));
+ }
+
+ public static string DecodeName (string name)
+ {
+ if (name == null || name.Length == 0)
+ return name;
+
+ int pos = name.IndexOf ('_');
+ if (pos == -1 || pos + 6 >= name.Length)
+ return name;
+
+ if (Char.ToUpper (name [pos + 1]) != 'X' || name [pos + 6] != '_')
+ return name [0] + DecodeName (name.Substring (1));
+
+ return name.Substring (0, pos) + TryDecoding (name.Substring (pos + 1));
+ }
+
+ public static string EncodeLocalName (string name)
+ {
+ string encoded = EncodeName (name);
+ int pos = encoded.IndexOf (':');
+ if (pos == -1)
+ return encoded;
+ return encoded.Replace (":", encodedColon);
+ }
+
+ internal static bool IsInvalid (char c, bool firstOnlyLetter)
+ {
+ if (c == ':') // Special case. allowed in EncodeName, but encoded in EncodeLocalName
+ return false;
+
+ if (firstOnlyLetter && !Char.IsLetter (c) && c != '_')
+ return false;
+
+ return !Char.IsLetterOrDigit (c);
+ }
+
+ private static string EncodeName (string name, bool nmtoken)
+ {
+ StringBuilder sb = new StringBuilder ();
+ int length = name.Length;
+ for (int i = 0; i < length; i++) {
+ char c = name [i];
+ if (c != '_' || i + 6 >= length) {
+ bool firstOnlyLetter = (i == 0 && !nmtoken);
+ if (IsInvalid (c, firstOnlyLetter)) {
+ sb.AppendFormat ("_x{0:X4}_", (int) c);
+ continue;
+ }
+ } else {
+ if (Char.ToUpper (name [i + 1]) == 'X' && name [i + 6] == '_') {
+ string decoded = TryDecoding (name.Substring (i + 1, 6));
+ if (decoded.Length == 1) {
+ sb.AppendFormat ("_x{0:X4}_", (int) c);
+ continue;
+ }
+ }
+ }
+ sb.Append (c);
+ }
+ return sb.ToString ();
+ }
+
+ public static string EncodeName (string name)
+ {
+ return EncodeName (name, false);
+ }
+
+ public static string EncodeNmToken(string name)
+ {
+ return EncodeName (name, true);
+ }
+
+ // {true, false, 1, 0}
+ public static bool ToBoolean(string s)
+ {
+ s = s.Trim();
+ switch(s)
+ {
+ case "1":
+ return true;
+ case "true":
+ return true;
+ case "0":
+ return false;
+ case "false":
+ return false;
+ default:
+ throw new FormatException(s + " is not a valid boolean value");
+ }
+ }
+
+ public static byte ToByte(string s)
+ {
+ return Byte.Parse(s, CultureInfo.InvariantCulture);
+ }
+
+ public static char ToChar(string s)
+ {
+ return Char.Parse(s);
+ }
+
+ public static DateTime ToDateTime(string s)
+ {
+ return DateTime.Parse(s);
+ }
+
+ public static DateTime ToDateTime(string s, string format)
+ {
+ DateTimeFormatInfo d = new DateTimeFormatInfo();
+ d.FullDateTimePattern = format;
+ return DateTime.Parse(s, d);
+ }
+
+ public static DateTime ToDateTime(string s, string[] formats)
+ {
+ DateTimeStyles style = DateTimeStyles.AllowLeadingWhite |
+ DateTimeStyles.AllowTrailingWhite;
+ return DateTime.ParseExact (s, formats, DateTimeFormatInfo.InvariantInfo, style);
+ }
+
+ public static Decimal ToDecimal(string s)
+ {
+ return Decimal.Parse(s, CultureInfo.InvariantCulture);
+ }
+
+ public static double ToDouble(string s)
+ {
+ return Double.Parse(s, CultureInfo.InvariantCulture);
+ }
+
+ public static Guid ToGuid(string s)
+ {
+ return new Guid(s);
+ }
+
+ public static short ToInt16(string s)
+ {
+ return Int16.Parse(s, CultureInfo.InvariantCulture);
+ }
+
+ public static int ToInt32(string s)
+ {
+ return Int32.Parse(s, CultureInfo.InvariantCulture);
+ }
+
+ public static long ToInt64(string s)
+ {
+ return Int64.Parse(s, CultureInfo.InvariantCulture);
+ }
+
+ [CLSCompliant (false)]
+ public static SByte ToSByte(string s)
+ {
+ return SByte.Parse(s, CultureInfo.InvariantCulture);
+ }
+
+ public static float ToSingle(string s)
+ {
+ return Single.Parse(s, CultureInfo.InvariantCulture);
+ }
+
+ public static string ToString(Guid value)
+ {
+ return value.ToString("D",CultureInfo.InvariantCulture);
+ }
+
+ public static string ToString(int value)
+ {
+ return value.ToString(CultureInfo.InvariantCulture);
+ }
+
+ public static string ToString(short value)
+ {
+ return value.ToString(CultureInfo.InvariantCulture);
+ }
+
+ public static string ToString(byte value)
+ {
+ return value.ToString(CultureInfo.InvariantCulture);
+ }
+
+ public static string ToString(long value)
+ {
+ return value.ToString(CultureInfo.InvariantCulture);
+ }
+
+ public static string ToString(char value)
+ {
+ return value.ToString(CultureInfo.InvariantCulture);
+ }
+
+ public static string ToString(bool value)
+ {
+ return value.ToString(CultureInfo.InvariantCulture);
+ }
+
+ [CLSCompliant (false)]
+ public static string ToString(SByte value)
+ {
+ return value.ToString(CultureInfo.InvariantCulture);
+ }
+ public static string ToString(Decimal value)
+ {
+ return value.ToString(CultureInfo.InvariantCulture);
+ }
+
+ [CLSCompliant (false)]
+ public static string ToString(UInt64 value)
+ {
+ return value.ToString(CultureInfo.InvariantCulture);
+ }
+ public static string ToString(TimeSpan value)
+ {
+ return value.ToString();
+ }
+ public static string ToString(double value)
+ {
+ return value.ToString(CultureInfo.InvariantCulture);
+ }
+ public static string ToString(float value)
+ {
+ return value.ToString(CultureInfo.InvariantCulture);
+ }
+
+ [CLSCompliant (false)]
+ public static string ToString(UInt32 value)
+ {
+ return value.ToString(CultureInfo.InvariantCulture);
+ }
+
+ [CLSCompliant (false)]
+ public static string ToString(UInt16 value)
+ {
+ return value.ToString(CultureInfo.InvariantCulture);
+ }
+ public static string ToString(DateTime value)
+ {
+ return value.ToString(CultureInfo.InvariantCulture);
+ }
+ public static string ToString(DateTime value, string format)
+ {
+ return value.ToString(format, CultureInfo.InvariantCulture);
+ }
+ public static TimeSpan ToTimeSpan(string s)
+ {
+ return TimeSpan.Parse(s);
+ }
+
+ [CLSCompliant (false)]
+ public static UInt16 ToUInt16(string s)
+ {
+ return UInt16.Parse(s, CultureInfo.InvariantCulture);
+ }
+
+ [CLSCompliant (false)]
+ public static UInt32 ToUInt32(string s)
+ {
+ return UInt32.Parse(s, CultureInfo.InvariantCulture);
+ }
+
+ [CLSCompliant (false)]
+ public static UInt64 ToUInt64(string s)
+ {
+ return UInt64.Parse(s, CultureInfo.InvariantCulture);
+ }
+
+ public static string VerifyName(string name)
+ {
+ Exception innerEx;
+ if(name == null)
+ throw new ArgumentNullException("name");
+
+ if(XmlConstructs.IsValidName(name, out innerEx))
+ return name;
+
+ throw new XmlException("'"+name+"' is not a valid XML Name",null);
+ }
+
+ public static string VerifyNCName(string ncname)
+ {
+ Exception innerEx;
+ if(ncname == null)
+ throw new ArgumentNullException("ncname");
+
+ if(XmlConstructs.IsValidName(ncname, out innerEx))
+ return ncname;
+
+ throw new XmlException("'"+ncname+"' is not a valid XML NCName",innerEx);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlDeclaration.cs b/mcs/class/System.XML/System.Xml/XmlDeclaration.cs
new file mode 100644
index 00000000000..c34df121227
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlDeclaration.cs
@@ -0,0 +1,136 @@
+//
+// System.Xml.XmlDeclaration
+//
+// Author:
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+
+using System;
+using System.Xml;
+using System.Text.RegularExpressions;
+
+namespace System.Xml
+{
+ public class XmlDeclaration : XmlLinkedNode
+ {
+ string encoding = "UTF-8"; // defaults to UTF-8
+ string standalone;
+ string version;
+
+ protected internal XmlDeclaration (string version, string encoding,
+ string standalone, XmlDocument doc)
+ : base (doc)
+ {
+ if (encoding == null)
+ encoding = "";
+
+ if (standalone == null)
+ standalone = "";
+
+ this.version = version;
+ this.encoding = encoding;
+ this.standalone = standalone;
+ }
+
+ public string Encoding {
+ get { return encoding; }
+ set { encoding = (value == null) ? String.Empty : value; }
+ }
+
+ public override string InnerText {
+ get { return Value; }
+ set { ParseInput (value); }
+ }
+
+ public override string LocalName {
+ get { return "xml"; }
+ }
+
+ public override string Name {
+ get { return "xml"; }
+ }
+
+ public override XmlNodeType NodeType {
+ get { return XmlNodeType.XmlDeclaration; }
+ }
+
+ public string Standalone {
+ get { return standalone; }
+ set {
+ if(value != null)
+ {
+ if (value.ToUpper() == "YES")
+ standalone = "yes";
+ if (value.ToUpper() == "NO")
+ standalone = "no";
+ }
+ else
+ standalone = String.Empty;
+ }
+ }
+
+ public override string Value {
+ get {
+ string formatEncoding = "";
+ string formatStandalone = "";
+
+ if (encoding != String.Empty)
+ formatEncoding = String.Format (" encoding=\"{0}\"", encoding);
+
+ if (standalone != String.Empty)
+ formatStandalone = String.Format (" standalone=\"{0}\"", standalone);
+
+ return String.Format ("version=\"{0}\"{1}{2}", Version, formatEncoding, formatStandalone);
+ }
+ set { ParseInput (value); }
+ }
+
+ public string Version {
+ get { return version; }
+ }
+
+ public override XmlNode CloneNode (bool deep)
+ {
+ return new XmlDeclaration (Version, Encoding, standalone, OwnerDocument);
+ }
+
+ public override void WriteContentTo (XmlWriter w) {}
+
+ public override void WriteTo (XmlWriter w)
+ {
+ // This doesn't seem to match up very well with w.WriteStartDocument()
+ // so writing out custom here.
+ w.WriteRaw (String.Format ("<?xml {0}?>", Value));
+ }
+
+ void ParseInput (string input)
+ {
+// Encoding = input.Split (new char [] { ' ' }) [1].Split (new char [] { '=' }) [1];
+// Standalone = input.Split (new char [] { ' ' }) [2].Split (new char [] { '=' }) [1];
+ Match m = XmlDeclRegex.Match(input);
+ if(!m.Success)
+ throw new XmlException("illegal XML declaration format.");
+// Version = m.Result("${ver}");
+ Encoding = m.Result("${enc}");
+ Standalone = m.Result("${sta}");
+ }
+
+ // This regular expression matches XMLDecl of XML specification BNF[23]
+ static Regex xmlDeclRegex;
+ Regex XmlDeclRegex
+ {
+ get
+ {
+ if(xmlDeclRegex == null) xmlDeclRegex = new Regex(allMatch, RegexOptions.Compiled);
+ return xmlDeclRegex;
+ }
+ }
+
+ // This code makes some loss, but you may understand a bit easily.
+ const string verMatch = "\\s*version\\s*=\\s*(\\'(?<ver>.*?)\\'|\\\"(?<ver>.*?)\")";
+ const string encMatch = "\\s*encoding\\s*=\\s*(\\'(?<enc>.*?)\\'|\\\"(?<enc>.*?)\")";
+ const string staMatch = "\\s*standalone\\s*=\\s*(\\'(?<sta>.*?)\\'|\\\"(?<sta>.*?)\")";
+ const string allMatch = verMatch + "(" + encMatch + ")?(" + staMatch + ")?";
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlDocument.cs b/mcs/class/System.XML/System.Xml/XmlDocument.cs
new file mode 100644
index 00000000000..e54a1ed4dcc
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlDocument.cs
@@ -0,0 +1,891 @@
+//
+// System.Xml.XmlDocument
+//
+// Authors:
+// Daniel Weber (daniel-weber@austin.rr.com)
+// Kral Ferch <kral_ferch@hotmail.com>
+// Jason Diamond <jason@injektilo.org>
+// Miguel de Icaza (miguel@ximian.com)
+// Duncan Mak (duncan@ximian.com)
+// Atsushi Enomoto (ginga@kit.hi-ho.ne.jp)
+//
+// (C) 2001 Daniel Weber
+// (C) 2002 Kral Ferch, Jason Diamond, Miguel de Icaza, Duncan Mak,
+// Atsushi Enomoto
+//
+
+using System;
+using System.IO;
+using System.Text;
+using System.Xml.XPath;
+using System.Diagnostics;
+using System.Collections;
+
+namespace System.Xml
+{
+ public class XmlDocument : XmlNode
+ {
+ #region Fields
+
+ XmlLinkedNode lastLinkedChild;
+ XmlNameTable nameTable;
+ string baseURI = String.Empty;
+ XmlImplementation implementation;
+ bool preserveWhitespace = false;
+ WeakReference reusableXmlTextReader;
+
+ #endregion
+
+ #region Constructors
+
+ public XmlDocument () : this (null, null)
+ {
+ }
+
+ protected internal XmlDocument (XmlImplementation imp) : this (imp, null)
+ {
+ }
+
+ public XmlDocument (XmlNameTable nt) : this (null, nt)
+ {
+ }
+
+ XmlDocument (XmlImplementation impl, XmlNameTable nt) : base (null)
+ {
+ implementation = (impl != null) ? impl : new XmlImplementation ();
+ nameTable = (nt != null) ? nt : implementation.internalNameTable;
+ AddDefaultNameTableKeys ();
+ }
+ #endregion
+
+ #region Events
+
+ public event XmlNodeChangedEventHandler NodeChanged;
+
+ public event XmlNodeChangedEventHandler NodeChanging;
+
+ public event XmlNodeChangedEventHandler NodeInserted;
+
+ public event XmlNodeChangedEventHandler NodeInserting;
+
+ public event XmlNodeChangedEventHandler NodeRemoved;
+
+ public event XmlNodeChangedEventHandler NodeRemoving;
+
+ #endregion
+
+ #region Properties
+
+ public override string BaseURI {
+ get {
+ return baseURI;
+ }
+ }
+
+ // Used to read 'InnerXml's for its descendants at any place.
+ internal XmlTextReader ReusableReader {
+ get {
+ if(reusableXmlTextReader == null)
+ reusableXmlTextReader = new WeakReference (null);
+ if(!reusableXmlTextReader.IsAlive) {
+ XmlTextReader reader = new XmlTextReader ((TextReader)null);
+ reusableXmlTextReader.Target = reader;
+ }
+ return (XmlTextReader)reusableXmlTextReader.Target;
+ }
+ }
+
+ public XmlElement DocumentElement {
+ get {
+ XmlNode node = FirstChild;
+
+ while (node != null) {
+ if (node is XmlElement)
+ break;
+ node = node.NextSibling;
+ }
+
+ return node != null ? node as XmlElement : null;
+ }
+ }
+
+ [MonoTODO("It doesn't have internal subset object model.")]
+ public virtual XmlDocumentType DocumentType {
+ get {
+ foreach(XmlNode n in this.ChildNodes) {
+ if(n.NodeType == XmlNodeType.DocumentType)
+ return (XmlDocumentType)n;
+ }
+ return null;
+ }
+ }
+
+ public XmlImplementation Implementation {
+ get { return implementation; }
+ }
+
+ public override string InnerXml {
+ get {
+ return base.InnerXml;
+ }
+ set { // reason for overriding
+ this.LoadXml (value);
+ }
+ }
+
+ public override bool IsReadOnly {
+ get { return false; }
+ }
+
+ internal override XmlLinkedNode LastLinkedChild {
+ get {
+ return lastLinkedChild;
+ }
+
+ set {
+ lastLinkedChild = value;
+ }
+ }
+
+ public override string LocalName {
+ get { return "#document"; }
+ }
+
+ public override string Name {
+ get { return "#document"; }
+ }
+
+ public XmlNameTable NameTable {
+ get { return nameTable; }
+ }
+
+ public override XmlNodeType NodeType {
+ get { return XmlNodeType.Document; }
+ }
+
+ internal override XPathNodeType XPathNodeType {
+ get {
+ return XPathNodeType.Root;
+ }
+ }
+
+ public override XmlDocument OwnerDocument {
+ get { return null; }
+ }
+
+ public bool PreserveWhitespace {
+ get { return preserveWhitespace; }
+ set { preserveWhitespace = value; }
+ }
+
+ internal override string XmlLang {
+ get { return String.Empty; }
+ }
+
+ [MonoTODO]
+ public virtual XmlResolver XmlResolver {
+ set { throw new NotImplementedException (); }
+ }
+
+ internal override XmlSpace XmlSpace {
+ get {
+ return XmlSpace.None;
+ }
+ }
+
+ #endregion
+
+ #region Methods
+
+ [MonoTODO("Should BaseURI be cloned?")]
+ public override XmlNode CloneNode (bool deep)
+ {
+ XmlDocument doc = implementation.CreateDocument ();
+ doc.PreserveWhitespace = PreserveWhitespace; // required?
+ if(deep)
+ {
+ foreach(XmlNode n in ChildNodes)
+ doc.AppendChild (doc.ImportNode (n, deep));
+ }
+ return doc;
+ }
+
+ public XmlAttribute CreateAttribute (string name)
+ {
+ return CreateAttribute (name, String.Empty);
+ }
+
+ public XmlAttribute CreateAttribute (string qualifiedName, string namespaceURI)
+ {
+ string prefix;
+ string localName;
+
+ ParseName (qualifiedName, out prefix, out localName);
+
+ return CreateAttribute (prefix, localName, namespaceURI);
+ }
+
+ public virtual XmlAttribute CreateAttribute (string prefix, string localName, string namespaceURI)
+ {
+ if ((localName == null) || (localName == String.Empty))
+ throw new ArgumentException ("The attribute local name cannot be empty.");
+
+ return new XmlAttribute (prefix, localName, namespaceURI, this);
+ }
+
+ public virtual XmlCDataSection CreateCDataSection (string data)
+ {
+ return new XmlCDataSection (data, this);
+ }
+
+ public virtual XmlComment CreateComment (string data)
+ {
+ return new XmlComment (data, this);
+ }
+
+ [MonoTODO]
+ protected internal virtual XmlAttribute CreateDefaultAttribute (string prefix, string localName, string namespaceURI)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public virtual XmlDocumentFragment CreateDocumentFragment ()
+ {
+ return new XmlDocumentFragment (this);
+ }
+
+ public virtual XmlDocumentType CreateDocumentType (string name, string publicId,
+ string systemId, string internalSubset)
+ {
+ return new XmlDocumentType (name, publicId, systemId, internalSubset, this);
+ }
+
+ public XmlElement CreateElement (string name)
+ {
+ return CreateElement (name, String.Empty);
+ }
+
+ public XmlElement CreateElement (
+ string qualifiedName,
+ string namespaceURI)
+ {
+ string prefix;
+ string localName;
+
+ ParseName (qualifiedName, out prefix, out localName);
+
+ return CreateElement (prefix, localName, namespaceURI);
+ }
+
+ public virtual XmlElement CreateElement (
+ string prefix,
+ string localName,
+ string namespaceURI)
+ {
+ if ((localName == null) || (localName == String.Empty))
+ throw new ArgumentException ("The local name for elements or attributes cannot be null or an empty string.");
+ CheckName (localName);
+ return new XmlElement (prefix != null ? prefix : String.Empty, localName, namespaceURI != null ? namespaceURI : String.Empty, this);
+ }
+
+ public virtual XmlEntityReference CreateEntityReference (string name)
+ {
+ return new XmlEntityReference (name, this);
+ }
+
+ [MonoTODO]
+ internal protected virtual XPathNavigator CreateNavigator (XmlNode node)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public virtual XmlNode CreateNode (
+ string nodeTypeString,
+ string name,
+ string namespaceURI)
+ {
+ return CreateNode (GetNodeTypeFromString (nodeTypeString), name, namespaceURI);
+ }
+
+ public virtual XmlNode CreateNode (
+ XmlNodeType type,
+ string name,
+ string namespaceURI)
+ {
+ string prefix = null;
+ string localName = name;
+
+ if ((type == XmlNodeType.Attribute) || (type == XmlNodeType.Element) || (type == XmlNodeType.EntityReference))
+ ParseName (name, out prefix, out localName);
+
+ return CreateNode (type, prefix, localName, namespaceURI);
+ }
+
+ public virtual XmlNode CreateNode (
+ XmlNodeType type,
+ string prefix,
+ string name,
+ string namespaceURI)
+ {
+ switch (type) {
+ case XmlNodeType.Attribute: return CreateAttribute (prefix, name, namespaceURI);
+ case XmlNodeType.CDATA: return CreateCDataSection (null);
+ case XmlNodeType.Comment: return CreateComment (null);
+ case XmlNodeType.Document: return new XmlDocument (); // TODO - test to see which constructor to use, i.e. use existing NameTable or not.
+ case XmlNodeType.DocumentFragment: return CreateDocumentFragment ();
+ case XmlNodeType.DocumentType: return CreateDocumentType (null, null, null, null);
+ case XmlNodeType.Element: return CreateElement (prefix, name, namespaceURI);
+ case XmlNodeType.EntityReference: return CreateEntityReference (null);
+ case XmlNodeType.ProcessingInstruction: return CreateProcessingInstruction (null, null);
+ case XmlNodeType.SignificantWhitespace: return CreateSignificantWhitespace (String.Empty);
+ case XmlNodeType.Text: return CreateTextNode (null);
+ case XmlNodeType.Whitespace: return CreateWhitespace (String.Empty);
+ case XmlNodeType.XmlDeclaration: return CreateXmlDeclaration ("1.0", null, null);
+ default: throw new ArgumentOutOfRangeException(String.Format("{0}\nParameter name: {1}",
+ "Specified argument was out of the range of valid values", type.ToString ()));
+ }
+ }
+
+ public virtual XmlProcessingInstruction CreateProcessingInstruction (
+ string target,
+ string data)
+ {
+ return new XmlProcessingInstruction (target, data, this);
+ }
+
+ public virtual XmlSignificantWhitespace CreateSignificantWhitespace (string text)
+ {
+ foreach (char c in text)
+ if ((c != ' ') && (c != '\r') && (c != '\n') && (c != '\t'))
+ throw new ArgumentException ("Invalid whitespace characters.");
+
+ return new XmlSignificantWhitespace (text, this);
+ }
+
+ public virtual XmlText CreateTextNode (string text)
+ {
+ return new XmlText (text, this);
+ }
+
+ public virtual XmlWhitespace CreateWhitespace (string text)
+ {
+ foreach (char c in text)
+ if ((c != ' ') && (c != '\r') && (c != '\n') && (c != '\t'))
+ throw new ArgumentException ("Invalid whitespace characters.");
+
+ return new XmlWhitespace (text, this);
+ }
+
+ public virtual XmlDeclaration CreateXmlDeclaration (string version, string encoding,
+ string standalone)
+ {
+ if (version != "1.0")
+ throw new ArgumentException ("version string is not correct.");
+
+ if ((standalone != null && standalone != String.Empty) && !((standalone == "yes") || (standalone == "no")))
+ throw new ArgumentException ("standalone string is not correct.");
+
+ return new XmlDeclaration (version, encoding, standalone, this);
+ }
+
+ [MonoTODO]
+ public virtual XmlElement GetElementById (string elementId)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public virtual XmlNodeList GetElementsByTagName (string name)
+ {
+ ArrayList nodeArrayList = new ArrayList ();
+ this.searchNodesRecursively (this, name, nodeArrayList);
+ return new XmlNodeArrayList (nodeArrayList);
+ }
+
+ private void searchNodesRecursively (XmlNode argNode, string argName,
+ ArrayList argArrayList)
+ {
+ XmlNodeList xmlNodeList = argNode.ChildNodes;
+ foreach (XmlNode node in xmlNodeList){
+ if (node.Name.Equals (argName))
+ argArrayList.Add (node);
+ else
+ this.searchNodesRecursively (node, argName, argArrayList);
+ }
+ }
+
+ private void searchNodesRecursively (XmlNode argNode, string argName, string argNamespaceURI,
+ ArrayList argArrayList)
+ {
+ XmlNodeList xmlNodeList = argNode.ChildNodes;
+ foreach (XmlNode node in xmlNodeList){
+ if (node.LocalName.Equals (argName) && node.NamespaceURI.Equals (argNamespaceURI))
+ argArrayList.Add (node);
+ else
+ this.searchNodesRecursively (node, argName, argNamespaceURI, argArrayList);
+ }
+ }
+
+ public virtual XmlNodeList GetElementsByTagName (string localName, string namespaceURI)
+ {
+ ArrayList nodeArrayList = new ArrayList ();
+ this.searchNodesRecursively (this, localName, namespaceURI, nodeArrayList);
+ return new XmlNodeArrayList (nodeArrayList);
+ }
+
+ private XmlNodeType GetNodeTypeFromString (string nodeTypeString)
+ {
+ switch (nodeTypeString) {
+ case "attribute": return XmlNodeType.Attribute;
+ case "cdatasection": return XmlNodeType.CDATA;
+ case "comment": return XmlNodeType.Comment;
+ case "document": return XmlNodeType.Document;
+ case "documentfragment": return XmlNodeType.DocumentFragment;
+ case "documenttype": return XmlNodeType.DocumentType;
+ case "element": return XmlNodeType.Element;
+ case "entityreference": return XmlNodeType.EntityReference;
+ case "processinginstruction": return XmlNodeType.ProcessingInstruction;
+ case "significantwhitespace": return XmlNodeType.SignificantWhitespace;
+ case "text": return XmlNodeType.Text;
+ case "whitespace": return XmlNodeType.Whitespace;
+ default:
+ throw new ArgumentException(String.Format("The string doesn't represent any node type : {0}.", nodeTypeString));
+ }
+ }
+
+ [MonoTODO("default attributes (of imported doc); Entity; Notation")]
+ public virtual XmlNode ImportNode (XmlNode node, bool deep)
+ {
+ switch(node.NodeType)
+ {
+ case XmlNodeType.Attribute:
+ {
+ XmlAttribute src_att = node as XmlAttribute;
+ XmlAttribute dst_att = this.CreateAttribute (src_att.Prefix, src_att.LocalName, src_att.NamespaceURI);
+ dst_att.Value = src_att.Value; // always explicitly specified (whether source is specified or not)
+ return dst_att;
+ }
+
+ case XmlNodeType.CDATA:
+ return this.CreateCDataSection (node.Value);
+
+ case XmlNodeType.Comment:
+ return this.CreateComment (node.Value);
+
+ case XmlNodeType.Document:
+ throw new XmlException ("Document cannot be imported.");
+
+ case XmlNodeType.DocumentFragment:
+ {
+ XmlDocumentFragment df = this.CreateDocumentFragment ();
+ if(deep)
+ {
+ foreach(XmlNode n in node.ChildNodes)
+ {
+ df.AppendChild (this.ImportNode (n, deep));
+ }
+ }
+ return df;
+ }
+
+ case XmlNodeType.DocumentType:
+ throw new XmlException ("DocumentType cannot be imported.");
+
+ case XmlNodeType.Element:
+ {
+ XmlElement src = (XmlElement)node;
+ XmlElement dst = this.CreateElement (src.Prefix, src.LocalName, src.NamespaceURI);
+ foreach(XmlAttribute attr in src.Attributes)
+ {
+ if(attr.Specified) // copies only specified attributes
+ dst.SetAttributeNode ((XmlAttribute)this.ImportNode (attr, deep));
+ if(DocumentType != null)
+ {
+ // TODO: create default attribute values
+ }
+ }
+ if(deep)
+ {
+ foreach(XmlNode n in src.ChildNodes)
+ dst.AppendChild (this.ImportNode (n, deep));
+ }
+ return dst;
+ }
+
+ case XmlNodeType.EndElement:
+ throw new XmlException ("Illegal ImportNode call for NodeType.EndElement");
+ case XmlNodeType.EndEntity:
+ throw new XmlException ("Illegal ImportNode call for NodeType.EndEntity");
+
+ case XmlNodeType.Entity:
+ throw new NotImplementedException (); // TODO
+
+ case XmlNodeType.EntityReference:
+ return this.CreateEntityReference (node.Name);
+
+ case XmlNodeType.None:
+ throw new XmlException ("Illegal ImportNode call for NodeType.None");
+
+ case XmlNodeType.Notation:
+ throw new NotImplementedException (); // TODO
+
+ case XmlNodeType.ProcessingInstruction:
+ XmlProcessingInstruction pi = node as XmlProcessingInstruction;
+ return this.CreateProcessingInstruction (pi.Target, pi.Data);
+
+ case XmlNodeType.SignificantWhitespace:
+ return this.CreateSignificantWhitespace (node.Value);
+
+ case XmlNodeType.Text:
+ return this.CreateTextNode (node.Value);
+
+ case XmlNodeType.Whitespace:
+ return this.CreateWhitespace (node.Value);
+
+ case XmlNodeType.XmlDeclaration:
+ XmlDeclaration srcDecl = node as XmlDeclaration;
+ return this.CreateXmlDeclaration (srcDecl.Version, srcDecl.Encoding, srcDecl.Standalone);
+
+ default:
+ throw new NotImplementedException ();
+ }
+ }
+
+ public virtual void Load (Stream inStream)
+ {
+ XmlReader xmlReader = new XmlTextReader (inStream);
+ Load (xmlReader);
+ }
+
+ public virtual void Load (string filename)
+ {
+ baseURI = filename;
+ XmlReader xmlReader = new XmlTextReader (new StreamReader (filename));
+ Load (xmlReader);
+ }
+
+ public virtual void Load (TextReader txtReader)
+ {
+ Load (new XmlTextReader (txtReader));
+ }
+
+ public virtual void Load (XmlReader xmlReader)
+ {
+ // Reset our document
+ // For now this just means removing all our children but later this
+ // may turn out o need to call a private method that resets other things
+ // like properties we have, etc.
+ RemoveAll ();
+
+ // create all contents with use of ReadNode()
+ do {
+ XmlNode n = ReadNode (xmlReader);
+ if(n == null) break;
+ AppendChild (n);
+ } while (true);
+ }
+
+ public virtual void LoadXml (string xml)
+ {
+ XmlReader xmlReader = new XmlTextReader (new StringReader (xml));
+ Load (xmlReader);
+ }
+
+ internal void onNodeChanged (XmlNode node, XmlNode Parent)
+ {
+ if (NodeChanged != null)
+ NodeChanged (node, new XmlNodeChangedEventArgs
+ (XmlNodeChangedAction.Change,
+ node, Parent, Parent));
+ }
+
+ internal void onNodeChanging(XmlNode node, XmlNode Parent)
+ {
+ if (NodeChanging != null)
+ NodeChanging (node, new XmlNodeChangedEventArgs
+ (XmlNodeChangedAction.Change,
+ node, Parent, Parent));
+ }
+
+ internal void onNodeInserted (XmlNode node, XmlNode newParent)
+ {
+ if (NodeInserted != null)
+ NodeInserted (node, new XmlNodeChangedEventArgs
+ (XmlNodeChangedAction.Insert,
+ node, null, newParent));
+ }
+
+ internal void onNodeInserting (XmlNode node, XmlNode newParent)
+ {
+ if (NodeInserting != null)
+ NodeInserting (node, new XmlNodeChangedEventArgs
+ (XmlNodeChangedAction.Insert,
+ node, null, newParent));
+ }
+
+ internal void onNodeRemoved (XmlNode node, XmlNode oldParent)
+ {
+ if (NodeRemoved != null)
+ NodeRemoved (node, new XmlNodeChangedEventArgs
+ (XmlNodeChangedAction.Remove,
+ node, oldParent, null));
+ }
+
+ internal void onNodeRemoving (XmlNode node, XmlNode oldParent)
+ {
+ if (NodeRemoving != null)
+ NodeRemoving (node, new XmlNodeChangedEventArgs
+ (XmlNodeChangedAction.Remove,
+ node, oldParent, null));
+ }
+
+ private void ParseName (string name, out string prefix, out string localName)
+ {
+ int indexOfColon = name.IndexOf (':');
+
+ if (indexOfColon != -1) {
+ prefix = name.Substring (0, indexOfColon);
+ localName = name.Substring (indexOfColon + 1);
+ } else {
+ prefix = "";
+ localName = name;
+ }
+ }
+
+ // Checks that Element's name is valid
+ private void CheckName (String name)
+ {
+ // TODO: others validations?
+ if (name.IndexOf (" ") >= 0)
+ throw new XmlException ("The ' ' characted cannot be included in a name");
+ }
+
+ // Reads XmlReader and creates Attribute Node.
+ private XmlAttribute ReadAttributeNode(XmlReader reader)
+ {
+ if(reader.NodeType == XmlNodeType.Element)
+ reader.MoveToFirstAttribute ();
+ else if(reader.NodeType != XmlNodeType.Attribute)
+ throw new InvalidOperationException ("bad position to read attribute.");
+ XmlAttribute attribute = CreateAttribute (reader.Prefix, reader.LocalName, reader.NamespaceURI);
+ ReadAttributeNodeValue (reader, attribute);
+ return attribute;
+ }
+
+ // Reads attribute from XmlReader and then creates attribute value children. XmlAttribute also uses this.
+ internal void ReadAttributeNodeValue(XmlReader reader, XmlAttribute attribute)
+ {
+ while(reader.ReadAttributeValue ()) {
+ if(reader.NodeType == XmlNodeType.EntityReference)
+ // FIXME: if DocumentType is available, then try to resolve it.
+ attribute.AppendChild (CreateEntityReference (reader.Name));
+ // FIXME: else if(NodeType == EndEntity) -- reset BaseURI and so on -- ;
+ else
+ // (IMHO) Children of Attribute is likely restricted to Text and EntityReference.
+ attribute.AppendChild (CreateTextNode (reader.Value));
+ }
+ }
+
+ [MonoTODO("DTD parser is not completed.")]
+ public virtual XmlNode ReadNode(XmlReader reader)
+ {
+ // This logic was formerly defined in 'XmlNode.ConstructDOM()'
+
+ XmlNode resultNode = null;
+ XmlNode newNode = null;
+ XmlNode currentNode = null;
+ // It was originally XmlDocument.Load(reader reader) when mcs was v0.16.
+ int startDepth = reader.Depth;
+ bool atStart = true;
+ bool ignoredWhitespace;
+
+ do {
+ ignoredWhitespace = false;
+ reader.Read ();
+ // This complicated check is because we shouldn't make
+ // improper additional XmlReader.Read() by this method itself.
+ if(atStart && (reader.NodeType == XmlNodeType.EndElement ||
+ reader.NodeType == XmlNodeType.EndEntity))
+ throw new InvalidOperationException ("the XmlReader now holds invalid position.");
+ atStart = false;
+ switch (reader.NodeType) {
+
+ case XmlNodeType.Attribute:
+ newNode = ReadAttributeNode (reader);
+ break;
+
+ case XmlNodeType.CDATA:
+ newNode = CreateCDataSection (reader.Value);
+ if(currentNode != null)
+ currentNode.AppendChild (newNode);
+ break;
+
+ case XmlNodeType.Comment:
+ newNode = CreateComment (reader.Value);
+ if(currentNode != null)
+ currentNode.AppendChild (newNode);
+ break;
+
+ case XmlNodeType.Element:
+ XmlElement element = CreateElement (reader.Prefix, reader.LocalName, reader.NamespaceURI);
+ element.IsEmpty = reader.IsEmptyElement;
+ if(currentNode != null)
+ currentNode.AppendChild (element);
+ else
+ resultNode = element;
+
+ // set the element's attributes.
+ while (reader.MoveToNextAttribute ()) {
+ element.SetAttributeNode (ReadAttributeNode (reader));
+ }
+
+ reader.MoveToElement ();
+
+ if (!reader.IsEmptyElement)
+ currentNode = element;
+
+ break;
+
+ case XmlNodeType.EndElement:
+ if(currentNode.Name != reader.Name)
+ throw new XmlException ("mismatch end tag.");
+ currentNode = currentNode.ParentNode;
+ break;
+
+ case XmlNodeType.EndEntity:
+ break; // no operation
+
+ case XmlNodeType.ProcessingInstruction:
+ newNode = CreateProcessingInstruction (reader.Name, reader.Value);
+ if(currentNode != null)
+ currentNode.AppendChild (newNode);
+ break;
+
+ case XmlNodeType.Text:
+ newNode = CreateTextNode (reader.Value);
+ if(currentNode != null)
+ currentNode.AppendChild (newNode);
+ break;
+
+ case XmlNodeType.XmlDeclaration:
+ // empty strings are dummy, then gives over setting value contents to setter.
+ newNode = CreateXmlDeclaration ("1.0" , String.Empty, String.Empty);
+ ((XmlDeclaration)newNode).Value = reader.Value;
+ if(currentNode != null)
+ throw new XmlException ("XmlDeclaration at invalid position.");
+ break;
+
+ case XmlNodeType.DocumentType:
+ // This logic is kinda hack;-)
+ XmlTextReader xtReader = reader as XmlTextReader;
+ if(xtReader == null) {
+ xtReader = new XmlTextReader (reader.ReadOuterXml (),
+ XmlNodeType.DocumentType,
+ new XmlParserContext (NameTable, ConstructNamespaceManager(), XmlLang, XmlSpace));
+ xtReader.Read ();
+ }
+ newNode = CreateDocumentType (xtReader.Name,
+ xtReader.GetAttribute ("PUBLIC"),
+ xtReader.GetAttribute ("SYSTEM"),
+ xtReader.Value);
+ if(currentNode != null)
+ throw new XmlException ("XmlDocumentType at invalid position.");
+ break;
+
+ case XmlNodeType.EntityReference:
+ newNode = CreateEntityReference (reader.Name);
+ if(currentNode != null)
+ currentNode.AppendChild (newNode);
+ break;
+
+ case XmlNodeType.SignificantWhitespace:
+ newNode = CreateSignificantWhitespace (reader.Value);
+ if(currentNode != null)
+ currentNode.AppendChild (newNode);
+ break;
+
+ case XmlNodeType.Whitespace:
+ if(PreserveWhitespace) {
+ newNode = CreateWhitespace (reader.Value);
+ if(currentNode != null)
+ currentNode.AppendChild (newNode);
+ }
+ else
+ ignoredWhitespace = true;
+ break;
+ }
+ } while(ignoredWhitespace ||
+ reader.Depth > startDepth ||
+ // This complicated condition is because reader.Depth was set
+ // before XmlTextReader.depth increments ;-)
+ (reader.Depth == startDepth && reader.NodeType == XmlNodeType.Element && reader.IsEmptyElement == false)
+ );
+ return resultNode != null ? resultNode : newNode;
+ }
+
+ public virtual void Save(Stream outStream)
+ {
+ XmlTextWriter xmlWriter = new XmlTextWriter (outStream, Encoding.UTF8);
+ xmlWriter.Formatting = Formatting.Indented;
+ WriteContentTo (xmlWriter);
+ xmlWriter.Close ();
+ }
+
+ public virtual void Save (string filename)
+ {
+ XmlTextWriter xmlWriter = new XmlTextWriter (filename, Encoding.UTF8);
+ xmlWriter.Formatting = Formatting.Indented;
+ WriteContentTo (xmlWriter);
+ xmlWriter.Close ();
+ }
+
+ [MonoTODO]
+ public virtual void Save (TextWriter writer)
+ {
+ XmlTextWriter xmlWriter = new XmlTextWriter (writer);
+ xmlWriter.Formatting = Formatting.Indented;
+ WriteContentTo (xmlWriter);
+ xmlWriter.Flush ();
+ }
+
+ public virtual void Save (XmlWriter xmlWriter)
+ {
+ //
+ // This should preserve white space if PreserveWhiteSpace is true
+ //
+ WriteContentTo (xmlWriter);
+ xmlWriter.Flush ();
+ }
+
+ public override void WriteContentTo (XmlWriter w)
+ {
+ foreach(XmlNode childNode in ChildNodes) {
+ childNode.WriteTo (w);
+ }
+ }
+
+ public override void WriteTo (XmlWriter w)
+ {
+ WriteContentTo (w);
+ }
+
+ private void AddDefaultNameTableKeys ()
+ {
+ // The following keys are default of MS .NET Framework
+ nameTable.Add ("#text");
+ nameTable.Add ("xml");
+ nameTable.Add ("xmlns");
+ nameTable.Add ("#entity");
+ nameTable.Add ("#document-fragment");
+ nameTable.Add ("#comment");
+ nameTable.Add ("space");
+ nameTable.Add ("id");
+ nameTable.Add ("#whitespace");
+ nameTable.Add ("http://www.w3.org/2000/xmlns/");
+ nameTable.Add ("#cdata-section");
+ nameTable.Add ("lang");
+ nameTable.Add ("#document");
+ nameTable.Add ("#significant-whitespace");
+ }
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlDocumentFragment.cs b/mcs/class/System.XML/System.Xml/XmlDocumentFragment.cs
new file mode 100644
index 00000000000..d711c53f487
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlDocumentFragment.cs
@@ -0,0 +1,125 @@
+//
+// System.Xml.XmlDocumentFragment
+//
+// Author:
+// Duncan Mak (duncan@ximian.com)
+// Atsushi Enomoto (ginga@kit.hi-ho.ne.jp)
+//
+// (C), Ximian, Inc
+// (C)2002 Atsushi Enomoto
+using System;
+using System.IO;
+using System.Text;
+
+namespace System.Xml
+{
+ public class XmlDocumentFragment : XmlNode
+ {
+ #region Fields
+
+ private XmlLinkedNode lastLinkedChild;
+
+ #endregion
+
+ #region Constructor
+
+ protected internal XmlDocumentFragment (XmlDocument doc)
+ : base (doc)
+ {
+ }
+
+ #endregion
+ #region Properties
+
+ [MonoTODO("Setter is as incomplete as that of XmlElement.InnerXml")]
+ public override string InnerXml {
+ set {
+ // Copied from XmlElement.InnerXml (in the meantime;-))
+ foreach(XmlNode n in ChildNodes)
+ {
+ this.RemoveChild (n);
+ }
+
+ // I hope there are any well-performance logic...
+ XmlNameTable nt = this.OwnerDocument.NameTable;
+ XmlNamespaceManager nsmgr = this.ConstructNamespaceManager ();
+ XmlParserContext ctx = new XmlParserContext (nt, nsmgr, XmlLang, this.XmlSpace);
+ XmlTextReader xmlReader = OwnerDocument.ReusableReader;
+ xmlReader.SetReaderContext (String.Empty, ctx);
+ xmlReader.SetReaderFragment (new StringReader (value), XmlNodeType.Element);
+
+ do {
+ XmlNode n = OwnerDocument.ReadNode (xmlReader);
+ if(n == null) break;
+ AppendChild (n);
+ } while (true);
+ }
+ get {
+ StringBuilder sb = new StringBuilder ();
+ foreach(XmlNode n in ChildNodes)
+ sb.Append (n.OuterXml);
+ return sb.ToString ();
+ }
+ }
+
+ public override string LocalName {
+ get { return "#document-fragment"; }
+ }
+
+
+ public override string Name {
+ get { return "#document-fragment"; }
+ }
+
+ public override XmlNodeType NodeType {
+ get { return XmlNodeType.DocumentFragment; }
+ }
+
+ public override XmlDocument OwnerDocument {
+ get { return base.OwnerDocument; }
+ }
+
+ public override XmlNode ParentNode {
+ get { return null; } // it's always null here.
+ }
+
+ // It is really not a type of XmlLinkedNode,
+ // but I copied this way from XmlElement. I looks good.
+ internal override XmlLinkedNode LastLinkedChild
+ {
+ get { return lastLinkedChild; }
+ set { lastLinkedChild = value; }
+ }
+ #endregion
+
+ #region Methods
+ public override XmlNode CloneNode (bool deep)
+ {
+ if (deep) { // clone document + child nodes
+ XmlNode node = FirstChild;
+
+ while ((node != null) && (node.HasChildNodes)) {
+ AppendChild (node.NextSibling.CloneNode (false));
+ node = node.NextSibling;
+ }
+
+ return node;
+ } else
+ return new XmlDocumentFragment (OwnerDocument);
+ }
+
+ public override void WriteContentTo (XmlWriter w)
+ {
+ foreach(XmlNode n in ChildNodes)
+ n.WriteContentTo (w);
+ }
+
+ public override void WriteTo (XmlWriter w)
+ {
+ foreach(XmlNode n in ChildNodes)
+ n.WriteTo (w);
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlDocumentNavigator.cs b/mcs/class/System.XML/System.Xml/XmlDocumentNavigator.cs
new file mode 100644
index 00000000000..4df3fa7f169
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlDocumentNavigator.cs
@@ -0,0 +1,304 @@
+//
+// System.Xml.XmlDocumentNavigator
+//
+// Author:
+// Jason Diamond <jason@injektilo.org>
+//
+// (C) 2002 Jason Diamond
+//
+
+using System;
+using System.Collections;
+using System.Xml;
+using System.Xml.XPath;
+
+namespace System.Xml
+{
+ internal class XmlDocumentNavigator : XPathNavigator
+ {
+ #region Constructors
+
+ [MonoTODO]
+ internal XmlDocumentNavigator(XmlNode node)
+ {
+ this.node = node;
+ }
+
+ #endregion
+
+ #region Fields
+
+ private XmlNode node;
+ private IEnumerator attributesEnumerator;
+
+ #endregion
+
+ #region Properties
+
+ [MonoTODO]
+ public override string BaseURI {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ public override bool HasAttributes {
+ get {
+ if (node.Attributes != null)
+ foreach (XmlAttribute attribute in node.Attributes)
+ if (attribute.NamespaceURI != "http://www.w3.org/2000/xmlns/")
+ return true;
+ return false;
+ }
+ }
+
+ public override bool HasChildren {
+ get {
+ XPathNodeType nodeType = NodeType;
+ bool canHaveChildren = nodeType == XPathNodeType.Root || nodeType == XPathNodeType.Element;
+ return canHaveChildren && node.FirstChild != null;
+ }
+ }
+
+ public override bool IsEmptyElement {
+ get {
+ return node.NodeType == XmlNodeType.Element && !HasChildren;
+ }
+ }
+
+ public override string LocalName {
+ get {
+ XPathNodeType nodeType = NodeType;
+ bool canHaveName =
+ nodeType == XPathNodeType.Element ||
+ nodeType == XPathNodeType.Attribute ||
+ nodeType == XPathNodeType.ProcessingInstruction ||
+ nodeType == XPathNodeType.Namespace;
+ return canHaveName ? node.LocalName : String.Empty;
+ }
+ }
+
+ public override string Name {
+ get {
+ XPathNodeType nodeType = NodeType;
+ bool canHaveName =
+ nodeType == XPathNodeType.Element ||
+ nodeType == XPathNodeType.Attribute ||
+ nodeType == XPathNodeType.ProcessingInstruction ||
+ nodeType == XPathNodeType.Namespace;
+ return canHaveName ? node.Name : String.Empty;
+ }
+ }
+
+ public override string NamespaceURI {
+ get {
+ return node.NamespaceURI;
+ }
+ }
+
+ [MonoTODO]
+ public override XmlNameTable NameTable {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ public override XPathNodeType NodeType {
+ get {
+ return node.XPathNodeType;
+ }
+ }
+
+ public override string Prefix {
+ get {
+ return node.Prefix;
+ }
+ }
+
+ public override string Value {
+ get {
+ switch (NodeType) {
+ case XPathNodeType.Attribute:
+ case XPathNodeType.Comment:
+ case XPathNodeType.ProcessingInstruction:
+ case XPathNodeType.Text:
+ case XPathNodeType.Whitespace:
+ case XPathNodeType.SignificantWhitespace:
+ return node.Value;
+ case XPathNodeType.Element:
+ case XPathNodeType.Root:
+ return node.InnerText;
+ }
+ return String.Empty;
+ }
+ }
+
+ [MonoTODO]
+ public override string XmlLang {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ #endregion
+
+ #region Methods
+
+ public override XPathNavigator Clone ()
+ {
+ return new XmlDocumentNavigator (node);
+ }
+
+ [MonoTODO]
+ public override string GetAttribute (string localName, string namespaceURI)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override string GetNamespace (string name)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override bool IsSamePosition (XPathNavigator other)
+ {
+ XmlDocumentNavigator otherDocumentNavigator = other as XmlDocumentNavigator;
+ if (otherDocumentNavigator != null)
+ return node == otherDocumentNavigator.node;
+ return false;
+ }
+
+ public override bool MoveTo (XPathNavigator other)
+ {
+ XmlDocumentNavigator otherDocumentNavigator = other as XmlDocumentNavigator;
+ if (otherDocumentNavigator != null) {
+ if (node.OwnerDocument == otherDocumentNavigator.node.OwnerDocument) {
+ node = otherDocumentNavigator.node;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ [MonoTODO]
+ public override bool MoveToAttribute (string localName, string namespaceURI)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override bool MoveToFirst ()
+ {
+ if (node.NodeType != XmlNodeType.Attribute && node.ParentNode != null) {
+ node = node.ParentNode.FirstChild;
+ return true;
+ }
+ return false;
+ }
+
+ public override bool MoveToFirstAttribute ()
+ {
+ if (NodeType == XPathNodeType.Element) {
+ attributesEnumerator = node.Attributes.GetEnumerator ();
+ return MoveToNextAttribute ();
+ }
+ return false;
+ }
+
+ public override bool MoveToFirstChild ()
+ {
+ if (HasChildren) {
+ node = node.FirstChild;
+ return true;
+ }
+ return false;
+ }
+
+ [MonoTODO]
+ public override bool MoveToFirstNamespace (XPathNamespaceScope namespaceScope)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override bool MoveToId (string id)
+ {
+ XmlDocument doc;
+
+ if (node.NodeType == XmlNodeType.Document)
+ doc = (XmlDocument) node;
+ else
+ doc = node.OwnerDocument;
+
+ XmlElement eltNew = doc.GetElementById (id);
+ if (eltNew == null)
+ return false;
+
+ node = eltNew;
+ return true;
+ }
+
+ [MonoTODO]
+ public override bool MoveToNamespace (string name)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override bool MoveToNext ()
+ {
+ if (node.NextSibling != null) {
+ node = node.NextSibling;
+ return true;
+ }
+ return false;
+ }
+
+ public override bool MoveToNextAttribute ()
+ {
+ if (attributesEnumerator != null && attributesEnumerator.MoveNext ()) {
+ node = attributesEnumerator.Current as XmlAttribute;
+ return true;
+ }
+ return false;
+ }
+
+ [MonoTODO]
+ public override bool MoveToNextNamespace (XPathNamespaceScope namespaceScope)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override bool MoveToParent ()
+ {
+ if (node.NodeType == XmlNodeType.Attribute) {
+ XmlElement ownerElement = ((XmlAttribute)node).OwnerElement;
+ if (ownerElement != null) {
+ node = ownerElement;
+ return true;
+ }
+ } else if (node.ParentNode != null) {
+ node = node.ParentNode;
+ return true;
+ }
+ return false;
+ }
+
+ public override bool MoveToPrevious ()
+ {
+ if (node.PreviousSibling != null) {
+ node = node.PreviousSibling;
+ return true;
+ }
+ return false;
+ }
+
+ public override void MoveToRoot ()
+ {
+ if (node.NodeType != XmlNodeType.Document)
+ node = node.OwnerDocument;
+ }
+
+ internal XmlNode Node { get { return node; } }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlDocumentType.cs b/mcs/class/System.XML/System.Xml/XmlDocumentType.cs
new file mode 100644
index 00000000000..83dbf11c7ea
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlDocumentType.cs
@@ -0,0 +1,98 @@
+//
+// System.Xml.XmlDocumentType.cs
+//
+// Author: Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+namespace System.Xml
+{
+ public class XmlDocumentType : XmlLinkedNode
+ {
+ // Fields
+ string name; // name of the document type
+ string publicId; // public identifier on the DOCTYPE
+ string systemId; // system identifier on the DOCTYPE
+ string internalSubset; // value of the DTD internal subset
+
+ // Constructor
+ protected internal XmlDocumentType (string name, string publicId,
+ string systemId, string internalSubset,
+ XmlDocument doc)
+ : base (doc)
+ {
+ this.name = name;
+ this.publicId = publicId;
+ this.systemId = systemId;
+ this.internalSubset = internalSubset;
+ }
+
+
+ // Properties
+ [MonoTODO]
+ public XmlNamedNodeMap Entities
+ {
+ get { return null; }
+ }
+
+ public string InternalSubset
+ {
+ get { return internalSubset; }
+ }
+
+ public override bool IsReadOnly
+ {
+ get { return true; } // always return true
+ }
+
+ public override string LocalName
+ {
+ get { return name; }
+ }
+
+ public override string Name
+ {
+ get { return name; }
+ }
+
+ public override XmlNodeType NodeType
+ {
+ get { return XmlNodeType.DocumentType; }
+ }
+
+ [MonoTODO]
+ public XmlNamedNodeMap Notations
+ {
+ get { return null; }
+ }
+
+ public string PublicId
+ {
+ get { return publicId; }
+ }
+
+ public string SystemId
+ {
+ get { return systemId; }
+ }
+
+ // Methods
+ public override XmlNode CloneNode (bool deep)
+ {
+ // deep is ignored
+ return new XmlDocumentType (name, publicId, systemId,
+ internalSubset, OwnerDocument);
+ }
+
+ public override void WriteContentTo (XmlWriter w)
+ {
+ // No effect
+ }
+
+ [MonoTODO]
+ public override void WriteTo (XmlWriter w)
+ {
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlElement.cs b/mcs/class/System.XML/System.Xml/XmlElement.cs
new file mode 100644
index 00000000000..6b6fd2838b8
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlElement.cs
@@ -0,0 +1,383 @@
+//
+// System.Xml.XmlElement
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+// Atsushi Enomoto (ginga@kit.hi-ho.ne.jp)
+//
+// (C) 2002 Jason Diamond http://injektilo.org/
+// (C) 2002 Atsushi Enomoto
+//
+
+using System;
+using System.Collections;
+using System.Xml.XPath;
+using System.IO;
+using System.Text;
+
+namespace System.Xml
+{
+ public class XmlElement : XmlLinkedNode
+ {
+ #region Fields
+
+ private XmlAttributeCollection attributes;
+ private string localName;
+ private string namespaceURI;
+ private string prefix;
+ private bool isEmpty;
+
+ #endregion
+
+ #region Constructor
+
+ protected internal XmlElement (
+ string prefix,
+ string localName,
+ string namespaceURI,
+ XmlDocument doc) : base (doc)
+ {
+ this.prefix = prefix;
+ this.localName = localName;
+ this.namespaceURI = namespaceURI;
+
+ attributes = new XmlAttributeCollection (this);
+
+ // TODO: Adds default attributes
+ if(doc.DocumentType != null)
+ {
+ }
+ }
+
+ #endregion
+
+ #region Properties
+
+ public override XmlAttributeCollection Attributes {
+ get { return attributes; }
+ }
+
+ public virtual bool HasAttributes {
+ get { return attributes.Count > 0; }
+ }
+
+ public override string InnerText {
+ get {
+ return base.InnerText;
+ }
+ set {
+ // Why its behavior (of MS FCL) is different from InnerXml...?
+ if (FirstChild != null && FirstChild.NodeType == XmlNodeType.Text)
+ FirstChild.Value = value;
+ else {
+ if(FirstChild != null) {
+ foreach (XmlNode n in ChildNodes)
+ this.RemoveChild (n);
+ }
+ // creates new Text node
+ AppendChild(OwnerDocument.CreateTextNode(value));
+ }
+ }
+ }
+
+ public override string InnerXml {
+ get {
+ return base.InnerXml;
+ }
+ set {
+ foreach(XmlNode n in ChildNodes)
+ this.RemoveChild(n);
+
+ // I hope there are any well-performance logic...
+ XmlNameTable nt = this.OwnerDocument.NameTable;
+ XmlNamespaceManager nsmgr = this.ConstructNamespaceManager ();
+ XmlParserContext ctx = new XmlParserContext (nt, nsmgr, XmlLang, this.XmlSpace);
+ XmlTextReader xmlReader = OwnerDocument.ReusableReader;
+ xmlReader.SetReaderContext (String.Empty, ctx);
+ xmlReader.SetReaderFragment (new StringReader (value), XmlNodeType.Element);
+
+ do {
+ XmlNode n = OwnerDocument.ReadNode (xmlReader);
+ if(n == null) break;
+ AppendChild (n);
+ } while (true);
+ }
+ }
+
+ public bool IsEmpty {
+ get { return isEmpty; }
+
+ set {
+ if(value)
+ RemoveAll();
+ isEmpty = value;
+ }
+ }
+
+ public override string LocalName {
+ get { return localName; }
+ }
+
+ public override string Name {
+ get {
+ return prefix != String.Empty ? prefix + ":" + localName : localName;
+ }
+ }
+
+ public override string NamespaceURI {
+ get { return namespaceURI; }
+ }
+
+ [MonoTODO]
+ public override XmlNode NextSibling {
+ get {
+ return base.NextSibling;
+ }
+ }
+
+ public override XmlNodeType NodeType {
+ get {
+ return XmlNodeType.Element;
+ }
+ }
+
+ internal override XPathNodeType XPathNodeType {
+ get {
+ return XPathNodeType.Element;
+ }
+ }
+
+ [MonoTODO]
+ public override XmlDocument OwnerDocument {
+ get {
+ return base.OwnerDocument;
+ }
+ }
+
+ public override string Prefix {
+ get { return prefix; }
+ set { prefix = value; }
+ }
+
+ #endregion
+
+ #region Methods
+
+ [MonoTODO]
+ public override XmlNode CloneNode (bool deep)
+ {
+ XmlNode node = new XmlElement (prefix, localName, namespaceURI,
+ OwnerDocument);
+
+ for (int i = 0; i < node.Attributes.Count; i++)
+ node.AppendChild (node.Attributes [i].CloneNode (false));
+
+ if (deep) {
+ while ((node != null) && (node.HasChildNodes)) {
+ AppendChild (node.NextSibling.CloneNode (true));
+ node = node.NextSibling;
+ }
+ } // shallow cloning
+
+ //
+ // Reminder: Also look into Default attributes.
+ //
+ return node;
+ }
+
+ [MonoTODO]
+ public virtual string GetAttribute (string name)
+ {
+ XmlNode attributeNode = Attributes.GetNamedItem (name);
+ return attributeNode != null ? attributeNode.Value : String.Empty;
+ }
+
+ [MonoTODO]
+ public virtual string GetAttribute (string localName, string namespaceURI)
+ {
+ XmlNode attributeNode = Attributes.GetNamedItem (localName, namespaceURI);
+ return attributeNode != null ? attributeNode.Value : String.Empty;
+ }
+
+ [MonoTODO]
+ public virtual XmlAttribute GetAttributeNode (string name)
+ {
+ XmlNode attributeNode = Attributes.GetNamedItem (name);
+ return attributeNode != null ? attributeNode as XmlAttribute : null;
+ }
+
+ [MonoTODO]
+ public virtual XmlAttribute GetAttributeNode (string localName, string namespaceURI)
+ {
+ XmlNode attributeNode = Attributes.GetNamedItem (localName, namespaceURI);
+ return attributeNode != null ? attributeNode as XmlAttribute : null;
+ }
+
+ public virtual XmlNodeList GetElementsByTagName (string name)
+ {
+ ArrayList nodeArrayList = new ArrayList ();
+ this.searchNodesRecursively (this, name, nodeArrayList);
+ return new XmlNodeArrayList (nodeArrayList);
+ }
+
+ private void searchNodesRecursively (XmlNode argNode, string argName,
+ ArrayList argArrayList)
+ {
+ XmlNodeList xmlNodeList = argNode.ChildNodes;
+ foreach (XmlNode node in xmlNodeList){
+ if (node.Name.Equals (argName))
+ argArrayList.Add (node);
+ else
+ this.searchNodesRecursively (node, argName, argArrayList);
+ }
+ }
+
+ private void searchNodesRecursively (XmlNode argNode, string argName, string argNamespaceURI,
+ ArrayList argArrayList)
+ {
+ XmlNodeList xmlNodeList = argNode.ChildNodes;
+ foreach (XmlNode node in xmlNodeList)
+ {
+ if (node.LocalName.Equals (argName) && node.NamespaceURI.Equals (argNamespaceURI))
+ argArrayList.Add (node);
+ else
+ this.searchNodesRecursively (node, argName, argNamespaceURI, argArrayList);
+ }
+ }
+
+ public virtual XmlNodeList GetElementsByTagName (string localName, string namespaceURI)
+ {
+ ArrayList nodeArrayList = new ArrayList ();
+ this.searchNodesRecursively (this, localName, namespaceURI, nodeArrayList);
+ return new XmlNodeArrayList (nodeArrayList);
+ }
+
+ [MonoTODO]
+ public virtual bool HasAttribute (string name)
+ {
+ XmlNode attributeNode = Attributes.GetNamedItem (name);
+ return attributeNode != null;
+ }
+
+ [MonoTODO]
+ public virtual bool HasAttribute (string localName, string namespaceURI)
+ {
+ XmlNode attributeNode = Attributes.GetNamedItem (localName, namespaceURI);
+ return attributeNode != null;
+ }
+
+ [MonoTODO ("confirm not removing default attributes [when DTD feature was implemented.")]
+ public override void RemoveAll ()
+ {
+ // Remove the child nodes.
+ base.RemoveAll ();
+
+ // Remove all attributes.
+ attributes.RemoveAll ();
+ }
+
+ [MonoTODO ("confirm not removing default attributes [when DTD feature was implemented.")]
+ public virtual void RemoveAllAttributes ()
+ {
+ attributes.RemoveAll ();
+ }
+
+ [MonoTODO ("confirm not resetting default attributes [when DTD feature was implemented.")]
+ public virtual void RemoveAttribute (string name)
+ {
+ attributes.Remove((XmlAttribute)attributes.GetNamedItem(name));
+ }
+
+ [MonoTODO ("confirm not resetting default attributes [when DTD feature was implemented.")]
+ public virtual void RemoveAttribute (string localName, string namespaceURI)
+ {
+ attributes.Remove((XmlAttribute)attributes.GetNamedItem(localName, namespaceURI));
+ }
+
+ [MonoTODO ("confirm not resetting default attributes [when DTD feature was implemented.")]
+ public virtual XmlNode RemoveAttributeAt (int i)
+ {
+ return attributes.Remove(attributes[i]);
+ }
+
+ [MonoTODO ("confirm not resetting default attributes [when DTD feature was implemented.")]
+ public virtual XmlAttribute RemoveAttributeNode (XmlAttribute oldAttr)
+ {
+ return attributes.Remove(oldAttr);
+ }
+
+ [MonoTODO ("confirm not resetting default attributes [when DTD feature was implemented.")]
+ public virtual XmlAttribute RemoveAttributeNode (string localName, string namespaceURI)
+ {
+ return attributes.Remove(attributes[localName, namespaceURI]);
+ }
+
+ [MonoTODO]
+ public virtual void SetAttribute (string name, string value)
+ {
+ XmlAttribute attribute = OwnerDocument.CreateAttribute (name);
+ attribute.SetOwnerElement(this);
+ attribute.Value = value;
+ Attributes.SetNamedItem (attribute);
+ }
+
+// [MonoTODO]
+ public virtual string SetAttribute (string localName, string namespaceURI, string value)
+ {
+ XmlAttribute attr = attributes[localName, namespaceURI];
+ if(attr == null)
+ {
+ attr = OwnerDocument.CreateAttribute(localName, namespaceURI);
+ attr.Value = value;
+ attributes.SetNamedItem(attr);
+ }
+ else
+ attr.Value = value;
+ return attr.Value;
+ }
+
+// [MonoTODO]
+ public virtual XmlAttribute SetAttributeNode (XmlAttribute newAttr)
+ {
+ newAttr.SetOwnerElement(this);
+ XmlNode oldAttr = Attributes.SetNamedItem(newAttr);
+ return oldAttr != null ? oldAttr as XmlAttribute : null;
+ }
+
+ public virtual XmlAttribute SetAttributeNode (string localName, string namespaceURI)
+ {
+ XmlDocument xmlDoc = this.OwnerDocument;
+ XmlAttribute xmlAttribute = new XmlAttribute (String.Empty, localName, namespaceURI, xmlDoc);
+ return this.attributes.Append (xmlAttribute);
+ }
+
+ public override void WriteContentTo (XmlWriter w)
+ {
+ foreach(XmlNode childNode in ChildNodes)
+ childNode.WriteTo(w);
+ }
+
+ [MonoTODO]
+ public override void WriteTo (XmlWriter w)
+ {
+ w.WriteStartElement(Prefix, LocalName, NamespaceURI);
+
+ foreach(XmlNode attributeNode in Attributes)
+ attributeNode.WriteTo(w);
+
+ // write namespace declarations(if not exist)
+ foreach(XmlNode attributeNode in Attributes) {
+ if(attributeNode.Prefix != null && attributeNode.Prefix != String.Empty &&
+ w.LookupPrefix(attributeNode.Prefix) != attributeNode.NamespaceURI &&
+ attributeNode.Prefix != "xmlns")
+ w.WriteAttributeString("xmlns", attributeNode.Prefix, "http://www.w3.org/2000/xmlns/", attributeNode.NamespaceURI);
+ }
+
+ WriteContentTo(w);
+
+ w.WriteEndElement();
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlEntity.cs b/mcs/class/System.XML/System.Xml/XmlEntity.cs
new file mode 100755
index 00000000000..f0778d8f3e7
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlEntity.cs
@@ -0,0 +1,123 @@
+//
+// System.Xml.XmlEntity.cs
+//
+// Author:
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+namespace System.Xml
+{
+ public class XmlEntity : XmlNode
+ {
+ #region Constructors
+
+ internal XmlEntity (string name, string NDATA, string publicId, string systemId,
+ XmlDocument doc)
+ : base (doc)
+ {
+ this.name = name;
+ this.NDATA = NDATA;
+ this.publicId = publicId;
+ this.systemId = systemId;
+ this.baseUri = doc.BaseURI;
+ }
+
+ #endregion
+
+ #region Fields
+
+ string name;
+ string NDATA;
+ string publicId;
+ string systemId;
+ string baseUri;
+
+ #endregion
+
+ #region Properties
+
+ public override string BaseURI {
+ get { return baseUri; }
+ }
+
+ [MonoTODO]
+ public override string InnerText {
+ get { throw new NotImplementedException (); }
+ set { throw new InvalidOperationException ("This operation is not supported."); }
+ }
+
+ public override string InnerXml {
+ get { return String.Empty; }
+ set { throw new InvalidOperationException ("This operation is not supported."); }
+ }
+
+ public override bool IsReadOnly {
+ get { return true; } // always read-only.
+ }
+
+ public override string LocalName {
+ get { return name; }
+ }
+
+ public override string Name {
+ get { return name; }
+ }
+
+ public override XmlNodeType NodeType {
+ get { return XmlNodeType.Entity; }
+ }
+
+ public string NotationName {
+ get {
+ if (NDATA == null)
+ return null;
+ else
+ return NDATA;
+ }
+ }
+
+ public override string OuterXml {
+ get { return String.Empty; }
+ }
+
+ public string PublicId {
+ get {
+ if (publicId == null)
+ return null;
+ else
+ return publicId;
+ }
+ }
+
+ public string SystemId {
+ get {
+ if (publicId == null)
+ return null;
+ else
+ return systemId;
+ }
+ }
+ #endregion
+
+ #region Methods
+
+ public override XmlNode CloneNode (bool deep)
+ {
+ throw new InvalidOperationException ("This operation is not supported.");
+ }
+
+ public override void WriteContentTo (XmlWriter w)
+ {
+ // No effect.
+ }
+
+ public override void WriteTo (XmlWriter w)
+ {
+ // No effect.
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlEntityReference.cs b/mcs/class/System.XML/System.Xml/XmlEntityReference.cs
new file mode 100644
index 00000000000..c6f94cf1bb6
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlEntityReference.cs
@@ -0,0 +1,75 @@
+//
+// System.Xml.XmlEntityReference.cs
+// Author:
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+
+namespace System.Xml
+{
+ public class XmlEntityReference : XmlLinkedNode
+ {
+ string entityName;
+
+ // Constructor
+ protected internal XmlEntityReference (string name, XmlDocument doc)
+ : base (doc)
+ {
+ entityName = name;
+ }
+
+ // Properties
+ [MonoTODO]
+ public override string BaseURI {
+ get { throw new NotImplementedException (); }
+ }
+
+ public override bool IsReadOnly {
+ get { return true; }
+ }
+
+ public override string LocalName {
+ get { return entityName; } // name of the entity referenced.
+ }
+
+ public override string Name {
+ get { return entityName; } // name of the entity referenced.
+ }
+
+ public override XmlNodeType NodeType {
+ get { return XmlNodeType.EntityReference; }
+ }
+
+ public override string Value {
+ get { return null; } // always return null here.
+ set {
+ throw new XmlException ("entity reference cannot be set value.");
+ }
+ }
+
+ // Methods
+ public override XmlNode CloneNode (bool deep)
+ {
+
+ // API docs: "The replacement text is not included." XmlNode.CloneNode
+ // "The replacement text is set when node is inserted." XmlEntityReference.CloneNode
+ //
+ return new XmlEntityReference ("", OwnerDocument);
+ }
+
+ public override void WriteContentTo (XmlWriter w)
+ {
+ // nothing to write for this object.
+ }
+
+ public override void WriteTo (XmlWriter w)
+ {
+ w.WriteRaw("&");
+ w.WriteName(Name);
+ w.WriteRaw(";");
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlException.cs b/mcs/class/System.XML/System.Xml/XmlException.cs
new file mode 100755
index 00000000000..e0aa241752d
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlException.cs
@@ -0,0 +1,93 @@
+//
+// XmlException.cs
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2002 Jason Diamond http://injektilo.org/
+//
+
+using System;
+using System.Runtime.Serialization;
+
+namespace System.Xml
+{
+ [Serializable]
+ public class XmlException : SystemException
+ {
+ #region Fields
+
+ int lineNumber;
+ int linePosition;
+
+ #endregion
+
+ #region Constructors
+
+ public XmlException (string message, Exception innerException)
+ : base (message, innerException)
+ {
+ }
+
+ protected XmlException (SerializationInfo info, StreamingContext context)
+ : base (info, context)
+ {
+ this.lineNumber = info.GetInt32 ("lineNumber");
+ this.linePosition = info.GetInt32 ("linePosition");
+ }
+
+ internal XmlException (string message)
+ : base (message)
+ {
+ }
+
+ internal XmlException (IXmlLineInfo li, string message) : base (message)
+ {
+ if (li != null) {
+ this.lineNumber = li.LineNumber;
+ this.linePosition = li.LinePosition;
+ }
+ }
+
+ internal XmlException (string message, int lineNumber, int linePosition) : base (message)
+ {
+ this.lineNumber = lineNumber;
+ this.linePosition = linePosition;
+ }
+
+ #endregion
+
+ #region Properties
+
+ public int LineNumber {
+ get { return lineNumber; }
+ }
+
+ public int LinePosition {
+ get { return linePosition; }
+ }
+
+ public override string Message {
+ get {
+ if (lineNumber == 0)
+ return base.Message;
+
+ return String.Format ("{0} Line {1}, position {2}.",
+ base.Message, lineNumber, linePosition);
+ }
+ }
+
+ #endregion
+
+ #region Methods
+
+ public override void GetObjectData (SerializationInfo info, StreamingContext context)
+ {
+ base.GetObjectData (info, context);
+ info.AddValue ("lineNumber", lineNumber);
+ info.AddValue ("linePosition", linePosition);
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlImplementation.cs b/mcs/class/System.XML/System.Xml/XmlImplementation.cs
new file mode 100644
index 00000000000..7febaa83644
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlImplementation.cs
@@ -0,0 +1,43 @@
+//
+// System.Xml.XmlImplementation.cs
+//
+// Author: Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+namespace System.Xml
+{
+ public class XmlImplementation
+ {
+ #region Constructor
+ public XmlImplementation ()
+ : base ()
+ {
+ // The following keys are default of MS .NET Framework
+ NameTable nt = new NameTable();
+ internalNameTable = nt;
+ }
+ #endregion
+
+ #region Public Methods
+ public virtual XmlDocument CreateDocument ()
+ {
+ return new XmlDocument (this);
+ }
+
+ public bool HasFeature (string strFeature, string strVersion)
+ {
+ if ((strFeature == "XML") || (strFeature == "xml") // not case-sensitive
+ && (strVersion == "1.0") || (strVersion == "2.0"))
+ return true;
+ else
+ return false;
+ }
+ #endregion
+
+ #region Internals
+ internal XmlNameTable internalNameTable;
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlLinkedNode.cs b/mcs/class/System.XML/System.Xml/XmlLinkedNode.cs
new file mode 100644
index 00000000000..cc6be542fd4
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlLinkedNode.cs
@@ -0,0 +1,77 @@
+//
+// System.Xml.XmlLinkedNode
+//
+// Authors:
+// Jason Diamond <jason@injektilo.org>
+// Kral Ferch <kral_ferch@hotmail.com>
+//
+// (C) 2002 Jason Diamond, Kral Ferch
+//
+
+using System;
+
+namespace System.Xml
+{
+ public abstract class XmlLinkedNode : XmlNode
+ {
+ #region Fields
+
+ XmlLinkedNode nextSibling;
+ XmlLinkedNode lastLinkedChild;
+
+ #endregion
+
+ #region Constructors
+ internal XmlLinkedNode(XmlDocument doc) : base(doc) { }
+
+ #endregion
+
+ #region Properties
+
+ public override XmlNode NextSibling
+ {
+ get {
+ if(ParentNode == null) {
+ return null;
+ }
+ else if (Object.ReferenceEquals(nextSibling, ParentNode.LastLinkedChild.NextLinkedSibling) == false) {
+ return nextSibling;
+ }
+ else {
+ return null;
+ }
+ }
+ }
+
+ internal XmlLinkedNode NextLinkedSibling
+ {
+ get { return nextSibling; }
+ set { nextSibling = value; }
+ }
+
+ public override XmlNode PreviousSibling
+ {
+ get {
+ if (ParentNode != null) {
+ XmlNode node = ParentNode.FirstChild;
+ if (node != this) {
+ do {
+ if (node.NextSibling == this)
+ return node;
+ } while ((node = node.NextSibling) != null);
+ }
+ }
+ return null;
+ }
+ }
+
+ // copied this way from XmlElement
+ internal override XmlLinkedNode LastLinkedChild
+ {
+ get { return lastLinkedChild; }
+ set { lastLinkedChild = value; }
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlNameTable.cs b/mcs/class/System.XML/System.Xml/XmlNameTable.cs
new file mode 100644
index 00000000000..7de896f0fc4
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlNameTable.cs
@@ -0,0 +1,20 @@
+// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// System.Xml.XmlNameTable.cs
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2001 Jason Diamond http://injektilo.org/
+//
+
+namespace System.Xml
+{
+ public abstract class XmlNameTable
+ {
+ public abstract string Add (string name);
+ public abstract string Add (char [] buffer, int offset, int length);
+ public abstract string Get (string name);
+ public abstract string Get (char [] buffer, int offset, int length);
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlNamedNodeMap.cs b/mcs/class/System.XML/System.Xml/XmlNamedNodeMap.cs
new file mode 100644
index 00000000000..756b30d18b6
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlNamedNodeMap.cs
@@ -0,0 +1,114 @@
+//
+// System.Xml.XmlNamedNodeMap
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) 2002 Jason Diamond http://injektilo.org/
+//
+
+using System;
+using System.Collections;
+
+namespace System.Xml
+{
+ public class XmlNamedNodeMap : IEnumerable
+ {
+ XmlNode parent;
+ ArrayList nodeList;
+ bool readOnly = false;
+
+ internal XmlNamedNodeMap (XmlNode parent)
+ {
+ this.parent = parent;
+ nodeList = new ArrayList ();
+ }
+
+ public virtual int Count {
+ get { return nodeList.Count; }
+ }
+
+ public virtual IEnumerator GetEnumerator ()
+ {
+ return nodeList.GetEnumerator ();
+ }
+
+ public virtual XmlNode GetNamedItem (string name)
+ {
+ foreach (XmlNode node in nodeList) {
+ if (node.Name == name)
+ return node;
+ }
+ return null;
+ }
+
+ public virtual XmlNode GetNamedItem (string localName, string namespaceURI)
+ {
+ foreach (XmlNode node in nodeList) {
+ if ((node.LocalName == localName)
+ && (node.NamespaceURI == namespaceURI))
+ return node;
+ }
+
+ return null;
+ }
+
+ public virtual XmlNode Item (int index)
+ {
+ if (index < 0 || index > nodeList.Count)
+ return null;
+ else
+ return (XmlNode) nodeList [index];
+ }
+
+ public virtual XmlNode RemoveNamedItem (string name)
+ {
+ foreach (XmlNode node in nodeList)
+ if (node.Name == name) {
+ nodeList.Remove (node);
+ return node;
+ }
+
+ return null;
+ }
+
+ public virtual XmlNode RemoveNamedItem (string localName, string namespaceURI)
+ {
+ foreach (XmlNode node in nodeList)
+ if ((node.LocalName == localName)
+ && (node.NamespaceURI == namespaceURI)) {
+ nodeList.Remove (node);
+ return node;
+ }
+
+ return null;
+ }
+
+ public virtual XmlNode SetNamedItem (XmlNode node)
+ {
+ return SetNamedItem(node, -1);
+ }
+
+ internal XmlNode SetNamedItem (XmlNode node, int pos)
+ {
+ if (readOnly || (node.OwnerDocument != parent.OwnerDocument))
+ throw new ArgumentException ("Cannot add to NodeMap.");
+
+ foreach (XmlNode x in nodeList)
+ if(x.LocalName == node.LocalName && x.NamespaceURI == node.NamespaceURI) {
+ nodeList.Remove (x);
+ nodeList.Add (node);
+ return x;
+ }
+
+ if(pos < 0)
+ nodeList.Add (node);
+ else
+ nodeList.Insert(pos, node);
+ return null;
+ }
+
+ internal ArrayList Nodes { get { return nodeList; } }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlNamespaceManager.cs b/mcs/class/System.XML/System.Xml/XmlNamespaceManager.cs
new file mode 100644
index 00000000000..ab8a0ebe6ce
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlNamespaceManager.cs
@@ -0,0 +1,182 @@
+//
+// XmlNamespaceManager.cs
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2001 Jason Diamond http://injektilo.org/
+//
+
+using System.Collections;
+
+namespace System.Xml
+{
+ public class XmlNamespaceManager : IEnumerable
+ {
+ #region Fields
+
+ private XmlNameTable nameTable;
+ private NamespaceScope currentScope;
+
+ #endregion
+
+ #region Constructor
+
+ public XmlNamespaceManager (XmlNameTable nameTable)
+ {
+ this.nameTable = nameTable;
+
+ nameTable.Add ("xmlns");
+ nameTable.Add ("xml");
+ nameTable.Add (String.Empty);
+ nameTable.Add ("http://www.w3.org/2000/xmlns/");
+ nameTable.Add ("http://www.w3.org/XML/1998/namespace");
+
+ PushScope ();
+ }
+
+ #endregion
+
+ #region Properties
+
+ public virtual string DefaultNamespace {
+ get { return LookupNamespace (String.Empty); }
+ }
+
+ public XmlNameTable NameTable {
+ get { return nameTable; }
+ }
+
+ #endregion
+
+ #region Methods
+
+ public virtual void AddNamespace (string prefix, string uri)
+ {
+ if (prefix == null)
+ throw new ArgumentNullException ("prefix", "Value cannot be null.");
+
+ if (uri == null)
+ throw new ArgumentNullException ("uri", "Value cannot be null.");
+
+ if (prefix.Length > 2 && prefix.Substring (0, 3).ToLower () == "xml")
+ throw new ArgumentException ( "Prefixes beginning with \"xml\" (regardless " + "of whether the characters are uppercase, lowercase, or some combination thereof) are reserved for use by XML.", "prefix");
+
+ if (currentScope.Namespaces == null)
+ currentScope.Namespaces = new Hashtable ();
+
+ if (prefix == String.Empty)
+ currentScope.Namespaces [prefix] = nameTable.Add (uri);
+ else
+ currentScope.Namespaces.Add (nameTable.Add (prefix), nameTable.Add (uri));
+ }
+
+ public virtual IEnumerator GetEnumerator ()
+ {
+ if (currentScope.Namespaces == null)
+ currentScope.Namespaces = new Hashtable ();
+
+ return currentScope.Namespaces.Keys.GetEnumerator ();
+ }
+
+ public virtual bool HasNamespace (string prefix)
+ {
+ return currentScope != null && currentScope.Namespaces != null && currentScope.Namespaces.Contains (prefix);
+ }
+
+ public virtual string LookupNamespace (string prefix)
+ {
+ NamespaceScope scope = currentScope;
+
+ while (scope != null) {
+ if (scope.Namespaces != null && scope.Namespaces.Contains (prefix))
+ return scope.Namespaces[prefix] as string;
+ scope = scope.Next;
+ }
+
+ switch (prefix) {
+ case "xmlns":
+ return nameTable.Get ("http://www.w3.org/2000/xmlns/");
+ case "xml":
+ return nameTable.Get ("http://www.w3.org/XML/1998/namespace");
+ case "":
+ return nameTable.Get (String.Empty);
+ }
+
+ return null;
+ }
+
+ public virtual string LookupPrefix (string uri)
+ {
+ if (uri == null)
+ return null;
+
+ NamespaceScope scope = currentScope;
+
+ while (scope != null)
+ {
+ if (scope.Namespaces != null && scope.Namespaces.ContainsValue (uri)) {
+ foreach (DictionaryEntry entry in scope.Namespaces) {
+ if (entry.Value.ToString() == uri)
+ return nameTable.Get (entry.Key as string) as string;
+ }
+ }
+
+ scope = scope.Next;
+ }
+
+ // ECMA specifies that this method returns String.Empty
+ // in case of no match. But actually MS.NET returns null.
+ // For more information,see
+ // http://lists.ximian.com/archives/public/mono-list/2003-January/005071.html
+ //return String.Empty;
+ return null;
+ }
+
+ public virtual bool PopScope ()
+ {
+ if (currentScope != null)
+ currentScope = currentScope.Next;
+
+ return currentScope != null;
+ }
+
+ public virtual void PushScope ()
+ {
+ NamespaceScope newScope = new NamespaceScope ();
+ newScope.Next = currentScope;
+ currentScope = newScope;
+ }
+
+ public virtual void RemoveNamespace (string prefix, string uri)
+ {
+ if (prefix == null)
+ throw new ArgumentNullException ("prefix");
+
+ if (uri == null)
+ throw new ArgumentNullException ("uri");
+
+ if (currentScope == null || currentScope.Namespaces == null)
+ return;
+
+ string p = nameTable.Get (prefix);
+ string u = nameTable.Get (uri);
+ if (p == null || u == null)
+ return;
+
+ string storedUri = currentScope.Namespaces [p] as string;
+ if (storedUri == null || storedUri != u)
+ return;
+
+ currentScope.Namespaces.Remove (p);
+ }
+
+ #endregion
+ }
+
+ internal class NamespaceScope
+ {
+ internal NamespaceScope Next;
+ internal Hashtable Namespaces;
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlNode.cs b/mcs/class/System.XML/System.Xml/XmlNode.cs
new file mode 100644
index 00000000000..f7502f16cf1
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlNode.cs
@@ -0,0 +1,532 @@
+//
+// System.Xml.XmlNode
+//
+// Author:
+// Kral Ferch <kral_ferch@hotmail.com>
+// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//
+// (C) 2002 Kral Ferch
+// (C) 2002 Atsushi Enomoto
+//
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Text;
+using System.Xml.XPath;
+
+namespace System.Xml
+{
+ public abstract class XmlNode : ICloneable, IEnumerable, IXPathNavigable
+ {
+ #region Fields
+
+ XmlDocument ownerDocument;
+ XmlNode parentNode;
+
+ #endregion
+
+ #region Constructors
+
+ internal XmlNode (XmlDocument ownerDocument)
+ {
+ this.ownerDocument = ownerDocument;
+ }
+
+ #endregion
+
+ #region Properties
+
+ public virtual XmlAttributeCollection Attributes {
+ get { return null; }
+ }
+
+ public virtual string BaseURI {
+ 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;
+ }
+ }
+
+ public virtual XmlNodeList ChildNodes {
+ get {
+ return new XmlNodeListChildren (this);
+ }
+ }
+
+ public virtual XmlNode FirstChild {
+ get {
+ if (LastChild != null) {
+ return LastLinkedChild.NextLinkedSibling;
+ }
+ else {
+ return null;
+ }
+ }
+ }
+
+ public virtual bool HasChildNodes {
+ get { return LastChild != null; }
+ }
+
+ [MonoTODO("confirm whether this way is right for each not-overriden types.")]
+ public virtual string InnerText {
+ get {
+ StringBuilder builder = new StringBuilder ();
+ AppendChildValues (this, builder);
+ return builder.ToString ();
+ }
+
+ set { throw new NotImplementedException (); }
+ }
+
+ private void AppendChildValues (XmlNode parent, StringBuilder builder)
+ {
+ XmlNode node = parent.FirstChild;
+
+ while (node != null) {
+ if (node.NodeType == XmlNodeType.Text)
+ builder.Append (node.Value);
+ AppendChildValues (node, builder);
+ node = node.NextSibling;
+ }
+ }
+
+ [MonoTODO("Setter.")]
+ public virtual string InnerXml {
+ get {
+ StringWriter sw = new StringWriter ();
+ XmlTextWriter xtw = new XmlTextWriter (sw);
+
+ WriteContentTo (xtw);
+
+ return sw.GetStringBuilder ().ToString ();
+ }
+
+ set { throw new NotImplementedException (); }
+ }
+
+ public virtual bool IsReadOnly {
+ get { return false; }
+ }
+
+ [System.Runtime.CompilerServices.IndexerName("Item")]
+ public virtual XmlElement this [string name] {
+ get {
+ foreach (XmlNode node in ChildNodes) {
+ if ((node.NodeType == XmlNodeType.Element) &&
+ (node.Name == name)) {
+ return (XmlElement) node;
+ }
+ }
+
+ return null;
+ }
+ }
+
+ [System.Runtime.CompilerServices.IndexerName("Item")]
+ public virtual XmlElement this [string localname, string ns] {
+ get {
+ foreach (XmlNode node in ChildNodes) {
+ if ((node.NodeType == XmlNodeType.Element) &&
+ (node.LocalName == localname) &&
+ (node.NamespaceURI == ns)) {
+ return (XmlElement) node;
+ }
+ }
+
+ return null;
+ }
+ }
+
+ public virtual XmlNode LastChild {
+ get { return LastLinkedChild; }
+ }
+
+ internal virtual XmlLinkedNode LastLinkedChild {
+ get { return null; }
+ set { }
+ }
+
+ public abstract string LocalName { get; }
+
+ public abstract string Name { get; }
+
+ public virtual string NamespaceURI {
+ get { return String.Empty; }
+ }
+
+ public virtual XmlNode NextSibling {
+ get { return null; }
+ }
+
+ public abstract XmlNodeType NodeType { get; }
+
+ internal virtual XPathNodeType XPathNodeType {
+ get {
+ return (XPathNodeType) (-1);
+ }
+ }
+
+ public virtual string OuterXml {
+ get {
+ StringWriter sw = new StringWriter ();
+ XmlTextWriter xtw = new XmlTextWriter (sw);
+
+ WriteTo (xtw);
+
+ return sw.GetStringBuilder ().ToString ();
+ }
+ }
+
+ public virtual XmlDocument OwnerDocument {
+ get { return ownerDocument; }
+ }
+
+ public virtual XmlNode ParentNode {
+ get { return parentNode; }
+ }
+
+ public virtual string Prefix {
+ get { return String.Empty; }
+ set {}
+ }
+
+ public virtual XmlNode PreviousSibling {
+ get { return null; }
+ }
+
+ public virtual string Value {
+ get { return null; }
+ set { throw new InvalidOperationException ("This node does not have a value"); }
+ }
+
+ internal virtual string XmlLang {
+ get {
+ if(Attributes != null)
+ foreach(XmlAttribute attr in Attributes)
+ if(attr.Name == "xml:lang")
+ return attr.Value;
+ return (ParentNode != null) ? ParentNode.XmlLang : OwnerDocument.XmlLang;
+ }
+ }
+
+ internal virtual XmlSpace XmlSpace {
+ get {
+ if(Attributes != null) {
+ foreach(XmlAttribute attr in Attributes) {
+ if(attr.Name == "xml:space") {
+ switch(attr.Value) {
+ case "preserve": return XmlSpace.Preserve;
+ case "default": return XmlSpace.Default;
+ }
+ break;
+ }
+ }
+ }
+ return (ParentNode != null) ? ParentNode.XmlSpace : OwnerDocument.XmlSpace;
+ }
+ }
+
+ #endregion
+
+ #region Methods
+
+ public virtual XmlNode AppendChild (XmlNode newChild)
+ {
+ // I assume that AppendChild(n) equals to InsertAfter(n, this.LastChild) or InsertBefore(n, null)
+ return InsertBefore (newChild, null);
+ }
+
+ public virtual XmlNode Clone ()
+ {
+ // By MS document, it is equivalent to CloneNode(true).
+ return this.CloneNode (true);
+ }
+
+ public abstract XmlNode CloneNode (bool deep);
+
+ [MonoTODO]
+ public XPathNavigator CreateNavigator ()
+ {
+ return new XmlDocumentNavigator (this);
+ }
+
+ public IEnumerator GetEnumerator ()
+ {
+ return new XmlNodeListChildren (this).GetEnumerator ();
+ }
+
+ [MonoTODO("performance problem.")]
+ public virtual string GetNamespaceOfPrefix (string prefix)
+ {
+ XmlNamespaceManager nsmgr = ConstructNamespaceManager ();
+ return nsmgr.LookupNamespace (prefix);
+ }
+
+ [MonoTODO("performance problem.")]
+ public virtual string GetPrefixOfNamespace (string namespaceURI)
+ {
+ XmlNamespaceManager nsmgr = ConstructNamespaceManager ();
+ string ns = nsmgr.LookupPrefix (namespaceURI);
+ return (ns != null) ? ns : String.Empty;
+ }
+
+ object ICloneable.Clone ()
+ {
+ return Clone ();
+ }
+
+ IEnumerator IEnumerable.GetEnumerator ()
+ {
+ return GetEnumerator ();
+ }
+
+ public virtual XmlNode InsertAfter (XmlNode newChild, XmlNode refChild)
+ {
+ // I assume that insertAfter(n1, n2) equals to InsertBefore(n1, n2.PreviousSibling).
+
+ // I took this way because rather than calling InsertAfter() from InsertBefore()
+ // because current implementation of 'NextSibling' looks faster than 'PreviousSibling'.
+ XmlNode argNode = null;
+ if(refChild != null)
+ argNode = refChild.NextSibling;
+ else if(ChildNodes.Count > 0)
+ argNode = FirstChild;
+ return InsertBefore (newChild, argNode);
+ }
+
+ [MonoTODO("If inserted node is entity reference, then check conforming entity. Wait for DTD implementation.")]
+ public virtual XmlNode InsertBefore (XmlNode newChild, XmlNode refChild)
+ {
+ XmlDocument ownerDoc = (NodeType == XmlNodeType.Document) ? (XmlDocument)this : OwnerDocument;
+
+ if (NodeType == XmlNodeType.Document ||
+ NodeType == XmlNodeType.Element ||
+ NodeType == XmlNodeType.Attribute ||
+ NodeType == XmlNodeType.DocumentFragment) {
+ if (IsReadOnly)
+ throw new ArgumentException ("The specified node is readonly.");
+
+ if (newChild.OwnerDocument != ownerDoc)
+ throw new ArgumentException ("Can't append a node created by another document.");
+
+ if (refChild != null && newChild.OwnerDocument != refChild.OwnerDocument)
+ throw new ArgumentException ("argument nodes are on the different documents.");
+
+ if (refChild != null && this == ownerDoc &&
+ ownerDoc.DocumentElement != null &&
+ (newChild is XmlElement ||
+ newChild is XmlCharacterData ||
+ newChild is XmlEntityReference))
+ throw new XmlException ("cannot insert this node to this position.");
+
+ // checking validity finished. then appending...
+
+ ownerDoc.onNodeInserting (newChild, this);
+
+ if(newChild.ParentNode != null)
+ newChild.ParentNode.RemoveChild (newChild);
+
+ if(newChild.NodeType == XmlNodeType.DocumentFragment) {
+ int x = newChild.ChildNodes.Count;
+ for(int i=0; i<x; i++) {
+ XmlNode n = newChild.ChildNodes [0];
+ this.InsertBefore (n, refChild); // recursively invokes events. (It is compatible with MS implementation.)
+ }
+ }
+ else {
+ XmlLinkedNode newLinkedChild = (XmlLinkedNode) newChild;
+ XmlLinkedNode lastLinkedChild = LastLinkedChild;
+
+ newLinkedChild.parentNode = this;
+
+ if(refChild == null) {
+ // append last, so:
+ // * set nextSibling of previous lastchild to newChild
+ // * set lastchild = newChild
+ // * set next of newChild to firstChild
+ if(LastLinkedChild != null) {
+ XmlLinkedNode formerFirst = FirstChild as XmlLinkedNode;
+ LastLinkedChild.NextLinkedSibling = newLinkedChild;
+ LastLinkedChild = newLinkedChild;
+ newLinkedChild.NextLinkedSibling = formerFirst;
+ }
+ else {
+ LastLinkedChild = newLinkedChild;
+ LastLinkedChild.NextLinkedSibling = newLinkedChild; // FirstChild
+ }
+ }
+ else {
+ // append not last, so:
+ // * if newchild is first, then set next of lastchild is newChild.
+ // otherwise, set next of previous sibling to newChild
+ // * set next of newChild to refChild
+ XmlLinkedNode prev = refChild.PreviousSibling as XmlLinkedNode;
+ if(prev == null)
+ LastLinkedChild.NextLinkedSibling = newLinkedChild;
+ else
+ prev.NextLinkedSibling = newLinkedChild;
+ newLinkedChild.NextLinkedSibling = refChild as XmlLinkedNode;
+ }
+ ownerDoc.onNodeInserted (newChild, newChild.ParentNode);
+ }
+ return newChild;
+ }
+ else
+ throw new InvalidOperationException ();
+ }
+
+ [MonoTODO]
+ public virtual void Normalize ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public virtual XmlNode PrependChild (XmlNode newChild)
+ {
+ return InsertAfter (newChild, null);
+ }
+
+ public virtual void RemoveAll ()
+ {
+ XmlNode next = null;
+ for (XmlNode node = FirstChild; node != null; node = next) {
+ next = node.NextSibling;
+ RemoveChild (node);
+ }
+ }
+
+ public virtual XmlNode RemoveChild (XmlNode oldChild)
+ {
+ XmlDocument ownerDoc = (NodeType == XmlNodeType.Document) ? (XmlDocument)this : OwnerDocument;
+ if(oldChild.ParentNode != this)
+ throw new XmlException ("specified child is not child of this node.");
+
+ ownerDoc.onNodeRemoving (oldChild, oldChild.ParentNode);
+
+ if (NodeType == XmlNodeType.Document || NodeType == XmlNodeType.Element || NodeType == XmlNodeType.Attribute || NodeType == XmlNodeType.DocumentFragment) {
+ if (IsReadOnly)
+ throw new ArgumentException ();
+
+ if (Object.ReferenceEquals (LastLinkedChild, LastLinkedChild.NextLinkedSibling) && Object.ReferenceEquals (LastLinkedChild, oldChild))
+ LastLinkedChild = null;
+ else {
+ XmlLinkedNode oldLinkedChild = (XmlLinkedNode)oldChild;
+ XmlLinkedNode beforeLinkedChild = LastLinkedChild;
+
+ while (!Object.ReferenceEquals (beforeLinkedChild.NextLinkedSibling, LastLinkedChild) && !Object.ReferenceEquals (beforeLinkedChild.NextLinkedSibling, oldLinkedChild))
+ beforeLinkedChild = beforeLinkedChild.NextLinkedSibling;
+
+ if (!Object.ReferenceEquals (beforeLinkedChild.NextLinkedSibling, oldLinkedChild))
+ throw new ArgumentException ();
+
+ beforeLinkedChild.NextLinkedSibling = oldLinkedChild.NextLinkedSibling;
+ oldLinkedChild.NextLinkedSibling = null;
+ }
+
+ ownerDoc.onNodeRemoved (oldChild, oldChild.ParentNode);
+ oldChild.parentNode = null; // clear parent 'after' above logic.
+
+ return oldChild;
+ }
+ else
+ throw new ArgumentException ();
+ }
+
+ [MonoTODO]
+ public virtual XmlNode ReplaceChild (XmlNode newChild, XmlNode oldChild)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public XmlNodeList SelectNodes (string xpath)
+ {
+ return SelectNodes (xpath, null);
+ }
+
+ [MonoTODO]
+ public XmlNodeList SelectNodes (string xpath, XmlNamespaceManager nsmgr)
+ {
+ XPathNavigator nav = CreateNavigator ();
+ XPathExpression expr = nav.Compile (xpath);
+ if (nsmgr != null)
+ expr.SetContext (nsmgr);
+ XPathNodeIterator iter = nav.Select (expr);
+ ArrayList rgNodes = new ArrayList ();
+ while (iter.MoveNext ())
+ {
+ rgNodes.Add (((XmlDocumentNavigator) iter.Current).Node);
+ }
+ return new XmlNodeArrayList (rgNodes);
+ }
+
+ public XmlNode SelectSingleNode (string xpath)
+ {
+ return SelectSingleNode (xpath, null);
+ }
+
+ [MonoTODO]
+ public XmlNode SelectSingleNode (string xpath, XmlNamespaceManager nsmgr)
+ {
+ XPathNavigator nav = CreateNavigator ();
+ XPathExpression expr = nav.Compile (xpath);
+ if (nsmgr != null)
+ expr.SetContext (nsmgr);
+ XPathNodeIterator iter = nav.Select (expr);
+ if (!iter.MoveNext ())
+ return null;
+ return ((XmlDocumentNavigator) iter.Current).Node;
+ }
+
+ internal void SetParentNode (XmlNode parent)
+ {
+ parentNode = parent;
+ }
+
+ [MonoTODO]
+ public virtual bool Supports (string feature, string version)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public abstract void WriteContentTo (XmlWriter w);
+
+ public abstract void WriteTo (XmlWriter w);
+
+ // It parses this and all the ancestor elements,
+ // find 'xmlns' declarations, stores and then return them.
+ // TODO: tests
+ internal XmlNamespaceManager ConstructNamespaceManager ()
+ {
+ XmlDocument doc = this is XmlDocument ? (XmlDocument)this : this.OwnerDocument;
+ XmlNamespaceManager nsmgr = new XmlNamespaceManager (doc.NameTable);
+ XmlElement el = null;
+ switch(this.NodeType) {
+ case XmlNodeType.Attribute:
+ el = ((XmlAttribute)this).OwnerElement;
+ break;
+ case XmlNodeType.Element:
+ el = this as XmlElement;
+ break;
+ default:
+ el = this.ParentNode as XmlElement;
+ break;
+ }
+
+ while(el != null) {
+ foreach(XmlAttribute attr in el.Attributes) {
+ if(attr.Prefix == "xmlns" || (attr.Name == "xmlns" && attr.Prefix == String.Empty)) {
+ if(nsmgr.LookupNamespace (attr.LocalName) == null )
+ nsmgr.AddNamespace (attr.LocalName, attr.Value);
+ }
+ }
+ // When reached to document, then it will set null value :)
+ el = el.ParentNode as XmlElement;
+ }
+ return nsmgr;
+ }
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlNodeArrayList.cs b/mcs/class/System.XML/System.Xml/XmlNodeArrayList.cs
new file mode 100644
index 00000000000..a62fd77f401
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlNodeArrayList.cs
@@ -0,0 +1,36 @@
+//
+// System.Xml.XmlNodeArrayList
+//
+// Author:
+// Piers Haken <piersh@friskit.com>
+//
+// (C) 2002 Piers Haken
+//
+
+using System;
+using System.Collections;
+
+namespace System.Xml
+{
+ internal class XmlNodeArrayList : XmlNodeList
+ {
+ ArrayList _rgNodes;
+
+ public XmlNodeArrayList (ArrayList rgNodes)
+ {
+ _rgNodes = rgNodes;
+ }
+
+ public override int Count { get { return _rgNodes.Count; } }
+
+ public override IEnumerator GetEnumerator ()
+ {
+ return _rgNodes.GetEnumerator ();
+ }
+
+ public override XmlNode Item (int index)
+ {
+ return (XmlNode) _rgNodes [index];
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlNodeChangedAction.cs b/mcs/class/System.XML/System.Xml/XmlNodeChangedAction.cs
new file mode 100755
index 00000000000..811edfd92f0
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlNodeChangedAction.cs
@@ -0,0 +1,27 @@
+using System;
+
+namespace System.Xml
+{
+ /// <summary>
+ /// Enumeration of node changed actions.
+ /// </summary>
+ public enum XmlNodeChangedAction
+ {
+
+ /// <summary>
+ /// A node is being inserted in the tree
+ /// </summary>
+ Insert = 0,
+
+ /// <summary>
+ /// A node is being removed from the tree.
+ /// </summary>
+ Remove = 1,
+
+ /// <summary>
+ /// A node is being changed.
+ /// </summary>
+ Change = 2,
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlNodeChangedEventArgs.cs b/mcs/class/System.XML/System.Xml/XmlNodeChangedEventArgs.cs
new file mode 100644
index 00000000000..29a842ad55d
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlNodeChangedEventArgs.cs
@@ -0,0 +1,67 @@
+using System;
+
+namespace System.Xml
+{
+ /// <summary>
+ /// Passed to delegates on document tree changes
+ /// </summary>
+ public class XmlNodeChangedEventArgs
+ {
+ // Private data members
+ XmlNode _oldParent;
+ XmlNode _newParent;
+ XmlNodeChangedAction _action;
+ XmlNode _node;
+
+ // public properties
+ public XmlNodeChangedAction Action
+ {
+ get
+ {
+ return _action;
+ }
+ }
+
+ public XmlNode Node
+ {
+ get
+ {
+ return _node;
+ }
+ }
+
+
+ public XmlNode OldParent
+ {
+ get
+ {
+ return _oldParent;
+ }
+ }
+
+
+ public XmlNode NewParent
+ {
+ get
+ {
+ return _newParent;
+ }
+ }
+
+
+ // Public Methods
+ // Internal Methods
+ internal XmlNodeChangedEventArgs(
+ XmlNodeChangedAction action,
+ XmlNode node,
+ XmlNode oldParent,
+ XmlNode newParent)
+ {
+ _node = node;
+ _oldParent = oldParent;
+ _newParent = newParent;
+ _action = action;
+ }
+
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlNodeChangedEventHandler.cs b/mcs/class/System.XML/System.Xml/XmlNodeChangedEventHandler.cs
new file mode 100755
index 00000000000..161482276d2
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlNodeChangedEventHandler.cs
@@ -0,0 +1,14 @@
+//
+// System.Xml.XmlNodeChangedEventHandler.cs
+//
+// Author:
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+namespace System.Xml
+{
+ public delegate void XmlNodeChangedEventHandler (Object sender,
+ XmlNodeChangedEventArgs e);
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlNodeList.cs b/mcs/class/System.XML/System.Xml/XmlNodeList.cs
new file mode 100644
index 00000000000..eff56279b55
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlNodeList.cs
@@ -0,0 +1,42 @@
+//
+// System.Xml.XmlNodeList
+//
+// Author:
+// Kral Ferch <kral_ferch@hotmail.com>
+//
+// (C) 2002 Kral Ferch
+//
+
+using System;
+using System.Collections;
+
+namespace System.Xml
+{
+ public abstract class XmlNodeList : IEnumerable
+ {
+ #region Constructors
+
+ protected XmlNodeList() { }
+
+ #endregion
+
+ #region Properties
+
+ public abstract int Count { get; }
+
+ [System.Runtime.CompilerServices.IndexerName("ItemOf")]
+ public virtual XmlNode this [int i] {
+ get { return Item(i); }
+ }
+
+ #endregion
+
+ #region Methods
+
+ public abstract IEnumerator GetEnumerator ();
+
+ public abstract XmlNode Item (int index);
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlNodeListChildren.cs b/mcs/class/System.XML/System.Xml/XmlNodeListChildren.cs
new file mode 100644
index 00000000000..c5d62823503
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlNodeListChildren.cs
@@ -0,0 +1,146 @@
+//
+// System.Xml.XmlNodeList
+//
+// Author:
+// Kral Ferch <kral_ferch@hotmail.com>
+//
+// (C) 2002 Kral Ferch
+//
+
+using System;
+using System.Collections;
+
+namespace System.Xml
+{
+ internal class XmlNodeListChildren : XmlNodeList
+ {
+ #region Enumerator
+
+ private class Enumerator : IEnumerator
+ {
+ XmlNode parent;
+ XmlLinkedNode currentChild;
+ bool passedLastNode;
+
+ internal Enumerator (XmlNode parent)
+ {
+ currentChild = null;
+ this.parent = parent;
+ passedLastNode = false;
+ }
+
+ public virtual object Current {
+ get {
+ if ((currentChild == null) ||
+ (parent.LastLinkedChild == null) ||
+ (passedLastNode == true))
+ throw new InvalidOperationException();
+
+ return currentChild;
+ }
+ }
+
+ public virtual bool MoveNext()
+ {
+ bool movedNext = true;
+
+ if (parent.LastLinkedChild == null) {
+ movedNext = false;
+ }
+ else if (currentChild == null) {
+ currentChild = parent.LastLinkedChild.NextLinkedSibling;
+ }
+ else {
+ if (Object.ReferenceEquals(currentChild, parent.LastLinkedChild)) {
+ movedNext = false;
+ passedLastNode = true;
+ }
+ else {
+ currentChild = currentChild.NextLinkedSibling;
+ }
+ }
+
+ return movedNext;
+ }
+
+ public virtual void Reset()
+ {
+ currentChild = null;
+ }
+ }
+
+ #endregion
+
+ #region Fields
+
+ XmlNode parent;
+
+ #endregion
+
+ #region Constructors
+ public XmlNodeListChildren(XmlNode parent)
+ {
+ this.parent = parent;
+ }
+
+ #endregion
+
+ #region Properties
+
+ public override int Count {
+ get {
+ int count = 0;
+
+ if (parent.LastLinkedChild != null) {
+ XmlLinkedNode currentChild = parent.LastLinkedChild.NextLinkedSibling;
+
+ count = 1;
+ while (!Object.ReferenceEquals(currentChild, parent.LastLinkedChild)) {
+ currentChild = currentChild.NextLinkedSibling;
+ count++;
+ }
+ }
+
+ return count;
+ }
+ }
+
+ #endregion
+
+ #region Methods
+
+ public override IEnumerator GetEnumerator ()
+ {
+ return new Enumerator(parent);
+ }
+
+ public override XmlNode Item (int index)
+ {
+ XmlNode requestedNode = null;
+
+ // Instead of checking for && index < Count which has to walk
+ // the whole list to get a count, we'll just keep a count since
+ // we have to walk the list anyways to get to index.
+ if ((index >= 0) && (parent.LastLinkedChild != null)) {
+ XmlLinkedNode currentChild = parent.LastLinkedChild.NextLinkedSibling;
+ int count = 0;
+
+ while ((count < index) && !Object.ReferenceEquals(currentChild, parent.LastLinkedChild))
+ {
+ currentChild = currentChild.NextLinkedSibling;
+ count++;
+ }
+
+ if (count == index) {
+ requestedNode = currentChild;
+ }
+ }
+
+ return requestedNode;
+ }
+
+ #endregion
+ }
+
+
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlNodeOrder.cs b/mcs/class/System.XML/System.Xml/XmlNodeOrder.cs
new file mode 100755
index 00000000000..9550967bbe6
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlNodeOrder.cs
@@ -0,0 +1,19 @@
+//
+// System.Xml.XmlNodeOrder.cs
+//
+// Author: Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+namespace System.Xml
+{
+ [Serializable]
+ public enum XmlNodeOrder
+ {
+ Before = 0,
+ After = 1,
+ Same = 2,
+ Unknown = 3,
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlNodeReader.cs b/mcs/class/System.XML/System.Xml/XmlNodeReader.cs
new file mode 100755
index 00000000000..bb4636947bc
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlNodeReader.cs
@@ -0,0 +1,420 @@
+//
+// System.Xml.XmlNodeReader.cs
+//
+// Author:
+// Duncan Mak (duncan@ximian.com)
+// Atsushi Enomoto (ginga@kit.hi-ho.ne.jp)
+//
+// (C) Ximian, Inc.
+// (C) Atsushi Enomoto
+//
+
+using System;
+using System.Collections;
+using System.Xml;
+using System.Text;
+
+namespace System.Xml
+{
+ public class XmlNodeReader : XmlReader
+ {
+ #region Constructor
+
+ XmlNode current;
+ ReadState state = ReadState.Initial;
+ int depth;
+ bool isEndElement;
+ bool isEndEntity;
+ bool nextIsEndElement;
+ bool alreadyRead;
+
+ public XmlNodeReader (XmlNode node)
+ {
+ current = node;
+ if (node.NodeType != XmlNodeType.Document
+ && node.NodeType != XmlNodeType.DocumentFragment)
+ alreadyRead = true;
+ }
+
+ #endregion
+
+ #region Properties
+
+ public override int AttributeCount {
+ get {
+ return ((ICollection) current.Attributes).Count;
+ }
+ }
+
+ public override string BaseURI {
+ get { return current.BaseURI; }
+ }
+
+ public override bool CanResolveEntity {
+ get { return false; }
+ }
+
+ public override int Depth {
+ get { return depth; }
+ }
+
+ public override bool EOF {
+ get { return this.ReadState == ReadState.EndOfFile; }
+ }
+
+ public override bool HasAttributes {
+ get {
+ if (current.Attributes == null)
+ return false;
+ else
+ return true;
+ }
+ }
+
+ public override bool HasValue {
+ get {
+ if (current.NodeType == XmlNodeType.Element ||
+ current.NodeType == XmlNodeType.EntityReference ||
+ current.NodeType == XmlNodeType.Document ||
+ current.NodeType == XmlNodeType.DocumentFragment ||
+ current.NodeType == XmlNodeType.Notation ||
+ current.NodeType == XmlNodeType.EndElement ||
+ current.NodeType == XmlNodeType.EndEntity)
+ return false;
+ else
+ return true;
+ }
+
+ }
+
+ [MonoTODO("waiting for DTD implementation")]
+ public override bool IsDefault {
+ get {
+ if (current.NodeType != XmlNodeType.Attribute)
+ return false;
+ else
+ {
+ return ((XmlAttribute) current).isDefault;
+ }
+ }
+ }
+
+ [MonoTODO("test it.")]
+ public override bool IsEmptyElement {
+ get {
+ if(current.NodeType == XmlNodeType.Element)
+ return ((XmlElement) current).IsEmpty;
+ else
+ return false;
+ }
+ }
+
+ public override string this [int i] {
+ get {
+ if (i < 0 || i > AttributeCount)
+ throw new ArgumentOutOfRangeException ("i is out of range.");
+
+ return current.Attributes [i].Value;
+ }
+ }
+
+ public override string this [string name] {
+ get {
+ string ret = current.Attributes [name].Value;
+
+ if (ret == null)
+ return String.Empty;
+ else
+ return ret;
+ }
+ }
+
+ public override string this [string name, string namespaceURI] {
+ get {
+ string ret = current.Attributes [name].Value;
+
+ if (ret == null)
+ return String.Empty;
+ else
+ return ret;
+ }
+ }
+
+ public override string LocalName {
+ get {
+ if (current is XmlCharacterData)
+ return String.Empty;
+ else
+ return current.LocalName;
+ }
+ }
+
+ public override string Name {
+ get { return current.Name; }
+ }
+
+ public override string NamespaceURI {
+ get {
+ return current.NamespaceURI;
+ }
+ }
+
+ public override XmlNameTable NameTable {
+ get {
+ XmlDocument doc =
+ current.NodeType == XmlNodeType.Document ?
+ current as XmlDocument : current.OwnerDocument;
+ return doc.NameTable;
+ }
+ }
+
+ public override XmlNodeType NodeType {
+ get {
+ return isEndElement ? XmlNodeType.EndElement : current.NodeType;
+ }
+ }
+
+ public override string Prefix {
+ get {
+ return current.Prefix;
+ }
+ }
+
+ public override char QuoteChar {
+ get { return '"'; }
+ }
+
+ public override ReadState ReadState {
+ get { return state; }
+ }
+
+ public override string Value {
+ get {
+ return HasValue ? current.Value : String.Empty;
+ }
+ }
+
+ public override string XmlLang {
+ get { return current.XmlLang; }
+ }
+
+ public override XmlSpace XmlSpace {
+ get { return current.XmlSpace; }
+ }
+ #endregion
+
+ #region Methods
+
+ public override void Close ()
+ {
+ current = null;
+ state = ReadState.Closed;
+ }
+
+ public override string GetAttribute (int attributeIndex)
+ {
+ return this [attributeIndex];
+ }
+
+ public override string GetAttribute (string name)
+ {
+ return this [name];
+ }
+
+ public override string GetAttribute (string name, string namespaceURI)
+ {
+ return this [name, namespaceURI];
+ }
+
+ // FIXME: Its performance is not good.
+ public override string LookupNamespace (string prefix)
+ {
+ XmlNamespaceManager nsmgr = current.ConstructNamespaceManager();
+ return nsmgr.LookupNamespace (prefix);
+ }
+
+ public override void MoveToAttribute (int attributeIndex)
+ {
+ if (attributeIndex < 0 || attributeIndex > AttributeCount)
+ throw new ArgumentOutOfRangeException ();
+
+ state = ReadState.Interactive;
+ current = current.Attributes [attributeIndex];
+ }
+
+ public override bool MoveToAttribute (string name)
+ {
+ if (GetAttribute (name) == null)
+ return false;
+ else
+ return true;
+ }
+
+ public override bool MoveToAttribute (string name, string namespaceURI)
+ {
+ if (GetAttribute (name, namespaceURI) == null)
+ return false;
+ else
+ return true;
+ }
+
+ public override bool MoveToElement ()
+ {
+ if (current.NodeType == XmlNodeType.Attribute) {
+ current = ((XmlAttribute) current).OwnerElement;
+ return true;
+ } else
+ return false;
+ }
+
+ public override bool MoveToFirstAttribute ()
+ {
+ if(current.Attributes.Count > 0)
+ {
+ current = current.Attributes [0];
+ return true;
+ }
+ else
+ return false;
+ }
+
+ public override bool MoveToNextAttribute ()
+ {
+ if (current.NodeType != XmlNodeType.Attribute)
+ return MoveToFirstAttribute ();
+ else
+ {
+ XmlAttributeCollection ac = ((XmlAttribute) current).OwnerElement.Attributes;
+ for (int i=0; i<ac.Count-1; i++)
+ {
+ XmlAttribute attr = ac [i];
+ if (attr == current)
+ {
+ current = ac [i+1];
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
+ [MonoTODO("Entity handling is not supported.")]
+ public override bool Read ()
+ {
+ state = ReadState.Interactive;
+
+ isEndEntity = false;
+
+ if (current.NodeType == XmlNodeType.Attribute)
+ current = ((XmlAttribute) current).OwnerElement;
+
+ if (nextIsEndElement) {
+ nextIsEndElement = false;
+ isEndElement = true;
+ } else if (alreadyRead) {
+ alreadyRead = false;
+ return current != null;
+ }
+
+ if (!isEndElement && current.FirstChild != null) {
+ isEndElement = false;
+ current = current.FirstChild;
+ depth++;
+ } else if (depth == 0) {
+ state = ReadState.EndOfFile;
+ return false;
+ } else if (current.NextSibling != null) {
+ isEndElement = false;
+ current = current.NextSibling;
+ } else {
+ isEndElement = true;
+ depth--;
+ current = current.ParentNode;
+ }
+ return current != null;
+ }
+
+ public override bool ReadAttributeValue ()
+ {
+ if (current is XmlAttribute) {
+ current = current.FirstChild;
+ return current != null;
+ } else if (current.ParentNode.NodeType == XmlNodeType.Attribute) {
+ current = current.NextSibling;
+ return current != null;
+ } else
+ return false;
+ }
+
+ [MonoTODO("Need to move to next content.")]
+ // Its traversal behavior is almost same as Read().
+ public override string ReadInnerXml ()
+ {
+ if (current.NodeType != XmlNodeType.Attribute &&
+ current.NodeType != XmlNodeType.Element)
+ return String.Empty;
+ else
+ return current.InnerXml;
+ }
+
+ [MonoTODO("Need to move to next content.")]
+ // Its traversal behavior is almost same as Read().
+ public override string ReadOuterXml ()
+ {
+ if (current.NodeType != XmlNodeType.Attribute &&
+ current.NodeType != XmlNodeType.Element)
+ return String.Empty;
+ else
+ return current.OuterXml;
+ }
+
+ [MonoTODO("test it.")]
+ public override string ReadString ()
+ {
+ XmlNode original = current;
+ StringBuilder builder = new StringBuilder();
+ foreach (XmlNode child in current.ChildNodes)
+ {
+ if (child is XmlCharacterData)
+ builder.Append (child.Value);
+ else {
+ depth++;
+ current = child;
+ break;
+ }
+ }
+ alreadyRead = true;
+ if (current == original)
+ nextIsEndElement = true;
+ return builder.ToString ();
+ }
+
+ [MonoTODO]
+ public override void ResolveEntity ()
+ {
+ if (current.NodeType != XmlNodeType.EntityReference)
+ throw new InvalidOperationException ("The current node is not an Entity Reference");
+ }
+
+ [MonoTODO("test it.")]
+ public override void Skip ()
+ {
+ if (current.NodeType == XmlNodeType.Attribute)
+ current = ((XmlAttribute) current).OwnerElement.NextSibling;
+ else
+ {
+ if(current.ChildNodes.Count > 0) {
+ current = current.FirstChild;
+ depth++;
+ } else if (current.NextSibling != null) {
+ current = current.NextSibling;
+ } else if (current.NodeType == XmlNodeType.Attribute) {
+ current = current.ParentNode;
+ } else {
+ depth--;
+ }
+ }
+ }
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlNodeType.cs b/mcs/class/System.XML/System.Xml/XmlNodeType.cs
new file mode 100644
index 00000000000..8ed73dd8db6
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlNodeType.cs
@@ -0,0 +1,93 @@
+// XmlNodeType.cs
+//
+// This code was automatically generated from
+// ECMA CLI XML Library Specification.
+// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
+// Created: Wed, 5 Sep 2001 06:31:46 UTC
+// Source file: AllTypes.xml
+// URL: http://msdn.microsoft.com/net/ecma/AllTypes.xml
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+
+
+namespace System.Xml {
+
+
+ /// <summary>
+ /// </summary>
+ public enum XmlNodeType {
+
+ /// <summary>
+ /// </summary>
+ None = 0,
+
+ /// <summary>
+ /// </summary>
+ Element = 1,
+
+ /// <summary>
+ /// </summary>
+ Attribute = 2,
+
+ /// <summary>
+ /// </summary>
+ Text = 3,
+
+ /// <summary>
+ /// </summary>
+ CDATA = 4,
+
+ /// <summary>
+ /// </summary>
+ EntityReference = 5,
+
+ /// <summary>
+ /// </summary>
+ Entity = 6,
+
+ /// <summary>
+ /// </summary>
+ ProcessingInstruction = 7,
+
+ /// <summary>
+ /// </summary>
+ Comment = 8,
+
+ /// <summary>
+ /// </summary>
+ Document = 9,
+
+ /// <summary>
+ /// </summary>
+ DocumentType = 10,
+
+ /// <summary>
+ /// </summary>
+ DocumentFragment = 11,
+
+ /// <summary>
+ /// </summary>
+ Notation = 12,
+
+ /// <summary>
+ /// </summary>
+ Whitespace = 13,
+
+ /// <summary>
+ /// </summary>
+ SignificantWhitespace = 14,
+
+ /// <summary>
+ /// </summary>
+ EndElement = 15,
+
+ /// <summary>
+ /// </summary>
+ EndEntity = 16,
+
+ /// <summary>
+ /// </summary>
+ XmlDeclaration = 17,
+ } // XmlNodeType
+
+} // System.Xml
diff --git a/mcs/class/System.XML/System.Xml/XmlNotation.cs b/mcs/class/System.XML/System.Xml/XmlNotation.cs
new file mode 100755
index 00000000000..7a8ddbd91c8
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlNotation.cs
@@ -0,0 +1,100 @@
+//
+// System.Xml.XmlNotation.cs
+//
+// Author:
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+using System;
+using System.Xml;
+
+namespace System.Xml
+{
+ public class XmlNotation : XmlNode
+ {
+ #region Fields
+
+ string localName;
+ string publicId;
+ string systemId;
+ string prefix;
+
+ #endregion
+
+ #region Constructor
+
+ internal XmlNotation (string localName, string prefix, string publicId,
+ string systemId, XmlDocument doc)
+ : base (doc)
+ {
+ this.localName = localName;
+ this.prefix = prefix;
+ this.publicId = publicId;
+ this.systemId = systemId;
+ }
+
+ #endregion
+
+ #region Properties
+
+ public override string InnerXml {
+ get { return String.Empty; }
+ set { throw new InvalidOperationException ("This operation is not allowed."); }
+ }
+
+ public override bool IsReadOnly {
+ get { return true; } // Notation nodes are always read-only
+ }
+
+ public override string LocalName {
+ get { return localName; }
+ }
+
+ public override string Name {
+ get { return prefix + ":" + localName; }
+ }
+
+ public override XmlNodeType NodeType {
+ get { return XmlNodeType.Notation; }
+ }
+
+ public override string OuterXml {
+ get { return String.Empty; }
+ }
+
+ public string PublicId {
+ get {
+ if (publicId != null)
+ return publicId;
+ else
+ return null;
+ }
+ }
+
+ public string SystemId {
+ get {
+ if (systemId != null)
+ return systemId;
+ else
+ return null;
+ }
+ }
+
+ #endregion
+
+ #region Methods
+
+ public override XmlNode CloneNode (bool deep)
+ {
+ throw new InvalidOperationException ("This operation is not allowed.");
+ }
+
+ public override void WriteContentTo (XmlWriter w) { } // has no effect.
+
+ public override void WriteTo (XmlWriter w) { } // has no effect.
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlParserContext.cs b/mcs/class/System.XML/System.Xml/XmlParserContext.cs
new file mode 100644
index 00000000000..58c5536a6d1
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlParserContext.cs
@@ -0,0 +1,186 @@
+//
+// System.Xml.XmlParserContext
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2001, 2002 Jason Diamond http://injektilo.org/
+//
+
+using System.Text;
+
+namespace System.Xml
+{
+ public class XmlParserContext
+ {
+ #region Constructors
+
+ public XmlParserContext (
+ XmlNameTable nt,
+ XmlNamespaceManager nsMgr,
+ string xmlLang,
+ XmlSpace xmlSpace) :
+
+ this (
+ nt,
+ nsMgr,
+ null,
+ null,
+ null,
+ null,
+ null,
+ xmlLang,
+ xmlSpace,
+ null
+ )
+ {
+ }
+
+ public XmlParserContext (
+ XmlNameTable nt,
+ XmlNamespaceManager nsMgr,
+ string xmlLang,
+ XmlSpace xmlSpace,
+ Encoding enc) :
+
+ this (
+ nt,
+ nsMgr,
+ null,
+ null,
+ null,
+ null,
+ null,
+ xmlLang,
+ xmlSpace,
+ enc
+ )
+ {
+ }
+
+ public XmlParserContext (
+ XmlNameTable nt,
+ XmlNamespaceManager nsMgr,
+ string docTypeName,
+ string pubId,
+ string sysId,
+ string internalSubset,
+ string baseURI,
+ string xmlLang,
+ XmlSpace xmlSpace) :
+
+ this (
+ nt,
+ nsMgr,
+ null,
+ null,
+ null,
+ null,
+ null,
+ xmlLang,
+ xmlSpace,
+ null
+ )
+ {
+ }
+
+ public XmlParserContext (
+ XmlNameTable nt,
+ XmlNamespaceManager nsMgr,
+ string docTypeName,
+ string pubId,
+ string sysId,
+ string internalSubset,
+ string baseURI,
+ string xmlLang,
+ XmlSpace xmlSpace,
+ Encoding enc)
+ {
+ if (nt == null)
+ this.nameTable = nsMgr.NameTable;
+ else
+ this.NameTable = nt;
+
+ this.namespaceManager = nsMgr;
+ this.docTypeName = docTypeName;
+ this.publicID = pubId;
+ this.systemID = sysId;
+ this.internalSubset = internalSubset;
+ this.baseURI = baseURI;
+ this.xmlLang = xmlLang;
+ this.xmlSpace = xmlSpace;
+ this.encoding = enc;
+ }
+
+ #endregion
+
+ #region Fields
+
+ private string baseURI;
+ private string docTypeName;
+ private Encoding encoding;
+ private string internalSubset;
+ private XmlNamespaceManager namespaceManager;
+ private XmlNameTable nameTable;
+ private string publicID;
+ private string systemID;
+ private string xmlLang;
+ private XmlSpace xmlSpace;
+
+ #endregion
+
+ #region Properties
+
+ public string BaseURI {
+ get { return baseURI; }
+ set { baseURI = value; }
+ }
+
+ public string DocTypeName {
+ get { return docTypeName; }
+ set { docTypeName = value; }
+ }
+
+ public Encoding Encoding {
+ get { return encoding; }
+ set { encoding = value; }
+ }
+
+ public string InternalSubset {
+ get { return internalSubset; }
+ set { internalSubset = value; }
+ }
+
+ public XmlNamespaceManager NamespaceManager {
+ get { return namespaceManager; }
+ set { namespaceManager = value; }
+ }
+
+ public XmlNameTable NameTable {
+ get { return nameTable; }
+ set { nameTable = value; }
+ }
+
+ public string PublicId {
+ get { return publicID; }
+ set { publicID = value; }
+ }
+
+ public string SystemId {
+ get { return systemID; }
+ set { systemID = value; }
+ }
+
+ public string XmlLang {
+ get { return xmlLang; }
+ set { xmlLang = value; }
+ }
+
+ public XmlSpace XmlSpace {
+ get { return xmlSpace; }
+ set { xmlSpace = value; }
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlProcessingInstruction.cs b/mcs/class/System.XML/System.Xml/XmlProcessingInstruction.cs
new file mode 100644
index 00000000000..089c1896542
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlProcessingInstruction.cs
@@ -0,0 +1,103 @@
+//
+// System.Xml.XmlProcessingInstruction
+//
+// Author:
+// Kral Ferch <kral_ferch@hotmail.com>
+//
+// (C) 2002 Kral Ferch
+//
+
+using System;
+using System.Xml.XPath;
+
+namespace System.Xml
+{
+ public class XmlProcessingInstruction : XmlLinkedNode
+ {
+ string target;
+ string data;
+
+ #region Constructors
+
+ protected internal XmlProcessingInstruction (string target, string data, XmlDocument doc) : base(doc)
+ {
+ if (data == null)
+ data = String.Empty;
+
+ this.target = target;
+ this.data = data;
+ }
+
+ #endregion
+
+ #region Properties
+
+ public string Data
+ {
+ get { return data; }
+
+ set { data = value; }
+ }
+
+ public override string InnerText
+ {
+ get { return Data; }
+ set { data = value; }
+ }
+
+ public override string LocalName
+ {
+ get { return target; }
+ }
+
+ public override string Name
+ {
+ get { return target; }
+ }
+
+ public override XmlNodeType NodeType
+ {
+ get { return XmlNodeType.ProcessingInstruction; }
+ }
+
+ internal override XPathNodeType XPathNodeType {
+ get {
+ return XPathNodeType.ProcessingInstruction;
+ }
+ }
+
+ public string Target
+ {
+ get { return target; }
+ }
+
+ public override string Value
+ {
+ get { return data; }
+ set {
+ if (this.IsReadOnly)
+ throw new ArgumentException ("This node is read-only.");
+ else
+ data = value;
+ }
+ }
+
+ #endregion
+
+ #region Methods
+
+ public override XmlNode CloneNode (bool deep)
+ {
+ return new XmlProcessingInstruction (target, data, OwnerDocument);
+ }
+
+ public override void WriteContentTo (XmlWriter w) { }
+
+ public override void WriteTo (XmlWriter w)
+ {
+ w.WriteProcessingInstruction (target, data);
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlQualifiedName.cs b/mcs/class/System.XML/System.Xml/XmlQualifiedName.cs
new file mode 100644
index 00000000000..d2d5f632567
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlQualifiedName.cs
@@ -0,0 +1,116 @@
+//
+// System.Xml.XmlQualifiedName.cs
+//
+// Author: Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+// Modified:
+// 21st June 2002 : Ajay kumar Dwivedi (adwiv@yahoo.com)
+
+using System;
+
+namespace System.Xml
+{
+ public class XmlQualifiedName
+ {
+ // Constructors
+ public XmlQualifiedName ()
+ : this (string.Empty, string.Empty)
+ {
+ }
+
+ public XmlQualifiedName (string name)
+ : this (name, string.Empty)
+ {
+ }
+
+ public XmlQualifiedName (string name, string ns)
+ : base ()
+ {
+ this.name = name;
+ this.ns = ns;
+ }
+
+ // Fields
+ public static readonly XmlQualifiedName Empty = new XmlQualifiedName ();
+ private string name;
+ private string ns;
+
+ // Properties
+ public bool IsEmpty
+ {
+ get {
+ if ((name == String.Empty) && (ns == String.Empty))
+ return true;
+ else
+ return false;
+ }
+ }
+
+ public string Name
+ {
+ get { return name; }
+ }
+
+ public string Namespace
+ {
+ get { return ns; }
+ }
+
+ // Methods
+ public override bool Equals (object other)
+ {
+ if(!(other is XmlQualifiedName))
+ return false;
+
+ if ((XmlQualifiedName) this == (XmlQualifiedName) other)
+ return true;
+ else
+ return false;
+ }
+
+ public override int GetHashCode ()
+ {
+ return unchecked (name.GetHashCode() + ns.GetHashCode());
+ }
+
+ public override string ToString ()
+ {
+ if (ns == null)
+ return name;
+ else if (ns == string.Empty)
+ return name;
+ else
+ return ns + ":" + name;
+ }
+
+ public static string ToString (string name, string ns)
+ {
+ if (ns == string.Empty)
+ return name;
+ else
+ return ns + ":" + name;
+ }
+
+ // Operators
+ public static bool operator == (XmlQualifiedName a, XmlQualifiedName b)
+ {
+ if((Object)a == null || (Object)b == null)
+ return false;
+
+ if ((a.Name == b.Name) && (a.Namespace == b.Namespace))
+ return true;
+ else
+ return false;
+ }
+
+ public static bool operator != (XmlQualifiedName a, XmlQualifiedName b)
+ {
+ if (a == b)
+ return false;
+ else
+ return true;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlReader.cs b/mcs/class/System.XML/System.Xml/XmlReader.cs
new file mode 100644
index 00000000000..6e4d243b2f6
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlReader.cs
@@ -0,0 +1,374 @@
+//
+// XmlReader.cs
+//
+// Authors:
+// Jason Diamond (jason@injektilo.org)
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2001, 2002 Jason Diamond http://injektilo.org/
+// (c) 2002 Ximian, Inc. (http://www.ximian.com)
+//
+
+namespace System.Xml
+{
+ public abstract class XmlReader
+ {
+ #region Constructor
+
+ protected XmlReader ()
+ {
+ }
+
+ #endregion
+
+ #region Properties
+
+ public abstract int AttributeCount { get; }
+
+ public abstract string BaseURI { get; }
+
+ public virtual bool CanResolveEntity
+ {
+ get { return false; }
+ }
+
+ public abstract int Depth { get; }
+
+ public abstract bool EOF { get; }
+
+ public virtual bool HasAttributes
+ {
+ get { return AttributeCount > 0; }
+ }
+
+ public abstract bool HasValue { get; }
+
+ public abstract bool IsDefault { get; }
+
+ public abstract bool IsEmptyElement { get; }
+
+ public abstract string this[int i] { get; }
+
+ public abstract string this[string name] { get; }
+
+ public abstract string this[
+ string localName,
+ string namespaceName]
+ { get; }
+
+ public abstract string LocalName { get; }
+
+ public abstract string Name { get; }
+
+ public abstract string NamespaceURI { get; }
+
+ public abstract XmlNameTable NameTable { get; }
+
+ public abstract XmlNodeType NodeType { get; }
+
+ public abstract string Prefix { get; }
+
+ public abstract char QuoteChar { get; }
+
+ public abstract ReadState ReadState { get; }
+
+ public abstract string Value { get; }
+
+ public abstract string XmlLang { get; }
+
+ public abstract XmlSpace XmlSpace { get; }
+
+ #endregion
+
+ #region Methods
+
+ public abstract void Close ();
+
+ public abstract string GetAttribute (int i);
+
+ public abstract string GetAttribute (string name);
+
+ public abstract string GetAttribute (
+ string localName,
+ string namespaceName);
+
+ public static bool IsName (string s)
+ {
+ bool result = false;
+
+ if (s != null && s.Length > 0) {
+ char[] chars = s.ToCharArray ();
+
+ if (XmlChar.IsFirstNameChar (chars[0])) {
+ int i = 1;
+ int n = chars.Length;
+
+ while (i < n && XmlChar.IsNameChar (chars[i]))
+ ++i;
+
+ result = i == n;
+ }
+ }
+
+ return result;
+ }
+
+ public static bool IsNameToken (string s)
+ {
+ bool result = false;
+
+ if (s != null && s.Length > 0) {
+ char[] chars = s.ToCharArray ();
+
+ int i = 0;
+ int n = chars.Length;
+
+ while (i < n && XmlChar.IsNameChar (chars[i]))
+ ++i;
+
+ result = i == n;
+ }
+
+ return result;
+ }
+
+ public virtual bool IsStartElement ()
+ {
+ return (MoveToContent () == XmlNodeType.Element);
+ }
+
+ public virtual bool IsStartElement (string name)
+ {
+ if (!IsStartElement ())
+ return false;
+
+ return (Name == name);
+ }
+
+ public virtual bool IsStartElement (string localName, string namespaceName)
+ {
+ if (!IsStartElement ())
+ return false;
+
+ return (LocalName == localName && NamespaceURI == namespaceName);
+ }
+
+ public abstract string LookupNamespace (string prefix);
+
+ public abstract void MoveToAttribute (int i);
+
+ public abstract bool MoveToAttribute (string name);
+
+ public abstract bool MoveToAttribute (
+ string localName,
+ string namespaceName);
+
+ private bool IsContent (XmlNodeType nodeType)
+ {
+ /* MS doc says:
+ * (non-white space text, CDATA, Element, EndElement, EntityReference, or EndEntity)
+ */
+ switch (nodeType) {
+ case XmlNodeType.Text:
+ return true;
+ case XmlNodeType.CDATA:
+ return true;
+ case XmlNodeType.Element:
+ return true;
+ case XmlNodeType.EndElement:
+ return true;
+ case XmlNodeType.EntityReference:
+ return true;
+ case XmlNodeType.EndEntity:
+ return true;
+ }
+
+ return false;
+ }
+
+ public virtual XmlNodeType MoveToContent ()
+ {
+ do {
+ XmlNodeType nodeType = NodeType;
+ if (IsContent (nodeType))
+ return nodeType;
+ } while (Read ());
+
+ return XmlNodeType.None;
+ }
+
+ public abstract bool MoveToElement ();
+
+ public abstract bool MoveToFirstAttribute ();
+
+ public abstract bool MoveToNextAttribute ();
+
+ public abstract bool Read ();
+
+ public abstract bool ReadAttributeValue ();
+
+ public virtual string ReadElementString ()
+ {
+ if (MoveToContent () != XmlNodeType.Element) {
+ string error = String.Format ("'{0}' is an invalid node type.",
+ NodeType.ToString ());
+ throw new XmlException (this as IXmlLineInfo, error);
+ }
+
+ string result = String.Empty;
+ if (!IsEmptyElement) {
+ Read ();
+ result = ReadString ();
+ if (NodeType != XmlNodeType.EndElement) {
+ string error = String.Format ("'{0}' is an invalid node type.",
+ NodeType.ToString ());
+ throw new XmlException (this as IXmlLineInfo, error);
+ }
+ }
+
+ Read ();
+ return result;
+ }
+
+ public virtual string ReadElementString (string name)
+ {
+ if (MoveToContent () != XmlNodeType.Element) {
+ string error = String.Format ("'{0}' is an invalid node type.",
+ NodeType.ToString ());
+ throw new XmlException (this as IXmlLineInfo, error);
+ }
+
+ if (name != Name) {
+ string error = String.Format ("The {0} tag from namespace {1} is expected.",
+ Name, NamespaceURI);
+ throw new XmlException (this as IXmlLineInfo, error);
+ }
+
+ string result = String.Empty;
+ if (!IsEmptyElement) {
+ Read ();
+ result = ReadString ();
+ if (NodeType != XmlNodeType.EndElement) {
+ string error = String.Format ("'{0}' is an invalid node type.",
+ NodeType.ToString ());
+ throw new XmlException (this as IXmlLineInfo, error);
+ }
+ }
+
+ Read ();
+ return result;
+ }
+
+ public virtual string ReadElementString (string localName, string namespaceName)
+ {
+ if (MoveToContent () != XmlNodeType.Element) {
+ string error = String.Format ("'{0}' is an invalid node type.",
+ NodeType.ToString ());
+ throw new XmlException (this as IXmlLineInfo, error);
+ }
+
+ if (localName != LocalName || NamespaceURI != namespaceName) {
+ string error = String.Format ("The {0} tag from namespace {1} is expected.",
+ LocalName, NamespaceURI);
+ throw new XmlException (this as IXmlLineInfo, error);
+ }
+
+ string result = String.Empty;
+ if (!IsEmptyElement) {
+ Read ();
+ result = ReadString ();
+ if (NodeType != XmlNodeType.EndElement) {
+ string error = String.Format ("'{0}' is an invalid node type.",
+ NodeType.ToString ());
+ throw new XmlException (this as IXmlLineInfo, error);
+ }
+ }
+
+ Read ();
+ return result;
+ }
+
+ public virtual void ReadEndElement ()
+ {
+ if (MoveToContent () != XmlNodeType.EndElement) {
+ string error = String.Format ("'{0}' is an invalid node type.",
+ NodeType.ToString ());
+ throw new XmlException (this as IXmlLineInfo, error);
+ }
+
+ Read ();
+ }
+
+ public abstract string ReadInnerXml ();
+
+ public abstract string ReadOuterXml ();
+
+ public virtual void ReadStartElement ()
+ {
+ if (MoveToContent () != XmlNodeType.Element) {
+ string error = String.Format ("'{0}' is an invalid node type.",
+ NodeType.ToString ());
+ throw new XmlException (this as IXmlLineInfo, error);
+ }
+
+ Read ();
+ }
+
+ public virtual void ReadStartElement (string name)
+ {
+ if (MoveToContent () != XmlNodeType.Element) {
+ string error = String.Format ("'{0}' is an invalid node type.",
+ NodeType.ToString ());
+ throw new XmlException (this as IXmlLineInfo, error);
+ }
+
+ if (name != Name) {
+ string error = String.Format ("The {0} tag from namespace {1} is expected.",
+ Name, NamespaceURI);
+ throw new XmlException (this as IXmlLineInfo, error);
+ }
+
+ Read ();
+ }
+
+ public virtual void ReadStartElement (string localName, string namespaceName)
+ {
+ if (MoveToContent () != XmlNodeType.Element) {
+ string error = String.Format ("'{0}' is an invalid node type.",
+ NodeType.ToString ());
+ throw new XmlException (this as IXmlLineInfo, error);
+ }
+
+ if (localName != LocalName || NamespaceURI != namespaceName) {
+ string error = String.Format ("The {0} tag from namespace {1} is expected.",
+ LocalName, NamespaceURI);
+ throw new XmlException (this as IXmlLineInfo, error);
+ }
+
+ Read ();
+ }
+
+ public abstract string ReadString ();
+
+ public abstract void ResolveEntity ();
+
+ public virtual void Skip ()
+ {
+ if (ReadState != ReadState.Interactive)
+ return;
+
+ MoveToElement ();
+ if (NodeType != XmlNodeType.Element || IsEmptyElement) {
+ Read ();
+ return;
+ }
+
+ int depth = Depth;
+ while (Read() && depth < Depth);
+ if (NodeType == XmlNodeType.EndElement)
+ Read ();
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlResolver.cs b/mcs/class/System.XML/System.Xml/XmlResolver.cs
new file mode 100644
index 00000000000..665dff630e6
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlResolver.cs
@@ -0,0 +1,32 @@
+// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// System.Xml.XmlResolver.cs
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2001 Jason Diamond http://injektilo.org/
+//
+
+using System;
+using System.Net;
+
+namespace System.Xml
+{
+ public abstract class XmlResolver
+ {
+ public abstract ICredentials Credentials
+ {
+ set;
+ }
+
+ public abstract object GetEntity(
+ Uri absoluteUri,
+ string role,
+ Type type);
+
+ public abstract Uri ResolveUri(
+ Uri baseUri,
+ string relativeUri);
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlSignificantWhitespace.cs b/mcs/class/System.XML/System.Xml/XmlSignificantWhitespace.cs
new file mode 100644
index 00000000000..1df1a7f512b
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlSignificantWhitespace.cs
@@ -0,0 +1,72 @@
+//
+// System.Xml.XmlSignificantWhitespace.cs
+//
+// Author:
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+using System.Xml.XPath;
+
+namespace System.Xml
+{
+ public class XmlSignificantWhitespace : XmlCharacterData
+ {
+ // Constructor
+ protected internal XmlSignificantWhitespace (string strData, XmlDocument doc)
+ : base (strData, doc)
+ {
+ }
+
+ // Properties
+ public override string LocalName {
+ get { return "#significant-whitespace"; }
+ }
+
+ public override string Name {
+ get { return "#significant-whitespace"; }
+ }
+
+ public override XmlNodeType NodeType {
+ get { return XmlNodeType.SignificantWhitespace; }
+ }
+
+ internal override XPathNodeType XPathNodeType {
+ get {
+ return XPathNodeType.SignificantWhitespace;
+ }
+ }
+
+ public override string Value {
+ get { return Data; }
+ set {
+ if (IsValidWhitespaceChar (value) == false)
+ throw new ArgumentException ("Invalid whitespace characters.");
+ base.Data = value;
+ }
+ }
+
+ // Methods
+ public override XmlNode CloneNode (bool deep)
+ {
+ return new XmlSignificantWhitespace (Data, OwnerDocument);
+ }
+
+ public override void WriteContentTo (XmlWriter w) {}
+
+ public override void WriteTo (XmlWriter w)
+ {
+ w.WriteWhitespace (Data);
+ }
+
+ private bool IsValidWhitespaceChar (string text)
+ {
+ foreach (char c in text)
+ if ((c != ' ') && (c != '\r') && (c != '\n') && (c != '\t'))
+ return false;
+ return true;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlSpace.cs b/mcs/class/System.XML/System.Xml/XmlSpace.cs
new file mode 100644
index 00000000000..f1e1128ff3c
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlSpace.cs
@@ -0,0 +1,37 @@
+// XmlSpace.cs
+//
+// This code was automatically generated from
+// ECMA CLI XML Library Specification.
+// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
+// Created: Wed, 5 Sep 2001 06:31:52 UTC
+// Source file: AllTypes.xml
+// URL: http://msdn.microsoft.com/net/ecma/AllTypes.xml
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+
+
+namespace System.Xml {
+
+
+ /// <summary>
+ /// Specifies the current xml:space scope
+ /// </summary>
+ public enum XmlSpace {
+
+ /// <summary>
+ /// No xml:space scope.
+ /// </summary>
+ None = 0,
+
+ /// <summary>
+ /// the xml:space scope = "default"
+ /// </summary>
+ Default = 1,
+
+ /// <summary>
+ /// the xml:space scope = "preserve"
+ /// </summary>
+ Preserve = 2,
+ } // XmlSpace
+
+} // System.Xml
diff --git a/mcs/class/System.XML/System.Xml/XmlText.cs b/mcs/class/System.XML/System.Xml/XmlText.cs
new file mode 100644
index 00000000000..32b0311e184
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlText.cs
@@ -0,0 +1,76 @@
+//
+// System.Xml.XmlText
+//
+// Author:
+// Jason Diamond <jason@injektilo.org>
+//
+// (C) 2002 Jason Diamond http://injektilo.org/
+//
+
+using System;
+using System.Xml.XPath;
+
+namespace System.Xml
+{
+ public class XmlText : XmlCharacterData
+ {
+ #region Constructor
+
+ protected internal XmlText (string strData, XmlDocument doc) : base(strData, doc)
+ {
+ }
+
+ #endregion
+
+ #region Properties
+
+ public override string LocalName
+ {
+ get { return "#text"; }
+ }
+
+ public override string Name {
+ get { return "#text"; }
+ }
+
+ public override XmlNodeType NodeType {
+ get { return XmlNodeType.Text; }
+ }
+
+ internal override XPathNodeType XPathNodeType {
+ get {
+ return XPathNodeType.Text;
+ }
+ }
+
+ public override string Value {
+ get { return Data; }
+ set { Data = value; }
+ }
+
+ #endregion
+
+ #region Methods
+
+ [MonoTODO]
+ public override XmlNode CloneNode (bool deep)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public virtual XmlText SplitText (int offset)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override void WriteContentTo (XmlWriter w) {}
+
+ public override void WriteTo (XmlWriter w)
+ {
+ w.WriteString (Data);
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlTextReader.cs b/mcs/class/System.XML/System.Xml/XmlTextReader.cs
new file mode 100644
index 00000000000..e61267f3c36
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlTextReader.cs
@@ -0,0 +1,1741 @@
+//
+// System.Xml.XmlTextReader
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+// Adam Treat (manyoso@yahoo.com)
+//
+// (C) 2001, 2002 Jason Diamond http://injektilo.org/
+//
+
+// FIXME:
+// This can only parse basic XML: elements, attributes, processing
+// instructions, and comments are OK.
+//
+// It barfs on DOCTYPE declarations.
+// => No barfing, but parsing is incomplete.
+// DTD nodes are not still created.
+//
+// There's also no checking being done for either well-formedness
+// or validity.
+//
+// NameTables aren't being used everywhere yet.
+//
+// Some thought needs to be given to performance. There's too many
+// strings being allocated.
+//
+// Some of the MoveTo methods haven't been implemented yet.
+//
+// LineNumber and LinePosition aren't being tracked.
+//
+// xml:space, xml:lang, and xml:base aren't being tracked.
+//
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Text;
+
+namespace System.Xml
+{
+ public class XmlTextReader : XmlReader, IXmlLineInfo
+ {
+ WhitespaceHandling whitespaceHandling = WhitespaceHandling.All;
+ #region Constructors
+
+ protected XmlTextReader ()
+ {
+ }
+
+ public XmlTextReader (Stream input)
+ : this (new StreamReader (input))
+ {
+ }
+
+ public XmlTextReader (string url)
+ : this(url, new NameTable ())
+ {
+ }
+
+ public XmlTextReader (TextReader input)
+ : this (input, new NameTable ())
+ {
+ }
+
+ protected XmlTextReader (XmlNameTable nt)
+ : this (String.Empty, null, XmlNodeType.None, null)
+ {
+ }
+
+ public XmlTextReader (Stream input, XmlNameTable nt)
+ : this(new StreamReader (input), nt)
+ {
+ }
+
+ public XmlTextReader (string url, Stream input)
+ : this (url, new StreamReader (input))
+ {
+ }
+
+ public XmlTextReader (string url, TextReader input)
+ : this (url, input, new NameTable ())
+ {
+ }
+
+ [MonoTODO("Non-filename-url must be supported. Waiting for WebClient")]
+ public XmlTextReader (string url, XmlNameTable nt)
+ // : this(url, new StreamReader ((Stream)new XmlUrlResolver ().GetEntity (new Uri (url), null, typeof(Stream))), nt)
+ : this (url, new StreamReader (url), nt)
+ {
+ }
+
+ public XmlTextReader (TextReader input, XmlNameTable nt)
+ : this(String.Empty, input, nt)
+ {
+ }
+
+ public XmlTextReader (Stream xmlFragment, XmlNodeType fragType, XmlParserContext context)
+ : this (String.Empty, new StreamReader (xmlFragment), fragType, context)
+ {
+ }
+
+ public XmlTextReader (string url, Stream input, XmlNameTable nt)
+ : this (url, new StreamReader (input), nt)
+ {
+ }
+
+ public XmlTextReader (string url, TextReader input, XmlNameTable nt)
+ : this (url, input, XmlNodeType.Document, new XmlParserContext (nt, new XmlNamespaceManager (nt), null, XmlSpace.None))
+ {
+ }
+
+ [MonoTODO("TODO as same as private XmlTextReader(TextReader, XmlNodeType, XmlParserContext)")]
+ public XmlTextReader (string xmlFragment, XmlNodeType fragType, XmlParserContext context)
+ : this (String.Empty, new StringReader (xmlFragment), fragType, context)
+ {
+ }
+
+ // TODO still remains as described at head of this file,
+ // but it might not be TODO of the constructors...
+ XmlTextReader (string url, TextReader fragment, XmlNodeType fragType, XmlParserContext context)
+ {
+ this.SetReaderContext(url, context);
+ this.SetReaderFragment(fragment, fragType);
+ }
+
+ #endregion
+
+ #region Properties
+
+ public override int AttributeCount
+ {
+ get { return attributes.Count; }
+ }
+
+ public override string BaseURI
+ {
+ get { return parserContext.BaseURI; }
+ }
+
+ public override int Depth
+ {
+ get {
+ return elementDepth;
+ }
+ }
+
+ public Encoding Encoding
+ {
+ get { return parserContext.Encoding; }
+ }
+
+ public override bool EOF
+ {
+ get
+ {
+ return
+ readState == ReadState.EndOfFile ||
+ readState == ReadState.Closed;
+ }
+ }
+
+ public override bool HasValue
+ {
+ get { return value != String.Empty; }
+ }
+
+ public override bool IsDefault
+ {
+ get
+ {
+ // XmlTextReader does not expand default attributes.
+ return false;
+ }
+ }
+
+ public override bool IsEmptyElement
+ {
+ get { return isEmptyElement; }
+ }
+
+ public override string this [int i]
+ {
+ get { return GetAttribute (i); }
+ }
+
+ public override string this [string name]
+ {
+ get { return GetAttribute (name); }
+ }
+
+ public override string this [string localName, string namespaceName]
+ {
+ get { return GetAttribute (localName, namespaceName); }
+ }
+
+ public int LineNumber
+ {
+ get { return line; }
+ }
+
+ public int LinePosition
+ {
+ get { return column; }
+ }
+
+ public override string LocalName
+ {
+ get { return localName; }
+ }
+
+ public override string Name
+ {
+ get { return name; }
+ }
+
+ [MonoTODO]
+ public bool Namespaces
+ {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ public override string NamespaceURI
+ {
+ get { return namespaceURI; }
+ }
+
+ public override XmlNameTable NameTable
+ {
+ get { return parserContext.NameTable; }
+ }
+
+ public override XmlNodeType NodeType
+ {
+ get { return nodeType; }
+ }
+
+ [MonoTODO]
+ public bool Normalization
+ {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ public override string Prefix
+ {
+ get { return prefix; }
+ }
+
+ [MonoTODO]
+ public override char QuoteChar
+ {
+ get { throw new NotImplementedException (); }
+ }
+
+ public override ReadState ReadState
+ {
+ get { return readState; }
+ }
+
+ public override string Value
+ {
+ get {
+ if(NodeType == XmlNodeType.Attribute)
+ return ResolveAttributeValue(value);
+ else
+ return value;
+ }
+ }
+
+ public WhitespaceHandling WhitespaceHandling
+ {
+ get { return whitespaceHandling; }
+ set { whitespaceHandling = value; }
+ }
+
+ [MonoTODO]
+ public override string XmlLang
+ {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public XmlResolver XmlResolver
+ {
+ set { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public override XmlSpace XmlSpace
+ {
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion
+
+ #region Methods
+
+ [MonoTODO]
+ public override void Close ()
+ {
+ readState = ReadState.Closed;
+ }
+
+ [MonoTODO]
+ public override string GetAttribute (int i)
+ {
+ if (i > attributes.Count)
+ throw new ArgumentOutOfRangeException ("i is smaller than AttributeCount");
+ else
+ return ResolveAttributeValue (attributes [orderedAttributes [i]] as string);
+ }
+
+ public override string GetAttribute (string name)
+ {
+ return attributes.ContainsKey (name) ?
+ ResolveAttributeValue (attributes [name] as string) : String.Empty;
+ }
+
+ public override string GetAttribute (string localName, string namespaceURI)
+ {
+ foreach (DictionaryEntry entry in attributes)
+ {
+ string thisName = entry.Key as string;
+
+ int indexOfColon = thisName.IndexOf (':');
+
+ if (indexOfColon != -1) {
+ string thisLocalName = thisName.Substring (indexOfColon + 1);
+
+ if (localName == thisLocalName) {
+ string thisPrefix = thisName.Substring (0, indexOfColon);
+ string thisNamespaceURI = LookupNamespace (thisPrefix);
+
+ if (namespaceURI == thisNamespaceURI)
+ return attributes.ContainsKey (thisName) ?
+ ResolveAttributeValue (attributes [thisName] as string) : String.Empty;
+ }
+ } else if (localName == "xmlns" && namespaceURI == "http://www.w3.org/2000/xmlns/" && thisName == "xmlns")
+ return attributes.ContainsKey (thisName) ?
+ ResolveAttributeValue (attributes [thisName] as string) : String.Empty;
+ }
+
+ return String.Empty;
+ }
+
+ [MonoTODO]
+ public TextReader GetRemainder ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ bool IXmlLineInfo.HasLineInfo ()
+ {
+ return false;
+ }
+
+ public override string LookupNamespace (string prefix)
+ {
+ return parserContext.NamespaceManager.LookupNamespace (prefix);
+ }
+
+ public override void MoveToAttribute (int i)
+ {
+ MoveToElement ();
+
+ if (attributes == null || orderedAttributes.Count < i || i < 0)
+ throw new ArgumentOutOfRangeException ("attribute index out of range.");
+
+ string name = orderedAttributes [i] as string;
+ string value = attributes [name] as string;
+ SetProperties (
+ XmlNodeType.Attribute, // nodeType
+ name, // name
+ false, // isEmptyElement
+ value, // value
+ false // clearAttributes
+ );
+ }
+
+ public override bool MoveToAttribute (string name)
+ {
+ MoveToElement ();
+ bool match = false;
+
+ if (attributes == null)
+ return false;
+
+ if (orderedAttributesEnumerator == null) {
+ SaveProperties ();
+ orderedAttributesEnumerator = orderedAttributes.GetEnumerator ();
+ }
+
+ while (orderedAttributesEnumerator.MoveNext ()) {
+ if(name == orderedAttributesEnumerator.Current as string) {
+ match = true;
+ break;
+ }
+ }
+
+ if (match) {
+ string value = attributes [name] as string;
+ SetProperties (
+ XmlNodeType.Attribute, // nodeType
+ name, // name
+ false, // isEmptyElement
+ value, // value
+ false // clearAttributes
+ );
+ }
+
+ return match;
+ }
+
+ [MonoTODO]
+ public override bool MoveToAttribute (string localName, string namespaceName)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override bool MoveToElement ()
+ {
+ if (orderedAttributesEnumerator != null) {
+ orderedAttributesEnumerator = null;
+ RestoreProperties ();
+ return true;
+ }
+
+ return false;
+ }
+
+ public override bool MoveToFirstAttribute ()
+ {
+ MoveToElement ();
+ return MoveToNextAttribute ();
+ }
+
+ public override bool MoveToNextAttribute ()
+ {
+ if (attributes == null)
+ return false;
+
+ if (orderedAttributesEnumerator == null) {
+ SaveProperties ();
+ orderedAttributesEnumerator = orderedAttributes.GetEnumerator ();
+ }
+
+ if (orderedAttributesEnumerator.MoveNext ()) {
+ string name = orderedAttributesEnumerator.Current as string;
+ string value = attributes [name] as string;
+ SetProperties (
+ XmlNodeType.Attribute, // nodeType
+ name, // name
+ false, // isEmptyElement
+ value, // value
+ false // clearAttributes
+ );
+ return true;
+ }
+
+ return false;
+ }
+
+ public override bool Read ()
+ {
+ bool more = false;
+
+ readState = ReadState.Interactive;
+
+ more = ReadContent ();
+
+ return more;
+ }
+
+ [MonoTODO("This method should consider entity references")]
+ public override bool ReadAttributeValue ()
+ {
+ // reading attribute value phase now stopped
+ if(attributeStringCurrentPosition < 0 ||
+ attributeString.Length < attributeStringCurrentPosition) {
+ attributeStringCurrentPosition = 0;
+ attributeString = String.Empty;
+ return false;
+ }
+
+ // If not started, then initialize attributeString when parsing is at start.
+ if(attributeStringCurrentPosition == 0)
+ attributeString = value;
+
+ bool returnEntity = false;
+ value = String.Empty;
+ int nextPosition = attributeString.IndexOf ('&',
+ attributeStringCurrentPosition);
+
+ // if attribute string starts from '&' then it may be (unparsable) entity reference.
+ if(nextPosition == 0) {
+ string parsed = ReadAttributeValueEntityReference ();
+ if(parsed == null) {
+ // return entity (It is only this case to return entity reference.)
+ int endEntityPosition = attributeString.IndexOf (';',
+ attributeStringCurrentPosition);
+ SetProperties (XmlNodeType.EntityReference,
+ attributeString.Substring (attributeStringCurrentPosition + 1,
+ endEntityPosition - attributeStringCurrentPosition - 1),
+ false,
+ String.Empty,
+ false);
+ attributeStringCurrentPosition = endEntityPosition + 1;
+
+ return true;
+ }
+ else
+ value += parsed;
+ }
+
+ // Other case always set text node.
+ while(!returnEntity) {
+ nextPosition = attributeString.IndexOf ('&', attributeStringCurrentPosition);
+ if(nextPosition < 0) {
+ // Reached to the end of value string.
+ value += attributeString.Substring (attributeStringCurrentPosition);
+ attributeStringCurrentPosition = -1;
+ break;
+ } else if(nextPosition == attributeStringCurrentPosition) {
+ string parsed = ReadAttributeValueEntityReference ();
+ if(parsed != null)
+ value += parsed;
+ else {
+ // Found that an entity reference starts from this point.
+ // Then once stop to parse attribute value and then return text.
+ value += attributeString.Substring (attributeStringCurrentPosition,
+ nextPosition - attributeStringCurrentPosition);
+ break;
+ }
+ } else {
+ value += attributeString.Substring (attributeStringCurrentPosition,
+ nextPosition - attributeStringCurrentPosition);
+ attributeStringCurrentPosition = nextPosition;
+ continue;
+ }
+ }
+
+ SetProperties(XmlNodeType.Text,
+ "#text",
+ false,
+ value,
+ false);
+
+ return true;
+ }
+
+ [MonoTODO]
+ public int ReadBase64 (byte [] buffer, int offset, int length)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public int ReadBinHex (byte [] buffer, int offset, int length)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public int ReadChars (char [] buffer, int offset, int length)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override string ReadInnerXml ()
+ {
+ // Still need a Well Formedness check.
+ // Will wait for Validating reader ;-)
+ if (NodeType == XmlNodeType.Attribute) {
+ return Value;
+ } else {
+ saveToXmlBuffer = true;
+ string startname = this.Name;
+ string endname = string.Empty;
+ readState = ReadState.Interactive;
+
+ while (startname != endname) {
+ ReadContent ();
+ endname = this.Name;
+ }
+
+ xmlBuffer.Replace (currentTag.ToString (), "");
+ saveToXmlBuffer = false;
+ string InnerXml = xmlBuffer.ToString ();
+ xmlBuffer.Length = 0;
+ return InnerXml;
+ }
+ }
+
+ [MonoTODO]
+ public override string ReadOuterXml ()
+ {
+ if (NodeType == XmlNodeType.Attribute) {
+ return Name + "=\"" + Value.Replace ("\"", "&quot;") + "\"";
+ } else {
+ saveToXmlBuffer = true;
+ xmlBuffer.Append (currentTag.ToString ());
+ int startDepth = Depth;
+ readState = ReadState.Interactive;
+
+ do {
+ ReadContent ();
+ } while (Depth > startDepth);
+
+ saveToXmlBuffer = false;
+ string OuterXml = xmlBuffer.ToString ();
+ xmlBuffer.Length = 0;
+ return OuterXml;
+ }
+ }
+
+ [MonoTODO]
+ public override string ReadString ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void ResetState ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override void ResolveEntity ()
+ {
+ // XmlTextReaders don't resolve entities.
+ throw new InvalidOperationException ("XmlTextReader cannot resolve external entities.");
+ }
+
+ #endregion
+
+ #region Internals
+ internal string publicId;
+ internal string systemId;
+
+ internal void SetReaderContext (string url, XmlParserContext context)
+ {
+ parserContext = context;
+ parserContext.BaseURI = url;
+ Init ();
+ }
+
+ internal void SetReaderFragment(TextReader fragment, XmlNodeType fragType)
+ {
+ this.reader = fragment;
+ can_seek = fragment != null && fragment.Peek () != -1;
+/* for future use
+ switch(fragType)
+ {
+ case XmlNodeType.Attribute: // attribute content
+ parserContext.InputState = XmlParserInputState.AttributeValue;
+ break;
+ case XmlNodeType.DocumentFragment: // element content
+ parserContext.InputState = XmlParserInputState.Content;
+ break;
+ case XmlNodeType.Element: // one element
+ parserContext.InputState = XmlParserInputState.StartTag;
+ break;
+ case XmlNodeType.Document: // document content
+ parserContext.InputState = XmlParserInputState.Start;
+ break;
+ default:
+ throw new InvalidOperationException("setting this xml node type not allowed.");
+ }
+*/
+ }
+ #endregion
+
+ #region Privates
+
+ private XmlParserContext parserContext;
+
+ private TextReader reader;
+ private ReadState readState;
+
+ private int depth;
+ private int elementDepth;
+ private bool depthDown;
+
+ private bool popScope;
+
+ private XmlNodeType nodeType;
+ private string name;
+ private string prefix;
+ private string localName;
+ private string namespaceURI;
+ private bool isEmptyElement;
+ private string value;
+
+ private XmlNodeType saveNodeType;
+ private string saveName;
+ private string savePrefix;
+ private string saveLocalName;
+ private string saveNamespaceURI;
+ private bool saveIsEmptyElement;
+
+ private Hashtable attributes;
+ private ArrayList orderedAttributes;
+ private IEnumerator orderedAttributesEnumerator;
+
+ private bool returnEntityReference;
+ private string entityReferenceName;
+
+ private char [] nameBuffer;
+ private int nameLength;
+ private int nameCapacity;
+ private const int initialNameCapacity = 256;
+
+ private char [] valueBuffer;
+ private int valueLength;
+ private int valueCapacity;
+ private const int initialValueCapacity = 8192;
+
+ private StringBuilder xmlBuffer; // This is for Read(Inner|Outer)Xml
+ private StringBuilder currentTag; // A buffer for ReadContent for ReadOuterXml
+ private bool saveToXmlBuffer;
+ private int line = 1;
+ private int column = 1;
+ private bool has_peek;
+ private bool can_seek;
+ private int peek_char;
+
+ private string attributeString = String.Empty;
+ private int attributeStringCurrentPosition;
+
+ private void Init ()
+ {
+ readState = ReadState.Initial;
+
+ depth = 0;
+ depthDown = false;
+
+ popScope = false;
+
+ nodeType = XmlNodeType.None;
+ name = String.Empty;
+ prefix = String.Empty;
+ localName = string.Empty;
+ isEmptyElement = false;
+ value = String.Empty;
+
+ attributes = new Hashtable ();
+ orderedAttributes = new ArrayList ();
+ orderedAttributesEnumerator = null;
+
+ returnEntityReference = false;
+ entityReferenceName = String.Empty;
+
+ nameBuffer = new char [initialNameCapacity];
+ nameLength = 0;
+ nameCapacity = initialNameCapacity;
+
+ valueBuffer = new char [initialValueCapacity];
+ valueLength = 0;
+ valueCapacity = initialValueCapacity;
+
+ xmlBuffer = new StringBuilder ();
+ currentTag = new StringBuilder ();
+ }
+
+ // Use this method rather than setting the properties
+ // directly so that all the necessary properties can
+ // be changed in harmony with each other. Maybe the
+ // fields should be in a seperate class to help enforce
+ // this.
+ private void SetProperties (
+ XmlNodeType nodeType,
+ string name,
+ bool isEmptyElement,
+ string value,
+ bool clearAttributes)
+ {
+ this.nodeType = nodeType;
+ this.name = name;
+ this.isEmptyElement = isEmptyElement;
+ this.value = value;
+ this.elementDepth = depth;
+
+ if (clearAttributes)
+ ClearAttributes ();
+
+ int indexOfColon = name.IndexOf (':');
+
+ if (indexOfColon == -1) {
+ prefix = String.Empty;
+ localName = name;
+ } else {
+ prefix = name.Substring (0, indexOfColon);
+ localName = name.Substring (indexOfColon + 1);
+ }
+
+ namespaceURI = LookupNamespace (prefix);
+ }
+
+ private void SaveProperties ()
+ {
+ saveNodeType = nodeType;
+ saveName = name;
+ savePrefix = prefix;
+ saveLocalName = localName;
+ saveNamespaceURI = namespaceURI;
+ saveIsEmptyElement = isEmptyElement;
+ // An element's value is always String.Empty.
+ }
+
+ private void RestoreProperties ()
+ {
+ nodeType = saveNodeType;
+ name = saveName;
+ prefix = savePrefix;
+ localName = saveLocalName;
+ namespaceURI = saveNamespaceURI;
+ isEmptyElement = saveIsEmptyElement;
+ value = String.Empty;
+ }
+
+ private void AddAttribute (string name, string value)
+ {
+ attributes.Add (name, value);
+ orderedAttributes.Add (name);
+ }
+
+ private void ClearAttributes ()
+ {
+ if (attributes.Count > 0) {
+ attributes.Clear ();
+ orderedAttributes.Clear ();
+ }
+
+ orderedAttributesEnumerator = null;
+ }
+
+ private int PeekChar ()
+ {
+ if (can_seek)
+ return reader.Peek ();
+
+ if (has_peek)
+ return peek_char;
+
+ peek_char = reader.Read ();
+ has_peek = true;
+ return peek_char;
+ }
+
+ private int ReadChar ()
+ {
+ int ch;
+ if (has_peek) {
+ ch = peek_char;
+ has_peek = false;
+ } else {
+ ch = reader.Read ();
+ }
+
+ if (ch == '\n') {
+ line++;
+ column = 1;
+ } else {
+ column++;
+ }
+ if (saveToXmlBuffer) {
+ xmlBuffer.Append ((char) ch);
+ }
+ currentTag.Append ((char) ch);
+ return ch;
+ }
+
+ // This should really keep track of some state so
+ // that it's not possible to have more than one document
+ // element or text outside of the document element.
+ private bool ReadContent ()
+ {
+ currentTag.Length = 0;
+ if (popScope) {
+ parserContext.NamespaceManager.PopScope ();
+ popScope = false;
+ }
+
+ if (returnEntityReference) {
+ SetEntityReferenceProperties ();
+ } else {
+ switch (PeekChar ())
+ {
+ case '<':
+ ReadChar ();
+ ReadTag ();
+ break;
+ case '\r':
+ if (whitespaceHandling == WhitespaceHandling.All ||
+ whitespaceHandling == WhitespaceHandling.Significant)
+ return ReadWhitespace ();
+
+ ReadChar ();
+ return ReadContent ();
+ case '\n':
+ if (whitespaceHandling == WhitespaceHandling.All ||
+ whitespaceHandling == WhitespaceHandling.Significant)
+ return ReadWhitespace ();
+
+ ReadChar ();
+ return ReadContent ();
+ case ' ':
+ if (whitespaceHandling == WhitespaceHandling.All ||
+ whitespaceHandling == WhitespaceHandling.Significant)
+ return ReadWhitespace ();
+
+ SkipWhitespace ();
+ return ReadContent ();
+ case -1:
+ readState = ReadState.EndOfFile;
+ SetProperties (
+ XmlNodeType.None, // nodeType
+ String.Empty, // name
+ false, // isEmptyElement
+ String.Empty, // value
+ true // clearAttributes
+ );
+ break;
+ default:
+ ReadText (true);
+ break;
+ }
+ }
+ return this.ReadState != ReadState.EndOfFile;
+ }
+
+ private void SetEntityReferenceProperties ()
+ {
+ SetProperties (
+ XmlNodeType.EntityReference, // nodeType
+ entityReferenceName, // name
+ false, // isEmptyElement
+ String.Empty, // value
+ true // clearAttributes
+ );
+
+ returnEntityReference = false;
+ entityReferenceName = String.Empty;
+ }
+
+ // The leading '<' has already been consumed.
+ private void ReadTag ()
+ {
+ switch (PeekChar ())
+ {
+ case '/':
+ ReadChar ();
+ ReadEndTag ();
+ break;
+ case '?':
+ ReadChar ();
+ ReadProcessingInstruction ();
+ break;
+ case '!':
+ ReadChar ();
+ ReadDeclaration ();
+ break;
+ default:
+ ReadStartTag ();
+ break;
+ }
+ }
+
+ // The leading '<' has already been consumed.
+ private void ReadStartTag ()
+ {
+ parserContext.NamespaceManager.PushScope ();
+
+ string name = ReadName ();
+ SkipWhitespace ();
+
+ bool isEmptyElement = false;
+
+ ClearAttributes ();
+
+ if (XmlChar.IsFirstNameChar (PeekChar ()))
+ ReadAttributes ();
+
+ if (PeekChar () == '/') {
+ ReadChar ();
+ isEmptyElement = true;
+ depthDown = true;
+ popScope = true;
+ }
+
+ Expect ('>');
+
+ SetProperties (
+ XmlNodeType.Element, // nodeType
+ name, // name
+ isEmptyElement, // isEmptyElement
+ String.Empty, // value
+ false // clearAttributes
+ );
+
+ if (!depthDown)
+ ++depth;
+ else
+ depthDown = false;
+
+ }
+
+ // The reader is positioned on the first character
+ // of the element's name.
+ private void ReadEndTag ()
+ {
+ string name = ReadName ();
+ SkipWhitespace ();
+ Expect ('>');
+
+ --depth;
+
+ SetProperties (
+ XmlNodeType.EndElement, // nodeType
+ name, // name
+ false, // isEmptyElement
+ String.Empty, // value
+ true // clearAttributes
+ );
+
+ popScope = true;
+ }
+
+ private void AppendNameChar (int ch)
+ {
+ CheckNameCapacity ();
+ nameBuffer [nameLength++] = (char)ch;
+ }
+
+ private void CheckNameCapacity ()
+ {
+ if (nameLength == nameCapacity) {
+ nameCapacity = nameCapacity * 2;
+ char [] oldNameBuffer = nameBuffer;
+ nameBuffer = new char [nameCapacity];
+ Array.Copy (oldNameBuffer, nameBuffer, nameLength);
+ }
+ }
+
+ private string CreateNameString ()
+ {
+ return new String (nameBuffer, 0, nameLength);
+ }
+
+ private void AppendValueChar (int ch)
+ {
+ CheckValueCapacity ();
+ valueBuffer [valueLength++] = (char)ch;
+ }
+
+ private void CheckValueCapacity ()
+ {
+ if (valueLength == valueCapacity) {
+ valueCapacity = valueCapacity * 2;
+ char [] oldValueBuffer = valueBuffer;
+ valueBuffer = new char [valueCapacity];
+ Array.Copy (oldValueBuffer, valueBuffer, valueLength);
+ }
+ }
+
+ private string CreateValueString ()
+ {
+ return new String (valueBuffer, 0, valueLength);
+ }
+
+ // The reader is positioned on the first character
+ // of the text.
+ private void ReadText (bool cleanValue)
+ {
+ if (cleanValue)
+ valueLength = 0;
+
+ int ch = PeekChar ();
+
+ while (ch != '<' && ch != -1) {
+ if (ch == '&') {
+ ReadChar ();
+ if (ReadReference (false))
+ break;
+ } else
+ AppendValueChar (ReadChar ());
+
+ ch = PeekChar ();
+ }
+
+ if (returnEntityReference && valueLength == 0) {
+ SetEntityReferenceProperties ();
+ } else {
+ SetProperties (
+ XmlNodeType.Text, // nodeType
+ String.Empty, // name
+ false, // isEmptyElement
+ CreateValueString (), // value
+ true // clearAttributes
+ );
+ }
+ }
+
+ // The leading '&' has already been consumed.
+ // Returns true if the entity reference isn't a simple
+ // character reference or one of the predefined entities.
+ // This allows the ReadText method to break so that the
+ // next call to Read will return the EntityReference node.
+ private bool ReadReference (bool ignoreEntityReferences)
+ {
+ if (PeekChar () == '#') {
+ ReadChar ();
+ ReadCharacterReference ();
+ } else
+ ReadEntityReference (ignoreEntityReferences);
+
+ return returnEntityReference;
+ }
+
+ private void ReadCharacterReference ()
+ {
+ int value = 0;
+
+ if (PeekChar () == 'x') {
+ ReadChar ();
+
+ while (PeekChar () != ';' && PeekChar () != -1) {
+ int ch = ReadChar ();
+
+ if (ch >= '0' && ch <= '9')
+ value = (value << 4) + ch - '0';
+ else if (ch >= 'A' && ch <= 'F')
+ value = (value << 4) + ch - 'A' + 10;
+ else if (ch >= 'a' && ch <= 'f')
+ value = (value << 4) + ch - 'a' + 10;
+ else
+ throw new XmlException (
+ String.Format (
+ "invalid hexadecimal digit: {0} (#x{1:X})",
+ (char)ch,
+ ch));
+ }
+ } else {
+ while (PeekChar () != ';' && PeekChar () != -1) {
+ int ch = ReadChar ();
+
+ if (ch >= '0' && ch <= '9')
+ value = value * 10 + ch - '0';
+ else
+ throw new XmlException (
+ String.Format (
+ "invalid decimal digit: {0} (#x{1:X})",
+ (char)ch,
+ ch));
+ }
+ }
+
+ ReadChar (); // ';'
+
+ AppendValueChar (value);
+ }
+
+ private void ReadEntityReference (bool ignoreEntityReferences)
+ {
+ nameLength = 0;
+
+ int ch = PeekChar ();
+
+ while (ch != ';' && ch != -1) {
+ AppendNameChar (ReadChar ());
+ ch = PeekChar ();
+ }
+
+ Expect (';');
+
+ string name = CreateNameString ();
+
+ switch (name)
+ {
+ case "lt":
+ AppendValueChar ('<');
+ break;
+ case "gt":
+ AppendValueChar ('>');
+ break;
+ case "amp":
+ AppendValueChar ('&');
+ break;
+ case "apos":
+ AppendValueChar ('\'');
+ break;
+ case "quot":
+ AppendValueChar ('"');
+ break;
+ default:
+ if (ignoreEntityReferences) {
+ AppendValueChar ('&');
+
+ foreach (char ch2 in name) {
+ AppendValueChar (ch2);
+ }
+
+ AppendValueChar (';');
+ } else {
+ returnEntityReference = true;
+ entityReferenceName = name;
+ }
+ break;
+ }
+ }
+
+ // The reader is positioned on the first character of
+ // the attribute name.
+ private void ReadAttributes ()
+ {
+ do {
+ string name = ReadName ();
+ SkipWhitespace ();
+ Expect ('=');
+ SkipWhitespace ();
+ string value = ReadAttribute ();
+ SkipWhitespace ();
+
+ if (name == "xmlns")
+ parserContext.NamespaceManager.AddNamespace (String.Empty, value);
+ else if (name.StartsWith ("xmlns:"))
+ parserContext.NamespaceManager.AddNamespace (name.Substring (6), value);
+
+ AddAttribute (name, value);
+ } while (PeekChar () != '/' && PeekChar () != '>' && PeekChar () != -1);
+ }
+
+ // The reader is positioned on the quote character.
+ private string ReadAttribute ()
+ {
+ int quoteChar = ReadChar ();
+
+ if (quoteChar != '\'' && quoteChar != '\"')
+ throw new XmlException ("an attribute value was not quoted");
+
+ valueLength = 0;
+
+ while (PeekChar () != quoteChar) {
+ int ch = ReadChar ();
+
+ switch (ch)
+ {
+ case '<':
+ throw new XmlException ("attribute values cannot contain '<'");
+// expansion of entity now should be done at ResolveAttributeValue() method
+// case '&':
+// ReadReference (true);
+// break;
+ case -1:
+ throw new XmlException ("unexpected end of file in an attribute value");
+ default:
+ AppendValueChar (ch);
+ break;
+ }
+ }
+
+ ReadChar (); // quoteChar
+
+ return CreateValueString ();
+ }
+
+ // The reader is positioned on the first character
+ // of the target.
+ //
+ // Now it also reads XmlDeclaration, this method name became improper...
+ private void ReadProcessingInstruction ()
+ {
+ string target = ReadName ();
+ SkipWhitespace ();
+
+ valueLength = 0;
+
+ while (PeekChar () != -1) {
+ int ch = ReadChar ();
+
+ if (ch == '?' && PeekChar () == '>') {
+ ReadChar ();
+ break;
+ }
+
+ AppendValueChar ((char)ch);
+ }
+
+/* for future use
+ if(target == "xml") && parserContext.InputState != XmlParserInputState.Start)
+ throw new XmlException("Xml declaration is not allowed here.");
+ else {
+ parserContext.InputState = XmlParserInputState.DTD; //for future use
+ }
+*/
+ SetProperties (
+ target == "xml" ?
+ XmlNodeType.XmlDeclaration :
+ XmlNodeType.ProcessingInstruction, // nodeType
+ target, // name
+ false, // isEmptyElement
+ CreateValueString (), // value
+ true // clearAttributes
+ );
+ }
+
+ // The reader is positioned on the first character after
+ // the leading '<!'.
+ private void ReadDeclaration ()
+ {
+ int ch = PeekChar ();
+
+ switch (ch)
+ {
+ case '-':
+ Expect ("--");
+ ReadComment ();
+ break;
+ case '[':
+ ReadChar ();
+ Expect ("CDATA[");
+ ReadCDATA ();
+ break;
+ case 'D':
+ Expect ("DOCTYPE");
+ ReadDoctypeDecl ();
+ break;
+ }
+ }
+
+ // The reader is positioned on the first character after
+ // the leading '<!--'.
+ private void ReadComment ()
+ {
+ valueLength = 0;
+
+ while (PeekChar () != -1) {
+ int ch = ReadChar ();
+
+ if (ch == '-' && PeekChar () == '-') {
+ ReadChar ();
+
+ if (PeekChar () != '>')
+ throw new XmlException ("comments cannot contain '--'");
+
+ ReadChar ();
+ break;
+ }
+
+ AppendValueChar ((char)ch);
+ }
+
+ SetProperties (
+ XmlNodeType.Comment, // nodeType
+ String.Empty, // name
+ false, // isEmptyElement
+ CreateValueString (), // value
+ true // clearAttributes
+ );
+ }
+
+ // The reader is positioned on the first character after
+ // the leading '<![CDATA['.
+ private void ReadCDATA ()
+ {
+ valueLength = 0;
+
+ while (PeekChar () != -1) {
+ int ch = ReadChar ();
+
+ if (ch == ']' && PeekChar () == ']') {
+ ch = ReadChar (); // ']'
+
+ if (PeekChar () == '>') {
+ ReadChar (); // '>'
+ break;
+ } else {
+ AppendValueChar (']');
+ AppendValueChar (']');
+ ch = ReadChar ();
+ }
+ }
+
+ AppendValueChar ((char)ch);
+ }
+
+ SetProperties (
+ XmlNodeType.CDATA, // nodeType
+ String.Empty, // name
+ false, // isEmptyElement
+ CreateValueString (), // value
+ true // clearAttributes
+ );
+ }
+
+ // The reader is positioned on the first character after
+ // the leading '<!DOCTYPE'.
+ private void ReadDoctypeDecl ()
+ {
+ string doctypeName = null;
+ string publicId = String.Empty;
+ string systemId = String.Empty;
+
+ SkipWhitespace ();
+ doctypeName = ReadName ();
+ SkipWhitespace ();
+ xmlBuffer.Length = 0;
+ switch(PeekChar ())
+ {
+ case 'S':
+ systemId = ReadSystemLiteral (true);
+ break;
+ case 'P':
+ publicId = ReadPubidLiteral ();
+ SkipWhitespace ();
+ systemId = ReadSystemLiteral (false);
+ break;
+ }
+ SkipWhitespace ();
+
+
+ if(PeekChar () == '[')
+ {
+ // read markupdecl etc. or end of decl
+ ReadChar ();
+ xmlBuffer.Length = 0;
+ saveToXmlBuffer = true;
+ do {
+ ReadDTDInternalSubset ();
+ } while(nodeType != XmlNodeType.None);
+ xmlBuffer.Remove (xmlBuffer.Length - 1, 1); // cut off ']'
+ saveToXmlBuffer = false;
+ }
+ // end of DOCTYPE decl.
+ SkipWhitespace ();
+ Expect ('>');
+
+ parserContext.InternalSubset = xmlBuffer.ToString ();
+
+ // set properties for <!DOCTYPE> node
+ SetProperties (
+ XmlNodeType.DocumentType, // nodeType
+ doctypeName, // name
+ false, // isEmptyElement
+ parserContext.InternalSubset, // value
+ true // clearAttributes
+ );
+ }
+
+ // Read any one of following:
+ // elementdecl, AttlistDecl, EntityDecl, NotationDecl,
+ // PI, Comment, Parameter Entity, or doctype termination char(']')
+ //
+ // returns a node of some nodeType or null, setting nodeType.
+ // (if None then ']' was found.)
+ private void ReadDTDInternalSubset()
+ {
+ SkipWhitespace ();
+ switch(ReadChar ())
+ {
+ case ']':
+ nodeType = XmlNodeType.None;
+ break;
+ case '%':
+ string peName = ReadName ();
+ Expect (';');
+ nodeType = XmlNodeType.EntityReference; // It's chating a bit;-)
+ break;
+ case '<':
+ switch(ReadChar ())
+ {
+ case '?':
+ ReadProcessingInstruction ();
+ break;
+ case '!':
+ switch(ReadChar ())
+ {
+ case '-':
+ Expect ('-');
+ ReadComment ();
+ break;
+ case 'E':
+ switch(ReadChar ())
+ {
+ case 'N':
+ Expect ("TITY");
+ ReadEntityDecl ();
+ break;
+ case 'L':
+ Expect ("EMENT");
+ ReadElementDecl ();
+ break;
+ default:
+ throw new XmlException ("Syntax Error after '<!E' (ELEMENT or ENTITY must be found)");
+ }
+ break;
+ case 'A':
+ Expect ("TTLIST");
+ ReadAttListDecl ();
+ break;
+ case 'N':
+ Expect ("OTATION");
+ ReadNotationDecl ();
+ break;
+ default:
+ throw new XmlException ("Syntax Error after '<!' characters.");
+ }
+ break;
+ default:
+ throw new XmlException ("Syntax Error after '<' character.");
+ }
+ break;
+ default:
+ throw new XmlException ("Syntax Error inside doctypedecl markup.");
+ }
+ }
+
+ // The reader is positioned on the head of the name.
+ private void ReadElementDecl()
+ {
+ while(ReadChar () != '>');
+ }
+
+ private void ReadEntityDecl()
+ {
+ while(ReadChar () != '>');
+ }
+
+ private void ReadAttListDecl()
+ {
+ while(ReadChar () != '>');
+ }
+
+ private void ReadNotationDecl()
+ {
+ while(ReadChar () != '>');
+ }
+
+ // The reader is positioned on the first 'S' of "SYSTEM".
+ private string ReadSystemLiteral (bool expectSYSTEM)
+ {
+ if(expectSYSTEM)
+ Expect ("SYSTEM");
+ SkipWhitespace ();
+ int quoteChar = ReadChar (); // apos or quot
+ xmlBuffer.Length = 0;
+ saveToXmlBuffer = true;
+ int c = 0;
+ while(c != quoteChar) {
+ c = ReadChar ();
+ if(c < 0) throw new XmlException ("Unexpected end of stream in ExternalID.");
+ }
+ saveToXmlBuffer = false;
+ xmlBuffer.Remove (xmlBuffer.Length-1, 1); // cut quoteChar
+ return xmlBuffer.ToString ();
+ }
+
+ private string ReadPubidLiteral()
+ {
+ Expect ("PUBLIC");
+ SkipWhitespace ();
+ int quoteChar = ReadChar ();
+ xmlBuffer.Length = 0;
+ saveToXmlBuffer = true;
+ int c = 0;
+ while(c != quoteChar)
+ {
+ c = ReadChar ();
+ if(c < 0) throw new XmlException ("Unexpected end of stream in ExternalID.");
+ if(c != quoteChar && !XmlChar.IsPubidChar (c))
+ throw new XmlException("character '" + (char)c + "' not allowed for PUBLIC ID");
+ }
+ ReadChar(); // skips quoteChar
+ xmlBuffer.Remove (xmlBuffer.Length-1, 1); // cut quoteChar
+ saveToXmlBuffer = false;
+ return xmlBuffer.ToString ();
+ }
+
+ // The reader is positioned on the first character
+ // of the name.
+ private string ReadName ()
+ {
+ if (!XmlChar.IsFirstNameChar (PeekChar ()))
+ throw new XmlException ("a name did not start with a legal character");
+
+ nameLength = 0;
+
+ AppendNameChar (ReadChar ());
+
+ while (XmlChar.IsNameChar (PeekChar ())) {
+ AppendNameChar (ReadChar ());
+ }
+
+ return CreateNameString ();
+ }
+
+ // Read the next character and compare it against the
+ // specified character.
+ private void Expect (int expected)
+ {
+ int ch = ReadChar ();
+
+ if (ch != expected) {
+ throw new XmlException (
+ String.Format (
+ "expected '{0}' ({1:X}) but found '{2}' ({3:X})",
+ (char)expected,
+ expected,
+ (char)ch,
+ ch));
+ }
+ }
+
+ private void Expect (string expected)
+ {
+ int len = expected.Length;
+ for(int i=0; i< len; i++)
+ Expect (expected[i]);
+ }
+
+ // Does not consume the first non-whitespace character.
+ private void SkipWhitespace ()
+ {
+ //FIXME: Should not skip if whitespaceHandling == WhiteSpaceHandling.None
+ while (XmlChar.IsWhitespace (PeekChar ()))
+ ReadChar ();
+ }
+
+ private bool ReadWhitespace ()
+ {
+ valueLength = 0;
+ int ch = PeekChar ();
+ do {
+ AppendValueChar (ReadChar ());
+ } while ((ch = PeekChar ()) != -1 && XmlChar.IsWhitespace (ch));
+
+ if (ch != -1 && ch != '<')
+ ReadText (false);
+ else
+ SetProperties (XmlNodeType.Whitespace,
+ String.Empty,
+ false,
+ CreateValueString (),
+ true);
+
+ return (PeekChar () != -1);
+ }
+
+ // read entity reference from attribute string and if parsable then return the value.
+ private string ReadAttributeValueEntityReference ()
+ {
+ int endEntityPosition = attributeString.IndexOf(';',
+ attributeStringCurrentPosition);
+ string entityName = attributeString.Substring (attributeStringCurrentPosition + 1,
+ endEntityPosition - attributeStringCurrentPosition - 1);
+
+ attributeStringCurrentPosition = endEntityPosition + 1;
+
+ if(entityName [0] == '#') {
+ char c;
+ // character entity
+ if(entityName [1] == 'x') {
+ // hexadecimal
+ c = (char) int.Parse ("0" + entityName.Substring (2),
+ System.Globalization.NumberStyles.HexNumber);
+ } else {
+ // decimal
+ c = (char) int.Parse (entityName.Substring (1));
+ }
+ return c.ToString();
+ }
+ else {
+ switch(entityName)
+ {
+ case "lt": return "<";
+ case "gt": return ">";
+ case "amp": return "&";
+ case "quot": return "\"";
+ case "apos": return "'";
+ default: return null;
+ }
+ }
+ }
+
+ private string ResolveAttributeValue (string unresolved)
+ {
+ if(unresolved == null) return null;
+ 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);
+ string entityName =
+ unresolved.Substring (next + 1, endPos - next - 1);
+ if(entityName [0] == '#') {
+ char c;
+ // character entity
+ if(entityName [1] == 'x') {
+ // hexadecimal
+ c = (char) int.Parse ("0" + entityName.Substring (2),
+ System.Globalization.NumberStyles.HexNumber);
+ } else {
+ // decimal
+ c = (char) int.Parse (entityName.Substring (1));
+ }
+ resolved.Append (c);
+ } else {
+ switch(entityName) {
+ case "lt": resolved.Append ("<"); break;
+ case "gt": resolved.Append (">"); break;
+ case "amp": resolved.Append ("&"); break;
+ case "quot": resolved.Append ("\""); break;
+ case "apos": resolved.Append ("'"); break;
+ // With respect to "Value", MS document is helpless
+ // and the implemention returns inconsistent value
+ // (e.g. XML: "&ent; &amp;ent;" ---> Value: "&ent; &ent;".)
+ default: resolved.Append ("&" + entityName + ";"); break;
+ }
+ }
+ pos = endPos + 1;
+ if(pos > unresolved.Length)
+ break;
+ next = unresolved.IndexOf('&', pos);
+ }
+ resolved.Append (unresolved.Substring(pos));
+
+ return resolved.ToString();
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlTextWriter.cs b/mcs/class/System.XML/System.Xml/XmlTextWriter.cs
new file mode 100644
index 00000000000..a11457b5b85
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlTextWriter.cs
@@ -0,0 +1,700 @@
+//
+// System.Xml.XmlTextWriter
+//
+// Author:
+// Kral Ferch <kral_ferch@hotmail.com>
+//
+// (C) 2002 Kral Ferch
+//
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Text;
+
+namespace System.Xml
+{
+ public class XmlTextWriter : XmlWriter
+ {
+ #region Fields
+
+ TextWriter w;
+ bool nullEncoding = false;
+ bool openWriter = true;
+ bool openStartElement = false;
+ bool openStartAttribute = false;
+ bool documentStarted = false;
+ bool namespaces = true;
+ bool openAttribute = false;
+ bool attributeWrittenForElement = false;
+ Stack openElements = new Stack ();
+ Formatting formatting = Formatting.None;
+ int indentation = 2;
+ char indentChar = ' ';
+ string indentChars = " ";
+ char quoteChar = '\"';
+ int indentLevel = 0;
+ string indentFormatting;
+ Stream baseStream = null;
+ string xmlLang = null;
+ XmlSpace xmlSpace = XmlSpace.None;
+ bool openXmlLang = false;
+ bool openXmlSpace = false;
+ string openElementPrefix;
+ string openElementNS;
+
+ #endregion
+
+ #region Constructors
+
+ public XmlTextWriter (TextWriter w) : base ()
+ {
+ this.w = w;
+ nullEncoding = (w.Encoding == null);
+
+ try {
+ baseStream = ((StreamWriter)w).BaseStream;
+ }
+ catch (Exception) { }
+ }
+
+ public XmlTextWriter (Stream w, Encoding encoding) : base ()
+ {
+ if (encoding == null) {
+ nullEncoding = true;
+ encoding = new UTF8Encoding ();
+ }
+
+ this.w = new StreamWriter(w, encoding);
+ baseStream = w;
+ }
+
+ public XmlTextWriter (string filename, Encoding encoding) :
+ this (new FileStream (filename, FileMode.Create, FileAccess.Write, FileShare.None), encoding)
+ {
+ }
+
+ #endregion
+
+ #region Properties
+
+ public Stream BaseStream {
+ get { return baseStream; }
+ }
+
+
+ public Formatting Formatting {
+ get { return formatting; }
+ set { formatting = value; }
+ }
+
+ private bool IndentingOverriden
+ {
+ get {
+ if (openElements.Count == 0)
+ return false;
+ else
+ return (((XmlTextWriterOpenElement)openElements.Peek()).IndentingOverriden);
+ }
+ set {
+ if (openElements.Count > 0)
+ ((XmlTextWriterOpenElement)openElements.Peek()).IndentingOverriden = value;
+ }
+ }
+
+ public int Indentation {
+ get { return indentation; }
+ set {
+ indentation = value;
+ UpdateIndentChars ();
+ }
+ }
+
+ public char IndentChar {
+ get { return indentChar; }
+ set {
+ indentChar = value;
+ UpdateIndentChars ();
+ }
+ }
+
+ public bool Namespaces {
+ get { return namespaces; }
+ set {
+ if (ws != WriteState.Start)
+ throw new InvalidOperationException ("NotInWriteState.");
+
+ namespaces = value;
+ }
+ }
+
+ public char QuoteChar {
+ get { return quoteChar; }
+ set {
+ if ((value != '\'') && (value != '\"'))
+ throw new ArgumentException ("This is an invalid XML attribute quote character. Valid attribute quote characters are ' and \".");
+
+ quoteChar = value;
+ }
+ }
+
+ public override WriteState WriteState {
+ get { return ws; }
+ }
+
+ public override string XmlLang {
+ get {
+ string xmlLang = null;
+ int i;
+
+ for (i = 0; i < openElements.Count; i++)
+ {
+ xmlLang = ((XmlTextWriterOpenElement)openElements.ToArray().GetValue(i)).XmlLang;
+ if (xmlLang != null)
+ break;
+ }
+
+ return xmlLang;
+ }
+ }
+
+ public override XmlSpace XmlSpace {
+ get {
+ XmlSpace xmlSpace = XmlSpace.None;
+ int i;
+
+ for (i = 0; i < openElements.Count; i++)
+ {
+ xmlSpace = ((XmlTextWriterOpenElement)openElements.ToArray().GetValue(i)).XmlSpace;
+ if (xmlSpace != XmlSpace.None)
+ break;
+ }
+
+ return xmlSpace;
+ }
+ }
+
+ #endregion
+
+ #region Methods
+ private void AddMissingElementXmlns ()
+ {
+ // output namespace declaration if not exist.
+ string prefix = openElementPrefix;
+ string ns = openElementNS;
+ if (ns != null/* && LookupPrefix (ns) != prefix*/)
+ {
+ string formatXmlns = String.Empty;
+ if (ns != String.Empty)
+ {
+ string existingPrefix = namespaceManager.LookupPrefix (ns);
+ bool addDefaultNamespace = false;
+
+ if (existingPrefix == null)
+ {
+ namespaceManager.AddNamespace (prefix, ns);
+ addDefaultNamespace = true;
+ }
+
+ if (prefix == String.Empty)
+ prefix = existingPrefix;
+
+ if (prefix != existingPrefix)
+ formatXmlns = String.Format (" xmlns:{0}={1}{2}{1}", prefix, quoteChar, ns);
+ else if (addDefaultNamespace)
+ formatXmlns = String.Format (" xmlns={0}{1}{0}", quoteChar, ns);
+ }
+ else if ((prefix == String.Empty) && (namespaceManager.LookupNamespace (prefix) != String.Empty))
+ {
+ namespaceManager.AddNamespace (prefix, ns);
+ formatXmlns = String.Format (" xmlns={0}{0}", quoteChar);
+ }
+ if(formatXmlns != String.Empty)
+ w.Write(formatXmlns);
+ openElementPrefix = null;
+ openElementNS = null;
+ }
+ }
+
+ private void CheckState ()
+ {
+ if (!openWriter) {
+ throw new InvalidOperationException ("The Writer is closed.");
+ }
+ if ((documentStarted == true) && (formatting == Formatting.Indented) && (!IndentingOverriden)) {
+ indentFormatting = w.NewLine;
+ if (indentLevel > 0) {
+ for (int i = 0; i < indentLevel; i++)
+ indentFormatting += indentChars;
+ }
+ }
+ else
+ indentFormatting = "";
+
+ documentStarted = true;
+ }
+
+ public override void Close ()
+ {
+ CloseOpenAttributeAndElements ();
+
+ w.Close();
+ ws = WriteState.Closed;
+ openWriter = false;
+ }
+
+ private void CloseOpenAttributeAndElements ()
+ {
+ if (openAttribute)
+ WriteEndAttribute ();
+
+ while (openElements.Count > 0) {
+ WriteEndElement();
+ }
+ }
+
+ private void CloseStartElement ()
+ {
+ if (!openStartElement)
+ return;
+
+ AddMissingElementXmlns ();
+
+ w.Write (">");
+ ws = WriteState.Content;
+ openStartElement = false;
+ attributeWrittenForElement = false;
+ }
+
+ public override void Flush ()
+ {
+ w.Flush ();
+ }
+
+ public override string LookupPrefix (string ns)
+ {
+ string prefix = namespaceManager.LookupPrefix (ns);
+
+ // XmlNamespaceManager has changed to return null when NSURI not found.
+ // (Contradiction to the documentation.)
+ //if (prefix == String.Empty)
+ // prefix = null;
+ return prefix;
+ }
+
+ private void UpdateIndentChars ()
+ {
+ indentChars = "";
+ for (int i = 0; i < indentation; i++)
+ indentChars += indentChar;
+ }
+
+ public override void WriteBase64 (byte[] buffer, int index, int count)
+ {
+ w.Write (Convert.ToBase64String (buffer, index, count));
+ }
+
+ [MonoTODO]
+ public override void WriteBinHex (byte[] buffer, int index, int count)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override void WriteCData (string text)
+ {
+ if (text.IndexOf("]]>") > 0)
+ throw new ArgumentException ();
+
+ CheckState ();
+ CloseStartElement ();
+
+ w.Write("<![CDATA[{0}]]>", text);
+ }
+
+ public override void WriteCharEntity (char ch)
+ {
+ Int16 intCh = (Int16)ch;
+
+ // Make sure the character is not in the surrogate pair
+ // character range, 0xd800- 0xdfff
+ if ((intCh >= -10240) && (intCh <= -8193))
+ throw new ArgumentException ("Surrogate Pair is invalid.");
+
+ w.Write("&#x{0:X};", intCh);
+ }
+
+ [MonoTODO]
+ public override void WriteChars (char[] buffer, int index, int count)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override void WriteComment (string text)
+ {
+ if ((text.EndsWith("-")) || (text.IndexOf("-->") > 0)) {
+ throw new ArgumentException ();
+ }
+
+ CheckState ();
+ CloseStartElement ();
+
+ w.Write ("<!--{0}-->", text);
+ }
+
+ public override void WriteDocType (string name, string pubid, string sysid, string subset)
+ {
+ if (name == null || name.Trim ().Length == 0)
+ throw new ArgumentException ("Invalid DOCTYPE name", "name");
+
+ w.Write ("<!DOCTYPE ");
+ w.Write (name);
+ if (pubid != null) {
+ w.Write (String.Format (" PUBLIC {0}{1}{0} {0}{2}{0}", quoteChar, pubid, sysid));
+ } else if (sysid != null) {
+ w.Write (String.Format (" SYSTEM {0}{1}{0}", quoteChar, sysid));
+ }
+
+ if (subset != null)
+ w.Write ("[" + subset + "]");
+
+ w.Write('>');
+ }
+
+ public override void WriteEndAttribute ()
+ {
+ if (!openAttribute)
+ throw new InvalidOperationException("Token EndAttribute in state Start would result in an invalid XML document.");
+
+ CheckState ();
+
+ if (openXmlLang) {
+ w.Write (xmlLang);
+ openXmlLang = false;
+ ((XmlTextWriterOpenElement)openElements.Peek()).XmlLang = xmlLang;
+ }
+
+ if (openXmlSpace)
+ {
+ w.Write (xmlSpace.ToString ().ToLower ());
+ openXmlSpace = false;
+ ((XmlTextWriterOpenElement)openElements.Peek()).XmlSpace = xmlSpace;
+ }
+
+ w.Write ("{0}", quoteChar);
+
+ openAttribute = false;
+ }
+
+ public override void WriteEndDocument ()
+ {
+ CloseOpenAttributeAndElements ();
+
+ if ((ws == WriteState.Start) || (ws == WriteState.Prolog))
+ throw new ArgumentException ("This document does not have a root element.");
+
+ ws = WriteState.Start;
+ }
+
+ public override void WriteEndElement ()
+ {
+ WriteEndElementInternal (false);
+ }
+
+ private void WriteEndElementInternal (bool fullEndElement)
+ {
+ if (openElements.Count == 0)
+ throw new InvalidOperationException("There was no XML start tag open.");
+
+ indentLevel--;
+ CheckState ();
+ AddMissingElementXmlns ();
+
+ if (openStartElement) {
+ if (openAttribute)
+ WriteEndAttribute ();
+ if (fullEndElement)
+ w.Write ("></{0}>", ((XmlTextWriterOpenElement)openElements.Peek ()).Name);
+ else
+ w.Write (" />");
+
+ openElements.Pop ();
+ openStartElement = false;
+ } else {
+ w.Write ("{0}</{1}>", indentFormatting, openElements.Pop ());
+ }
+
+ namespaceManager.PopScope();
+ }
+
+ [MonoTODO]
+ public override void WriteEntityRef (string name)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override void WriteFullEndElement ()
+ {
+ WriteEndElementInternal (true);
+ }
+
+ private void CheckValidChars (string name, bool firstOnlyLetter)
+ {
+ foreach (char c in name) {
+ if (XmlConvert.IsInvalid (c, firstOnlyLetter))
+ throw new ArgumentException ("There is an invalid character: '" + c +
+ "'", "name");
+ }
+ }
+
+ public override void WriteName (string name)
+ {
+ CheckValidChars (name, true);
+ w.Write (name);
+ }
+
+ public override void WriteNmToken (string name)
+ {
+ CheckValidChars (name, false);
+ w.Write (name);
+ }
+
+ public override void WriteProcessingInstruction (string name, string text)
+ {
+ if ((name == null) || (name == string.Empty) || (name.IndexOf("?>") > 0) || (text.IndexOf("?>") > 0)) {
+ throw new ArgumentException ();
+ }
+
+ CheckState ();
+ CloseStartElement ();
+
+ w.Write ("{0}<?{1} {2}?>", indentFormatting, name, text);
+ }
+
+ [MonoTODO]
+ public override void WriteQualifiedName (string localName, string ns)
+ {
+ if (localName == null || localName == String.Empty)
+ throw new ArgumentException ();
+
+ CheckState ();
+ w.Write ("{0}:{1}", ns, localName);
+ }
+
+ public override void WriteRaw (string data)
+ {
+ WriteStringInternal (data, false);
+ }
+
+ [MonoTODO]
+ public override void WriteRaw (char[] buffer, int index, int count)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override void WriteStartAttribute (string prefix, string localName, string ns)
+ {
+ if ((prefix == "xml") && (localName == "lang"))
+ openXmlLang = true;
+
+ if ((prefix == "xml") && (localName == "space"))
+ openXmlSpace = true;
+
+ if ((prefix == "xmlns") && (localName == "xmlns"))
+ throw new ArgumentException ("Prefixes beginning with \"xml\" (regardless of whether the characters are uppercase, lowercase, or some combination thereof) are reserved for use by XML.");
+
+ CheckState ();
+
+ if (ws == WriteState.Content)
+ throw new InvalidOperationException ("Token StartAttribute in state " + WriteState + " would result in an invalid XML document.");
+
+ if (prefix == null)
+ prefix = String.Empty;
+
+ if (ns == null)
+ ns = String.Empty;
+
+ string formatPrefix = "";
+ string formatSpace = "";
+
+ if (ns != String.Empty)
+ {
+ string existingPrefix = namespaceManager.LookupPrefix (ns);
+
+ if (prefix == String.Empty)
+ prefix = (existingPrefix == null) ?
+ String.Empty : existingPrefix;
+ }
+
+ if (prefix != String.Empty)
+ {
+ formatPrefix = prefix + ":";
+ }
+
+ if (openStartElement || attributeWrittenForElement)
+ formatSpace = " ";
+
+ w.Write ("{0}{1}{2}={3}", formatSpace, formatPrefix, localName, quoteChar);
+
+ openAttribute = true;
+ attributeWrittenForElement = true;
+ ws = WriteState.Attribute;
+ }
+
+ public override void WriteStartDocument ()
+ {
+ WriteStartDocument ("");
+ }
+
+ public override void WriteStartDocument (bool standalone)
+ {
+ string standaloneFormatting;
+
+ if (standalone == true)
+ standaloneFormatting = String.Format (" standalone={0}yes{0}", quoteChar);
+ else
+ standaloneFormatting = String.Format (" standalone={0}no{0}", quoteChar);
+
+ WriteStartDocument (standaloneFormatting);
+ }
+
+ private void WriteStartDocument (string standaloneFormatting)
+ {
+ if (documentStarted == true)
+ throw new InvalidOperationException("WriteStartDocument should be the first call.");
+
+ CheckState ();
+
+ string encodingFormatting = "";
+
+ if (!nullEncoding)
+ encodingFormatting = String.Format (" encoding={0}{1}{0}", quoteChar, w.Encoding.HeaderName);
+
+ w.Write("<?xml version={0}1.0{0}{1}{2}?>", quoteChar, encodingFormatting, standaloneFormatting);
+ ws = WriteState.Prolog;
+ }
+
+ public override void WriteStartElement (string prefix, string localName, string ns)
+ {
+ if (!Namespaces && (((prefix != null) && (prefix != String.Empty))
+ || ((ns != null) && (ns != String.Empty))))
+ throw new ArgumentException ("Cannot set the namespace if Namespaces is 'false'.");
+
+ WriteStartElementInternal (prefix, localName, ns);
+ }
+
+ private void WriteStartElementInternal (string prefix, string localName, string ns)
+ {
+ if ((prefix != null && prefix != String.Empty) && ((ns == null) || (ns == String.Empty)))
+ throw new ArgumentException ("Cannot use a prefix with an empty namespace.");
+
+ CheckState ();
+ CloseStartElement ();
+
+ if (prefix == null)
+ prefix = namespaceManager.LookupPrefix (ns);
+ if (prefix == null)
+ prefix = String.Empty;
+
+ string formatXmlns = "";
+ string formatPrefix = "";
+
+ if(ns != null) {
+ if (prefix != String.Empty)
+ formatPrefix = prefix + ":";
+ }
+
+ w.Write ("{0}<{1}{2}{3}", indentFormatting, formatPrefix, localName, formatXmlns);
+
+
+ openElements.Push (new XmlTextWriterOpenElement (formatPrefix + localName));
+ ws = WriteState.Element;
+ openStartElement = true;
+ openElementNS = ns;
+ openElementPrefix = prefix;
+
+ namespaceManager.PushScope ();
+// if(ns != null)
+// namespaceManager.AddNamespace (prefix, ns);
+ indentLevel++;
+ }
+
+ public override void WriteString (string text)
+ {
+ if (ws == WriteState.Prolog)
+ throw new InvalidOperationException ("Token content in state Prolog would result in an invalid XML document.");
+
+ WriteStringInternal (text, true);
+ }
+
+ private void WriteStringInternal (string text, bool entitize)
+ {
+ if (text == null)
+ text = String.Empty;
+
+ if (text != String.Empty)
+ {
+ CheckState ();
+
+ if (entitize)
+ {
+ text = text.Replace ("&", "&amp;");
+ text = text.Replace ("<", "&lt;");
+ text = text.Replace (">", "&gt;");
+
+ if (openAttribute)
+ {
+ if (quoteChar == '"')
+ text = text.Replace ("\"", "&quot;");
+ else
+ text = text.Replace ("'", "&apos;");
+ }
+ }
+
+ if (!openAttribute)
+ {
+ IndentingOverriden = true;
+ CloseStartElement ();
+ }
+ if (!openXmlLang && !openXmlSpace)
+ w.Write (text);
+ else
+ {
+ if (openXmlLang)
+ xmlLang = text;
+ else
+ {
+ switch (text)
+ {
+ case "default":
+ xmlSpace = XmlSpace.Default;
+ break;
+ case "preserve":
+ xmlSpace = XmlSpace.Preserve;
+ break;
+ default:
+ throw new ArgumentException ("'{0}' is an invalid xml:space value.");
+ }
+ }
+ }
+ }
+ }
+
+ [MonoTODO]
+ public override void WriteSurrogateCharEntity (char lowChar, char highChar)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override void WriteWhitespace (string ws)
+ {
+ foreach (char c in ws) {
+ if ((c != ' ') && (c != '\t') && (c != '\r') && (c != '\n'))
+ throw new ArgumentException ();
+ }
+
+ w.Write (ws);
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlTextWriterOpenElement.cs b/mcs/class/System.XML/System.Xml/XmlTextWriterOpenElement.cs
new file mode 100644
index 00000000000..1f0f63aae3d
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlTextWriterOpenElement.cs
@@ -0,0 +1,72 @@
+//
+// System.Xml.XmlTextWriterOpenElement
+//
+// Author:
+// Kral Ferch <kral_ferch@hotmail.com>
+//
+// (C) 2002 Kral Ferch
+//
+//
+// Scope support for XmlLang and XmlSpace in XmlTextWriter.
+//
+using System;
+
+namespace System.Xml
+{
+ internal class XmlTextWriterOpenElement
+ {
+ #region Fields
+
+ string name;
+ string xmlLang;
+ XmlSpace xmlSpace;
+ bool indentingOverriden = false;
+
+ #endregion
+
+ #region Constructors
+
+ public XmlTextWriterOpenElement (string name)
+ {
+ this.name = name;
+ }
+
+ #endregion
+
+ #region Properties
+
+ public string Name
+ {
+ get { return name; }
+ }
+
+ public bool IndentingOverriden
+ {
+ get { return indentingOverriden; }
+ set { indentingOverriden = value; }
+ }
+
+ public string XmlLang
+ {
+ get { return xmlLang; }
+ set { xmlLang = value; }
+ }
+
+ public XmlSpace XmlSpace
+ {
+ get { return xmlSpace; }
+ set { xmlSpace = value; }
+ }
+
+ #endregion
+
+ #region Methods
+
+ public override string ToString ()
+ {
+ return name;
+ }
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlTokenizedType.cs b/mcs/class/System.XML/System.Xml/XmlTokenizedType.cs
new file mode 100755
index 00000000000..13762770ce6
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlTokenizedType.cs
@@ -0,0 +1,27 @@
+//
+// System.Xml.XmlTokenizedType.cs
+//
+// Author: Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+namespace System.Xml
+{
+ [Serializable] public enum XmlTokenizedType
+ {
+ CDATA = 0,
+ ID = 1,
+ IDREF = 2,
+ IDREFS = 3,
+ ENTITY = 4,
+ ENTITIES = 5,
+ NMTOKEN = 6,
+ NMTOKENS = 7,
+ NOTATION = 8,
+ ENUMERATION = 9,
+ QName = 10,
+ NCName = 11,
+ None = 12,
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlUrlResolver.cs b/mcs/class/System.XML/System.Xml/XmlUrlResolver.cs
new file mode 100755
index 00000000000..54750bb6f60
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlUrlResolver.cs
@@ -0,0 +1,41 @@
+// System.Xml.XmlUrlResolver.cs
+//
+// Author: Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+using System.Net;
+
+namespace System.Xml
+{
+ public class XmlUrlResolver : XmlResolver
+ {
+ // Field
+ ICredentials credential;
+
+ // Constructor
+ public XmlUrlResolver ()
+ : base ()
+ {
+ }
+
+ // Properties
+ public override ICredentials Credentials
+ {
+ set { credential = value; }
+ }
+
+ // Methods
+ [MonoTODO]
+ public override object GetEntity (Uri absoluteUri, string role, Type ofObjectToReturn)
+ {
+ return null;
+ }
+
+ public override Uri ResolveUri (Uri baseUri, string relativeUri)
+ {
+ return new Uri (baseUri, relativeUri);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlValidatingReader.cs b/mcs/class/System.XML/System.Xml/XmlValidatingReader.cs
new file mode 100644
index 00000000000..330793f55ad
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlValidatingReader.cs
@@ -0,0 +1,341 @@
+//
+// System.Xml.XmlValidatingReader.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+using System.IO;
+using System.Text;
+using System.Xml.Schema;
+
+namespace System.Xml {
+ public class XmlValidatingReader : XmlReader, IXmlLineInfo {
+
+ #region Fields
+
+ EntityHandling entityHandling;
+ bool namespaces;
+ XmlReader reader;
+ ValidationType validationType;
+
+ #endregion // Fields
+
+ #region Constructors
+
+ [MonoTODO]
+ public XmlValidatingReader (XmlReader reader)
+ : base ()
+ {
+ if (!(reader is XmlTextReader))
+ throw new ArgumentException ();
+
+ this.reader = reader;
+ entityHandling = EntityHandling.ExpandEntities;
+ namespaces = true;
+ validationType = ValidationType.Auto;
+ }
+
+ [MonoTODO]
+ public XmlValidatingReader (Stream xmlFragment, XmlNodeType fragType, XmlParserContext context)
+ : this (new XmlTextReader (xmlFragment))
+ {
+ }
+
+ public XmlValidatingReader (string xmlFragment, XmlNodeType fragType, XmlParserContext context)
+ : this (new XmlTextReader (xmlFragment))
+ {
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public override int AttributeCount {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public override string BaseURI {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public override bool CanResolveEntity {
+ get { return true; }
+ }
+
+ public override int Depth {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public Encoding Encoding {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public EntityHandling EntityHandling {
+ get { return entityHandling; }
+ set { entityHandling = value; }
+ }
+
+ public override bool EOF {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public override bool HasValue {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public override bool IsDefault {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public override bool IsEmptyElement {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public override string this [int i] {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public override string this [string name] {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public override string this [string localName, string namespaceName] {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ int IXmlLineInfo.LineNumber {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ int IXmlLineInfo.LinePosition {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public override string LocalName {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public override string Name {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public bool Namespaces {
+ get { return namespaces; }
+ set { namespaces = value; }
+ }
+
+ public override string NamespaceURI {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public override XmlNameTable NameTable {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public override XmlNodeType NodeType {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public override string Prefix {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public override char QuoteChar {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public XmlReader Reader {
+ get { return reader; }
+ }
+
+ public override ReadState ReadState {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public XmlSchemaCollection Schemas {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public object SchemaType {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public ValidationType ValidationType {
+ get { return validationType; }
+ [MonoTODO ("Need to check for exception.")]
+ set { validationType = value; }
+ }
+
+ public override string Value {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public override string XmlLang {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ public XmlResolver XmlResolver {
+ [MonoTODO]
+ set { throw new NotImplementedException (); }
+ }
+
+ public override XmlSpace XmlSpace {
+ [MonoTODO]
+ get { throw new NotImplementedException (); }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ [MonoTODO]
+ public override void Close ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override string GetAttribute (int i)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override string GetAttribute (string name)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override string GetAttribute (string localName, string namespaceName)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ bool IXmlLineInfo.HasLineInfo ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override string LookupNamespace (string prefix)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override void MoveToAttribute (int i)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override bool MoveToAttribute (string name)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override bool MoveToAttribute (string localName, string namespaceName)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override bool MoveToElement ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override bool MoveToFirstAttribute ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override bool MoveToNextAttribute ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override bool Read ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override bool ReadAttributeValue ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override string ReadInnerXml ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override string ReadOuterXml ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override string ReadString ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public object ReadTypedValue ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override void ResolveEntity ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+
+ #region Events and Delegates
+
+ public event ValidationEventHandler ValidationEventHandler;
+
+ #endregion // Events and Delegates
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlWhitespace.cs b/mcs/class/System.XML/System.Xml/XmlWhitespace.cs
new file mode 100644
index 00000000000..ba1013c6683
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlWhitespace.cs
@@ -0,0 +1,72 @@
+//
+// System.Xml.XmlWhitespace.cs
+//
+// Author:
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+using System.Xml.XPath;
+
+namespace System.Xml
+{
+ public class XmlWhitespace : XmlCharacterData
+ {
+ // Constructor
+ protected internal XmlWhitespace (string strData, XmlDocument doc)
+ : base (strData, doc)
+ {
+ }
+
+ // Properties
+ public override string LocalName {
+ get { return "#whitespace"; }
+ }
+
+ public override string Name {
+ get { return "#whitespace"; }
+ }
+
+ public override XmlNodeType NodeType {
+ get { return XmlNodeType.Whitespace; }
+ }
+
+ internal override XPathNodeType XPathNodeType {
+ get { return XPathNodeType.Whitespace; }
+ }
+
+ public override string Value {
+ get { return Data; }
+ set {
+ if (IsValidWhitespaceChar (value) == false)
+ throw new ArgumentException ("Invalid whitespace characters.");
+ Data = value;
+ }
+ }
+
+ // Methods
+ public override XmlNode CloneNode (bool deep)
+ {
+ // always return the data value
+ return new XmlWhitespace (Data, OwnerDocument);
+ }
+
+ public override void WriteContentTo (XmlWriter w) {}
+
+ public override void WriteTo (XmlWriter w)
+ {
+ if(OwnerDocument.PreserveWhitespace)
+ w.WriteWhitespace (Data);
+ }
+
+ private bool IsValidWhitespaceChar (string text)
+ {
+ foreach (char c in text)
+ if ((c != ' ') && (c != '\r') && (c != '\n') && (c != '\t'))
+ return false;
+ return true;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlWriter.cs b/mcs/class/System.XML/System.Xml/XmlWriter.cs
new file mode 100644
index 00000000000..0bd2412a084
--- /dev/null
+++ b/mcs/class/System.XML/System.Xml/XmlWriter.cs
@@ -0,0 +1,258 @@
+//
+// System.Xml.XmlTextWriter
+//
+// Author:
+// Kral Ferch <kral_ferch@hotmail.com>
+//
+// (C) 2002 Kral Ferch
+//
+
+using System;
+
+namespace System.Xml
+{
+ public abstract class XmlWriter
+ {
+ #region Fields
+
+ protected WriteState ws = WriteState.Start;
+ protected XmlNamespaceManager namespaceManager = new XmlNamespaceManager (new NameTable ());
+
+ #endregion
+
+ #region Constructors
+
+ protected XmlWriter () { }
+
+ #endregion
+
+ #region Properties
+
+ public abstract WriteState WriteState { get; }
+
+ public abstract string XmlLang { get; }
+
+ public abstract XmlSpace XmlSpace { get; }
+
+ #endregion
+
+ #region Methods
+
+ public abstract void Close ();
+
+ public abstract void Flush ();
+
+ public abstract string LookupPrefix (string ns);
+
+ [MonoTODO("DTDs must be implemented to use 'defattr' parameter.")]
+ public virtual void WriteAttributes (XmlReader reader, bool defattr)
+ {
+ if(reader == null)
+ throw new ArgumentException("null XmlReader specified.", "reader");
+
+ switch(reader.NodeType)
+ {
+ case XmlNodeType.XmlDeclaration:
+ // this method doesn't write "<?xml " and "?>", at least MS .NET Framework as yet.
+ XmlDeclaration decl = new XmlDeclaration("1.0", String.Empty, String.Empty, null);
+ decl.Value = reader.Value;
+ if(decl.Version != null && decl.Version != String.Empty) WriteAttributeString("version", decl.Version);
+ if(decl.Encoding != null && decl.Encoding != String.Empty) WriteAttributeString("encoding", decl.Encoding);
+ if(decl.Standalone != null && decl.Standalone != String.Empty) WriteAttributeString("standalone", decl.Standalone);
+ break;
+ case XmlNodeType.Element:
+ while (reader.MoveToNextAttribute ())
+ {
+ WriteAttributeString(reader.Prefix, reader.LocalName, reader.NamespaceURI, reader.Value);
+ }
+ break;
+ case XmlNodeType.Attribute:
+ do
+ {
+ WriteAttributeString(reader.Prefix, reader.LocalName, reader.NamespaceURI, reader.Value);
+ }
+ while (reader.MoveToNextAttribute ()) ;
+ break;
+ default:
+ throw new XmlException("NodeType is not one of Element, Attribute, nor XmlDeclaration.");
+ }
+ }
+
+ public void WriteAttributeString (string localName, string value)
+ {
+ WriteAttributeString ("", localName, "", value);
+ }
+
+ public void WriteAttributeString (string localName, string ns, string value)
+ {
+ WriteAttributeString ("", localName, ns, value);
+ }
+
+ public void WriteAttributeString (string prefix, string localName, string ns, string value)
+ {
+ if ((prefix == "xmlns") || (localName == "xmlns"))
+ {
+ ns = value;
+
+ if (prefix == "xmlns" && namespaceManager.HasNamespace (localName))
+ return;
+
+ /* Users need to be able to re-declare the default namespace for subnodes
+ else if (localName == "xmlns" && namespaceManager.HasNamespace (String.Empty))
+ return;
+ */
+ }
+
+ WriteStartAttribute (prefix, localName, ns);
+ WriteString (value);
+ WriteEndAttribute ();
+
+ if ((prefix == "xmlns") || (localName == "xmlns"))
+ {
+ if (prefix == "xmlns")
+ namespaceManager.AddNamespace (localName, ns);
+ else
+ namespaceManager.AddNamespace ("", ns);
+ }
+
+ }
+
+ public abstract void WriteBase64 (byte[] buffer, int index, int count);
+
+ public abstract void WriteBinHex (byte[] buffer, int index, int count);
+
+ public abstract void WriteCData (string text);
+
+ public abstract void WriteCharEntity (char ch);
+
+ public abstract void WriteChars (char[] buffer, int index, int count);
+
+ public abstract void WriteComment (string text);
+
+ public abstract void WriteDocType (string name, string pubid, string sysid, string subset);
+
+ public void WriteElementString (string localName, string value)
+ {
+ WriteStartElement(localName);
+ WriteString(value);
+ WriteEndElement();
+ }
+
+ public void WriteElementString (string localName, string ns, string value)
+ {
+ WriteStartElement(localName, ns);
+ WriteString(value);
+ WriteEndElement();
+ }
+
+ public abstract void WriteEndAttribute ();
+
+ public abstract void WriteEndDocument ();
+
+ public abstract void WriteEndElement ();
+
+ public abstract void WriteEntityRef (string name);
+
+ public abstract void WriteFullEndElement ();
+
+ public abstract void WriteName (string name);
+
+ public abstract void WriteNmToken (string name);
+
+ [MonoTODO("needs to test")]
+ public virtual void WriteNode (XmlReader reader, bool defattr)
+ {
+ if (reader == null)
+ throw new ArgumentException ();
+
+ if (reader.ReadState == ReadState.Initial) {
+ while (reader.Read ())
+ WriteNode (reader, defattr);
+ }
+ else {
+ switch (reader.NodeType) {
+ case XmlNodeType.Element:
+ WriteStartElement (reader.Prefix, reader.LocalName, reader.NamespaceURI);
+ WriteAttributes (reader, defattr);
+ if (reader.IsEmptyElement)
+ WriteEndElement ();
+ break;
+ case XmlNodeType.Attribute:
+ break;
+ case XmlNodeType.Text:
+ WriteString (reader.Value);
+ break;
+ case XmlNodeType.CDATA:
+ WriteCData (reader.Value);
+ break;
+ case XmlNodeType.EntityReference:
+ WriteEntityRef (reader.Name);
+ break;
+ case XmlNodeType.ProcessingInstruction:
+ WriteProcessingInstruction (reader.Name, reader.Value);
+ break;
+ case XmlNodeType.Comment:
+ WriteComment (reader.Value);
+ break;
+ case XmlNodeType.DocumentType:
+ WriteDocType (reader.Name,
+ reader ["PUBLIC"], reader ["SYSTEM"], reader.Value);
+ break;
+ case XmlNodeType.SignificantWhitespace:
+ goto case XmlNodeType.Whitespace;
+ case XmlNodeType.Whitespace:
+ WriteWhitespace (reader.Value);
+ break;
+ case XmlNodeType.EndElement:
+ break;
+ case XmlNodeType.EndEntity:
+ break;
+ case XmlNodeType.XmlDeclaration:
+ WriteStartDocument (reader.GetAttribute ("standalone").ToLower () == "yes");
+ break;
+ default:
+ throw new NotImplementedException ();
+ }
+ }
+ }
+
+ public abstract void WriteProcessingInstruction (string name, string text);
+
+ public abstract void WriteQualifiedName (string localName, string ns);
+
+ public abstract void WriteRaw (string data);
+
+ public abstract void WriteRaw (char[] buffer, int index, int count);
+
+ public void WriteStartAttribute (string localName, string ns)
+ {
+ WriteStartAttribute (null, localName, ns);
+ }
+
+ public abstract void WriteStartAttribute (string prefix, string localName, string ns);
+
+ public abstract void WriteStartDocument ();
+
+ public abstract void WriteStartDocument (bool standalone);
+
+ public void WriteStartElement (string localName)
+ {
+ WriteStartElement (null, localName, null);
+ }
+
+ public void WriteStartElement (string localName, string ns)
+ {
+ WriteStartElement (null, localName, ns);
+ }
+
+ public abstract void WriteStartElement (string prefix, string localName, string ns);
+
+ public abstract void WriteString (string text);
+
+ public abstract void WriteSurrogateCharEntity (char lowChar, char highChar);
+
+ public abstract void WriteWhitespace (string ws);
+
+ #endregion
+ }
+}
diff --git a/mcs/class/System.XML/Test/.cvsignore b/mcs/class/System.XML/Test/.cvsignore
new file mode 100644
index 00000000000..136fcca0890
--- /dev/null
+++ b/mcs/class/System.XML/Test/.cvsignore
@@ -0,0 +1,4 @@
+*.dll
+*.csproj.user
+bin
+obj
diff --git a/mcs/class/System.XML/Test/AllTests.cs b/mcs/class/System.XML/Test/AllTests.cs
new file mode 100644
index 00000000000..4c158627fed
--- /dev/null
+++ b/mcs/class/System.XML/Test/AllTests.cs
@@ -0,0 +1,52 @@
+// Author:
+// Mario Martinez (mariom925@home.com)
+//
+// (C) Ximian, Inc. http://www.ximian.com
+//
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+ /// <summary>
+ /// Combines all unit tests for the System.XML.dll assembly
+ /// into one test suite.
+ /// </summary>
+ public class AllTests : TestCase
+ {
+ public AllTests (string name) : base (name) {}
+
+ public static ITest Suite {
+ get {
+ TestSuite suite = new TestSuite ();
+ suite.AddTest (new TestSuite (typeof (XmlProcessingInstructionTests)));
+ suite.AddTest (new TestSuite (typeof (XmlTextTests)));
+ suite.AddTest (new TestSuite (typeof (XmlTextReaderTests)));
+ suite.AddTest (new TestSuite (typeof (XmlWriterTests)));
+ suite.AddTest (new TestSuite (typeof (XmlTextWriterTests)));
+ suite.AddTest (new TestSuite (typeof (XmlNamespaceManagerTests)));
+ suite.AddTest (new TestSuite (typeof (XmlAttributeTests)));
+ suite.AddTest (new TestSuite (typeof (XmlAttributeCollectionTests)));
+ suite.AddTest (new TestSuite (typeof (XmlDocumentTests)));
+ suite.AddTest (new TestSuite (typeof (XmlDocumentFragmentTests)));
+ suite.AddTest (new TestSuite (typeof (NameTableTests)));
+ suite.AddTest (new TestSuite (typeof (XmlElementTests)));
+ suite.AddTest (new TestSuite (typeof (XmlEntityReferenceTests)));
+ suite.AddTest (new TestSuite (typeof (XmlNodeTests)));
+ suite.AddTest (new TestSuite (typeof (XmlNodeListTests)));
+ suite.AddTest (new TestSuite (typeof (XmlCharacterDataTests)));
+ suite.AddTest (new TestSuite (typeof (XmlCommentTests)));
+ suite.AddTest (new TestSuite (typeof (XmlCDataSectionTests)));
+ suite.AddTest (new TestSuite (typeof (XmlWhitespaceTests)));
+ suite.AddTest (new TestSuite (typeof (XmlSignificantWhitespaceTests)));
+ suite.AddTest (new TestSuite (typeof (XmlDeclarationTests)));
+ suite.AddTest (new TestSuite (typeof (XmlDocumentTypeTests)));
+ suite.AddTest (new TestSuite (typeof (XPathNavigatorTests)));
+ suite.AddTest (new TestSuite (typeof (SelectNodesTests)));
+ suite.AddTest (new TestSuite (typeof (XPathNavigatorMatchesTests)));
+ suite.AddTest (new TestSuite (typeof (XPathNavigatorEvaluateTests)));
+ return suite;
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/Test/ChangeLog b/mcs/class/System.XML/Test/ChangeLog
new file mode 100644
index 00000000000..165b50d8edb
--- /dev/null
+++ b/mcs/class/System.XML/Test/ChangeLog
@@ -0,0 +1,598 @@
+2003-01-19 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlElementTests.cs : added TestWriteToDefaultNamespace test.
+ * XmlNodeTests.cs : added TestGetPrefixOfNamespace test.
+
+2003-01-18 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * added XmlWriterTests.cs file and added it to AllTests.cs
+
+2003-01-13 Nick Drochak <ndrochak@gol.com>
+
+ * XmlNodeTests.cs: MS.NET doesn't throw an exception here.
+
+2003-01-11 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlElementTests.cs : added TestInnerTextAndEvent test.
+ (and many coding style fix.)
+ * XmlTextReaderTests.cs : tiny argument order fix for TestAttributeWithEntityReference test.
+
+2003-01-08 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlDocumentTests.cs : test for attribute value bugfix.
+
+2003-01-08 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlTextReaderTests.cs : test for attribute value bugfix.
+
+2002-01-02 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * SelectNodesTests.cs : added TestAlphabetDigitMixedName.
+
+2002-12-28 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlDocumentTests.cs : Test for bugzilla #34743 (whitespace handling)
+
+2002-12-28 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlDocumentTests.cs : Test for bugzilla #35308 (default ns output)
+ * XmlElementTests.cs : Test for output of attributes with different NS.
+
+2002-12-24 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlDocumentTests.cs, XmlWhitespaceTests.cs:
+ fixed whitespace handling (in relation to Ville's patch).
+
+2002-12-21 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlTextWriterTests.cs (TestAttributeNamespacesXmlnsXmlns):
+ fixed bug in the testcase (in relation to JD Conley's patch).
+
+2002-12-01 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlDeclarationTests.cs (TestValueProperty):
+ applied patch by David Sheldon
+
+2002-11-13 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * AllTests.cs : added XmlEntityReferenceTests
+ * XmlDocumentTests.cs : TestCloneNode, TestDocumentWithDoctypeDecl
+ * XmlDocumentFragmentTests.cs : TestSetInnerXml
+ * XmlEntityReferenceTests.cs : created
+ * XmlTextWriterTests.cs : TestWriteAttributes() bugfix (reusing ctx)
+ * XmlNodeTests.cs : bugfix TestInsertAfter(when refChild = null),
+ added TestPrependChild
+
+2002-11-13 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlAttributeTests.cs : TestSetInnerAndOuterXml
+ * XmlSignificantWhitespaceTests.cs : TestDataAndValue
+
+2002-11-03 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlAttributeCollectionTests.cs : TestSetNamedItem,
+ TestInsertBeforeAfterPrepend, TestRemove
+ * XmlElementTests.cs : TestWriteToWithDeletedNamespacePrefix,
+ TestRemoveAttribute()
+ * XmlDocumentFragmentTests.cs : TestGetInnerXml
+
+2002-10-29 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * XmlElementTests.cs : added an Assert InnerXml with element content.
+ * XmlNodeTests.cs : TestInsertBefore() and TestInsertAfter()
+
+2002-10-28 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+
+ * added XmlDocumentFragmentTests.cs
+ (including AllTests.cs and System.XML_linux_test.args)
+ * XmlDocumentTests.cs: added test of XMLDeclaration to TestImportNode()
+ * XmlElementTests.cs: added check removing children of InnerXml
+
+2002-10-28 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * System.XML_linux_test.args: added XPathNavigatorEvaluateTests.cs
+ * makefile.gnu: pass MONO_PATH when running the tests.
+
+2002-10-24 Nick Drochak <ndrochak@gol.com>
+
+ * System.XML_test.build: remove legacy build of a standalone exe of the
+ unit tests
+ * XmlDocumentTests.cs: Cannot use a URI with Load().
+
+2002-10-23 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * XmlTextReaderTests.cs: fixed TestEntityReferenceInsideText.
+
+2002-10-22 Nick Drochak <ndrochak@gol.com>
+
+ * XmlTextWriterTests.cs: Null is ok when prefix is "xmlns".
+
+2002-10-21 Duncan Mak <duncan@ximian.com>
+
+ * XmlTextReaderTests.cs:
+ * XmlElementTests.cs:
+ * XmlDocumentTests.cs: Patches from Atsushi Enomoto
+ <ginga@kit.hi-ho.ne.jp>.
+
+2002-10-18 Duncan Mak <duncan@ximian.com>
+
+ * XmlDocumentTests.cs: Apply a patch from Atsushi Enomoto
+ <ginga@kit.hi-ho.ne.jp>.
+
+2002-09-29 Nick Drochak <ndrochak@gol.com>
+
+ * XmlTextReaderTest.cs (AssertEndDocument): Add messages for Asserts()
+ so we can tell where this is failing.
+
+2002-09-19 Matt Hunter <mahunter@tconl.com>
+
+ * XmlElementTests.cs: Test for SetAttributeNode(localName, namespaceURI) added.
+ * XmlAttributeCollectionTests.cs: added TestAppend().
+
+2002-09-17 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XPathNavigatorEvaluateTests.cs: Tests for string(), concat(),
+ starts-with(), and contains().
+
+2002-09-12 Piers Haken <piersh@friskit.com>
+
+ * XPathNavigatorEvaluateTests.cs: enable string() tests.
+
+2002-09-12 Piers Haken <piersh@friskit.com>
+
+ * XPathNavigatorEvaluateTests.cs: enable last() & count() tests.
+
+2002-09-11 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XPathNavigatorEvaluateTests.cs: Added tests for
+ local-name, namespace-uri, and string.
+
+2002-09-11 Kral Ferch <kral_ferch@hotmail.com>
+
+ * Added XPathNavigatorEvaluateTests.cs file to
+ the MonoMicro.Test project.
+
+ * XPathNavigatorEvaluateTests.cs: New file.
+
+ * AllTests.cs: Added XPathNavigatorEvaluateTests suite.
+
+ * XmlDocumentTests: Added space between namespace decls in
+ TestGetElementsByTagNameUsingNameSpace. Was causing error
+ when testing against Microsoft assembly.
+
+ * XmlElementTests: Added space between namespace decls in
+ TestGetElementsByTagNameUsingNameSpace. Was causing error
+ when testing against Microsoft assembly.
+
+2002-09-06 Kral Ferch <kral_ferch@hotmail.com>
+
+ * Added XPathNavigatorMatchesTests.cs file to
+ the MonoMicro.Test project.
+
+2002-08-22 Jason Diamond <jason@injektilo.org>
+
+ * AllTests.cs, System.XML_linux_test.args,
+ XmlAttributeCollectionTests.cs,XmlElementTests.cs: Added test for
+ RemoveAll and RemoveAllAttributes courtesy of Matt Hunter
+ <xrkune@tconl.com>.
+
+2002-08-22 Jason Diamond <jason@injektilo.org>
+
+ * XmlElementTests.cs: Correction to previous GetElementsByTagName
+ patch courtesy of Matt Hunter <xrkune@tconl.com>.
+
+2002-08-22 Jason Diamond <jason@injektilo.org>
+
+ * XmlDocumentTests.cs, XmlElementTests.cs: Added tests for
+ namespace qualified GetElementsByTagName courtesy of Matt Hunter
+ <xrkune@tconl.com>.
+
+2002-08-19 Jason Diamond <jason@injektilo.org>
+
+ * XmlDocumentTests.cs, XmlElementTests.cs: Added tests for
+ GetElementsByTagName courtesy of Matt Hunter <xrkune@tconl.com>.
+
+2002-08-17 Jason Diamond <jason@injektilo.org>
+
+ * XPathNavigatorMatchesTests.cs: Added tests for absolute patterns
+ and patterns with predicates.
+
+2002-08-17 Jason Diamond <jason@injektilo.org>
+
+ * AllTests.cs: Added XPathNavigatorMatchesTests suite.
+
+ * XPathNavigatorMatchesTests.cs: Added.
+
+2002-08-16 Jason Diamond <jason@injektilo.org>
+
+ * XmlElementTests.cs: Added test for OuterXml (and WriteTo) for
+ qualified elements.
+
+2002-08-16 Jason Diamond <jason@injektilo.org>
+
+ * makefile.gnu: Added SOURCES_INCLUDE and SOURCES_EXCLUDE variables
+ to get tests to build with the new build system.
+
+2002-08-10 Jason Diamond <jason@injektilo.org>
+
+ * makefile.gnu: Use relative path to NUnitConsole_mono.exe instead of
+ hardcoding it to /usr/local/bin. Default test suite to AllTests but
+ allow it to be overridden from the command line.
+
+ * XmlTextWriterTests.cs: Split TestWriteString into multiple tests.
+ Added encoding parameters to all the StreamReaders in
+ TestBaseConstructorsAndBaseStream. I think this is a bug in Mono's
+ StreamReader since these aren't required when testing against
+ Microsoft's.
+
+2002-08-08 Jason Diamond <jason@injektilo.org>
+
+ * System.XML_linux_test.args: Added Kral's new test classes.
+
+2002-08-07 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlCharacterDataTests.cs: New file.
+
+ * XmlNodeTests.cs: New file.
+
+ * AllTests.cs: Added XmlCharacterDataTests and XmlNodeTests.
+
+ * XmlDocumentTests.cs: Added tests for NodeChanging, NodeChanged,
+ NodeInserting, NodeInserted, NodeRemoving, and NodeRemoved events.
+
+2002-08-03 Jason Diamond <jason@injektilo.org>
+
+ * makefile.gnu: Added.
+
+ * System.XML_linux_test.args: Added.
+
+2002-07-12 Piers Haken <piersh@friskit.com
+
+ * SelectNodesTests.cs: Added TestUnion (bug #27548)
+
+2002-07-11 Jason Diamond <jason@injektilo.org>
+
+ * SelectNodesTests.cs: Added.
+
+ * AllTests.cs: Added SelectNodesTests to suite.
+
+2002-07-11 Piers Haken <piersh@friskit.com>
+
+ * XmlElementTests.cs: added TestCreateElement3WithNullNamespace
+
+2002-06-24 Jason Diamond <jason@injektilo.org>
+
+ * XPathScannerTests.cs: Removed.
+
+ * System.XML_test.build: Removed tests for XPathScanner.
+
+2002-05-27 Jason Diamond <jason@injektilo.org>
+
+ * XPathNavigatorTests.cs: Added file to directory.
+
+ * AllTests.cs: Added XPathNavigatorTests to suite.
+
+ * XmlTextReaderTests.cs: Added test to make sure attributes are ordered
+ like Microsoft's parser does it.
+
+2002-05-05 Nick Drochak <ndrochak@gol.com>
+
+ * ChangeLog: Update build file to run correct class in the test dll.
+
+2002-05-05 Nick Drochak <ndrochak@gol.com>
+
+ * AllTests.cs
+ * NameTableTests.cs
+ * TheTests.cs
+ * XPathScannerTests.cs
+ * XmlAttributeTests.cs
+ * XmlCDataSectionTests.cs
+ * XmlCommentTests.cs
+ * XmlDeclarationTests.cs
+ * XmlDocumentTests.cs
+ * XmlDocumentTypeTests.cs
+ * XmlElementTests.cs
+ * XmlNamespaceManagerTests.cs
+ * XmlNodeListTests.cs
+ * XmlProcessingInstructionTests.cs
+ * XmlSignificantWhitespaceTests.cs
+ * XmlTextReaderTests.cs
+ * XmlTextTests.cs
+ * XmlTextWriterTests.cs
+ * XmlWhiteSpaceTests.cs: Use same namespace style as corlib tests.
+ Changed Ximian.Mono.Tests to MonoTests.System.Xml
+
+2002-04-08 Kral Ferch <kral_ferch@hotmail.com>
+
+ * AllTests.cs: added XmlProcessingInstructionTests and XmlTextTests.
+
+ * MonoMicro.Test.csproj: Added XmlProcessingInstructionTests.cs and
+ XmlTextTests.cs.
+
+ * XmlAttributeTests.cs: Added TestAttributeInnerAndOuterXml.
+
+ * XmlCDataSectionTests.cs: Added TestXmlCDataSectionInnerAndOuterXml.
+
+ * XmlCommentTests.cs: Added TestXmlCommentInnerAndOuterXml.
+
+ * XmlDeclarationTests.cs: Added TestInnerAndOuterXml.
+
+ * XmlDocumentTests.cs: Added TestInnerAndOuterXml.
+
+ * XmlElementTests.cs: Added TestInnerAndOuterXml.
+
+ * XmlProcessingInstructionTests.cs: Initial check-in.
+
+ * XmlSignificantWhitespaceTests.cs: Added TestInnerAndOuterXml.
+
+ * XmlTextTests.cs: Initial check-in.
+
+ * XmlTextWriterTests.cs: Added TestWriteRaw, TestWriteRawInvalidInAttribute,
+ and TestXmlSpaceRaw.
+
+ * XmlWhiteSpacesTests.cs: Added TestInnerAndOuterXml.
+
+2002-04-05 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlDocumentTests.cs: CreateNode tests.
+
+2002-04-01 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlTextWriterTests.cs: Tests for WriteEndDocument and WriteFullEndElement.
+
+2002-03-31 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlTextWriterTests.cs: Tests for LookupPrefix, WriteBase64,
+ and WriteCharEntity.
+
+2002-03-31 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlTextWriterTests.cs: Finished XmlLang, XmlSpace, and
+ Attribute namespace declaration tests.
+
+2002-03-29 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlTextWriterTests.cs: XmlLang and XmlSpace tests.
+
+2002-03-29 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlTextWriterTests.cs: Working on Attributes.
+
+2002-03-28 Duncan Mak <duncan@ximian.com>
+
+ * XmlDeclarationTests.cs (TestConstructor):
+ * XmlDocumentTypeTests.cs (TestAppendChild):
+ * XmlSignificantWhitespaceTests.cs (TestXmlWhitespaceConstructor):
+ * XmlWhiteSpaceTests.cs (TestXmlWhitespaceConstructor): Fixed the
+ test for catching Exceptions.
+
+2002-03-26 Jason Diamond <jason@injektilo.org>
+
+ * AllTests.cs:
+ * Mono.Test.csproj: Removed XPathScanner tests.
+
+ * System.XML_test.build: Test XPathScanner separately.
+
+2002-03-26 Duncan Mak <duncan@ximian.com>
+
+ * AllTests.cs:
+ * Microsoft.Test.csproj:
+ * Mono.Test.csproj: Updated to include new test,
+ XmlDocumentTypeTests.
+
+ * XmlDocumentTypeTests.cs: New testsuite for XmlDocumentType class.
+
+ * XmlCommentTests.cs (TestXmlNodeBaseProperties): Move the
+ XmlNode.Value test in here.
+
+2002-03-26 Jason Diamond <jason@injektilo.org>
+
+ * XPathScannerTests.cs: More location path tests.
+
+2002-03-25 Jason Diamond <jason@injektilo.org>
+
+ * AllTests.cs:
+ * Microsoft.Test.csproj:
+ * Mono.Test.csproj: Updated to include new test, XmlScannerTests.
+
+ * XPathScannerTests.cs: Added new tests for XPathScanner class.
+
+2002-03-25 Duncan Mak <duncan@ximian.com>
+
+ * AllTests.cs:
+ * Microsoft.Test.csproj:
+ * Mono.Test.csproj: Updated to include new test,
+ XmlDeclarationTests.
+
+ * XmlDeclarationTests.cs: Added new test for XmlDeclaration class.
+
+2002-03-23 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlTextWriterTests.cs: Tests for BaseStream,
+ Namespaces = false, and WriteState.
+
+2002-03-23 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlTextWriterTests.cs: constructor tests with
+ different encodings to test that encoding gets suppressed
+ on xml declaration when null stream passed to constructor.
+ WriteStartDocument(standalone) tests. Tests for formatting
+ and indentation. Test for invalid value set on QuoteChar.
+
+2002-03-22 Duncan Mak <duncan@ximian.com>
+
+ * AllTests.cs:
+ * Microsoft.Test.csproj:
+ * Mono.Test.csproj: Updated to include new files.
+
+ * XmlCDataSectionTests.cs: Added to CVS.
+
+ * XmlCommentTests.cs: Added to CVS. hanks to Kral for helping me
+ setup a testing environment on VS.NET.
+
+ * XmlElementTests.cs: Reformatted.
+ (TestCloneNode): Added.
+
+ * XmlSignificantWhitespaceTests.cs: Added to CVS.
+
+ * XmlWhiteSpaceTests.cs: Added to CVS.
+
+2002-03-21 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlDocumentTests.cs: Tessts parent traversal up through
+ document itself until null. Tests a removed elements next
+ sibling is null.
+
+ * XmlNodeListTests.cs: Tests case where enumerator is on
+ a node that gets removed from list.
+
+ * XmlTextWriterTests.cs: Keeping tests for WriteXXX after
+ writer is closed up to date as new WriteXXX methods are written.
+ TestDocumentStart and TestWriteEndElement.
+
+2002-03-19 Jason Diamond <jason@injektilo.org>
+
+ * XmlDocumentTests.cs: Added a test to check an element's names after
+ loading.
+
+2002-03-17 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlDocumentTests.cs: Tests navigation to parents since
+ that was part of a document.Load() bug reported by Mike Kestner.
+
+ * XmlTextWriterTests.cs: Tests for namespaces and prefixes.
+
+2002-03-17 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlDocumentTests.cs: TestOuterXml.
+
+ * XmlTextWriterTests.cs: Tests for CData, Close, Comment, Element,
+ and ProcessingInstruction.
+
+2002-03-17 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlDocumentTests.cs: More LoadXml tests.
+
+ * XmlTextWriterTests.cs: Test for invalid Processing Instructions.
+
+2002-03-14 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlTextWriterTests.cs: Added tests TestCData and TestComment.
+
+2002-03-14 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlTextWriterTests.cs: Initial checkin.
+
+2002-03-12 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlNodeListTests.cs: New tests: TestNodeTypesThatCantHaveChildren,
+ TestZeroChildren, TestOneChild, TestMultipleChildren,
+ TestAppendChildAffectOnEnumeration, TestRemoveChildAffectOnEnumeration,
+ TestRemoveOnlyChildAffectOnEnumeration, TestCurrentBeforeFirstNode,
+ TestCurrentAfterLastNode, TestCurrentDoesntMove, and TestReset. Made
+ two other tests but not in use yet until RemoveAll is implemented for
+ attributes and XmlNode.ReplaceChild is implemented. The tests are called
+ saveTestReplaceChildAffectOnEnumeration and saveTestRemoveAllAffectOnEnumeration.
+
+2002-03-08 Jason Diamond <jason@injektilo.org>
+
+ * XmlTextReaderTests.cs: Test MoveToElement and MoveToFirstAttribute.
+
+2002-03-08 Jason Diamond <jason@injektilo.org>
+
+ * XmlAttributeTests.cs: Test XmlAttribute child nodes.
+
+2002-03-08 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlNodeListTests.cs: New file.
+
+ * AllTests.cs: Added XmlNodeListTests.
+
+2002/03/08 Nick Drochak <ndrochak@gol.com>
+
+ * System_test.build: Don't build test dll by default. Only build
+ it when 'make test' is specified.
+
+2002-03-06 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlAttributeTests.cs: Fixed bug in TestHasChildNodes test.
+
+ * XmlDocumentTests.cs: Started work on some tests for invalid data in
+ various nodes created by the document.
+
+2002-03-02 Kral Ferch <kral_ferch@hotmail.com>
+
+ * XmlDocumentTests.cs: New tests TestLoadProcessingInstruction(),
+ TestLoadCDATA(), and TestLoadComment().
+
+2002-03-02 Jason Diamond <jason@injektilo.org>
+
+ * XmlElementTests.cs: New file.
+
+ * AllTests.cs: Added XmlElementTests.
+
+2002-03-02 Jason Diamond <jason@injektilo.org>
+
+ * XmlTextReaderTests.cs: Test MoveToNextAttribute().
+
+ * XmlDocumentTests.cs: Test loading document containing attributes
+ and text nodes.
+
+2002-03-02 Mike Kestner <mkestner@speakeasy.net>
+
+ * XmlAttributeTests.cs : New test suite for attrs.
+ * AllTests.cs : Add the attr suite.
+
+2002-03-02 Jason Diamond <jason@injektilo.org>
+
+ * XmlNamespaceManagerTests.cs: Make sure the XmlNamespaceManager
+ is using its name table.
+
+ * NameTableTests.cs: Make sure NameTable is really returning the
+ same references.
+
+2002-02-28 Jason Diamond <jason@injektilo.org>
+
+ * XmlDocumentTests.cs: Tests for XmlDocument.LoadXml courtesy of
+ Kral Ferch <kral.ferch@hotmail.com>.
+
+2002-02-28 Jason Diamond <jason@injektilo.org>
+
+ * XmlTextReaderTests.cs: Test for XmlException when parse fail.
+
+2002-02-27 Martin Baulig <martin@gnome.org>
+
+ * System.XML_test.build: Build new executable RunTests.System.XML.exe
+ which you can use to run the tests on Linux.
+
+ * *.cs: Added zero-args constructors.
+
+2002-02-26 Duncan Mak <duncan@ximian.com>
+
+ * NameTableTests.cs: Test for System.Xml.NameTable.
+
+2002-02-26 Jason Diamond <jason@injektilo.org>
+
+ * XmlTextReaderTests.cs: Test for namespace declarations as
+ attributes.
+
+ * XmlNamespaceManagerTests.cs: Use the newly implemented NameTable
+ when creating the XmlNamespaceManager. Properly test HasNamespace.
+
+2002-02-25 Jason Diamond <jason@injektilo.org>
+
+ * XmlDocumentTests.cs: Added file.
+
+2002-02-23 Jason Diamond <jason@injektilo.org>
+
+ * XmlTextReaderTests.cs: Added tests for qualified attributes.
+
+2002-02-23 Jason Diamond <jason@injektilo.org>
+
+ * ChangeLog: Added change log to this directory.
+
+ * Test.cs: Renamed to XmlTextReaderTests.cs.
+
+ * XmlTextReaderTests.cs: Added tests for NamespaceURI property.
+
+ * XmlNamespaceManagerTests.cs: Initial tests.
diff --git a/mcs/class/System.XML/Test/Microsoft.Test.csproj b/mcs/class/System.XML/Test/Microsoft.Test.csproj
new file mode 100644
index 00000000000..99f1015f00e
--- /dev/null
+++ b/mcs/class/System.XML/Test/Microsoft.Test.csproj
@@ -0,0 +1,162 @@
+<VisualStudioProject>
+ <CSHARP
+ ProjectType = "Local"
+ ProductVersion = "7.0.9466"
+ SchemaVersion = "1.0"
+ ProjectGuid = "{D6C51F53-33E2-41DF-981A-33FCFA81CDA7}"
+ >
+ <Build>
+ <Settings
+ ApplicationIcon = ""
+ AssemblyKeyContainerName = ""
+ AssemblyName = "Microsoft.Test"
+ AssemblyOriginatorKeyFile = ""
+ DefaultClientScript = "JScript"
+ DefaultHTMLPageLayout = "Grid"
+ DefaultTargetSchema = "IE50"
+ DelaySign = "false"
+ OutputType = "Library"
+ RootNamespace = "Test"
+ StartupObject = ""
+ >
+ <Config
+ Name = "Debug"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "DEBUG;TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "true"
+ FileAlignment = "4096"
+ IncrementalBuild = "true"
+ Optimize = "false"
+ OutputPath = "bin\Debug\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ <Config
+ Name = "Release"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "false"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ Optimize = "true"
+ OutputPath = "bin\Release\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ </Settings>
+ <References>
+ <Reference
+ Name = "System"
+ AssemblyName = "System"
+ HintPath = "..\..\..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.dll"
+ />
+ <Reference
+ Name = "System.XML"
+ AssemblyName = "System.Xml"
+ HintPath = "..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.XML.dll"
+ />
+ <Reference
+ Name = "NUnitCore"
+ AssemblyName = "NUnitCore"
+ HintPath = "..\..\..\nunit\NUnitCore.dll"
+ />
+ </References>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "AllTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "ChangeLog"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "NameTableTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlAttributeTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlCDataSectionTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlCommentTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlDeclarationTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlDocumentTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlDocumentTypeTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlElementTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlNamespaceManagerTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlNodeListTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlSignificantWhitespaceTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlTextReaderTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlTextWriterTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlWhiteSpaceTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ </Include>
+ </Files>
+ </CSHARP>
+</VisualStudioProject>
+
diff --git a/mcs/class/System.XML/Test/Mono.Test.csproj b/mcs/class/System.XML/Test/Mono.Test.csproj
new file mode 100644
index 00000000000..677a5b82388
--- /dev/null
+++ b/mcs/class/System.XML/Test/Mono.Test.csproj
@@ -0,0 +1,167 @@
+<VisualStudioProject>
+ <CSHARP
+ ProjectType = "Local"
+ ProductVersion = "7.0.9466"
+ SchemaVersion = "1.0"
+ ProjectGuid = "{D6C51F53-33E2-41DF-981A-33FCFA81CDA7}"
+ >
+ <Build>
+ <Settings
+ ApplicationIcon = ""
+ AssemblyKeyContainerName = ""
+ AssemblyName = "Mono.Test"
+ AssemblyOriginatorKeyFile = ""
+ DefaultClientScript = "JScript"
+ DefaultHTMLPageLayout = "Grid"
+ DefaultTargetSchema = "IE50"
+ DelaySign = "false"
+ OutputType = "Library"
+ RootNamespace = "Test"
+ StartupObject = ""
+ >
+ <Config
+ Name = "Debug"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "DEBUG;TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "true"
+ FileAlignment = "4096"
+ IncrementalBuild = "true"
+ Optimize = "false"
+ OutputPath = "bin\Debug\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ <Config
+ Name = "Release"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "false"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ Optimize = "true"
+ OutputPath = "bin\Release\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ </Settings>
+ <References>
+ <Reference
+ Name = "System"
+ AssemblyName = "System"
+ HintPath = "..\..\..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.dll"
+ />
+ <Reference
+ Name = "Mono.System.XML"
+ Project = "{0CB7FB41-3C0F-40E8-ACD3-8C5B8BC35B2C}"
+ Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
+ />
+ <Reference
+ Name = "NUnitCore"
+ AssemblyName = "NUnitCore"
+ HintPath = "..\..\..\nunit\NUnitCore.dll"
+ />
+ <Reference
+ Name = "System.Data"
+ AssemblyName = "System.Data"
+ HintPath = "..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.Data.dll"
+ />
+ </References>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "AllTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "ChangeLog"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "NameTableTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlAttributeTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlCDataSectionTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlCommentTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlDeclarationTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlDocumentTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlDocumentTypeTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlElementTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlNamespaceManagerTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlNodeListTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlSignificantWhitespaceTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlTextReaderTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlTextWriterTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlWhiteSpaceTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ </Include>
+ </Files>
+ </CSHARP>
+</VisualStudioProject>
+
diff --git a/mcs/class/System.XML/Test/MonoMicro.Test.csproj b/mcs/class/System.XML/Test/MonoMicro.Test.csproj
new file mode 100644
index 00000000000..88ebbc080a1
--- /dev/null
+++ b/mcs/class/System.XML/Test/MonoMicro.Test.csproj
@@ -0,0 +1,212 @@
+<VisualStudioProject>
+ <CSHARP
+ ProjectType = "Local"
+ ProductVersion = "7.0.9466"
+ SchemaVersion = "1.0"
+ ProjectGuid = "{F7734143-3845-4288-B1CA-FE614FFA70F0}"
+ >
+ <Build>
+ <Settings
+ ApplicationIcon = ""
+ AssemblyKeyContainerName = ""
+ AssemblyName = "MonoMicro.Test"
+ AssemblyOriginatorKeyFile = ""
+ DefaultClientScript = "JScript"
+ DefaultHTMLPageLayout = "Grid"
+ DefaultTargetSchema = "IE50"
+ DelaySign = "false"
+ OutputType = "Library"
+ RootNamespace = "MonoMicro.Test"
+ StartupObject = ""
+ >
+ <Config
+ Name = "Debug"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "DEBUG;TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "true"
+ FileAlignment = "4096"
+ IncrementalBuild = "true"
+ Optimize = "false"
+ OutputPath = "bin\Debug\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ <Config
+ Name = "Release"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "false"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ Optimize = "true"
+ OutputPath = "bin\Release\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ </Settings>
+ <References>
+ <Reference
+ Name = "System"
+ AssemblyName = "System"
+ HintPath = "..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.dll"
+ />
+ <Reference
+ Name = "NUnitCore"
+ AssemblyName = "NUnitCore"
+ HintPath = "..\..\..\nunit\NUnitCore.dll"
+ />
+ <Reference
+ Name = "System.Data"
+ AssemblyName = "System.Data"
+ HintPath = "..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.Data.dll"
+ />
+ <Reference
+ Name = "System.XML"
+ AssemblyName = "System.XML"
+ HintPath = "..\obj\Debug\System.XML.dll"
+ />
+ </References>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "AllTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "ChangeLog"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "NameTableTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "SelectNodesTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlAttributeCollectionTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlAttributeTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlCDataSectionTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlCharacterDataTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlCommentTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlDeclarationTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlDocumentTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlDocumentTypeTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlElementTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlNamespaceManagerTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlNodeListTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlNodeTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlProcessingInstructionTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlSignificantWhitespaceTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlTextReaderTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlTextTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlTextWriterTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XmlWhiteSpaceTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XPathNavigatorEvaluateTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XPathNavigatorMatchesTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "XPathNavigatorTests.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ </Include>
+ </Files>
+ </CSHARP>
+</VisualStudioProject>
+
diff --git a/mcs/class/System.XML/Test/NameTableTests.cs b/mcs/class/System.XML/Test/NameTableTests.cs
new file mode 100755
index 00000000000..ee115132f44
--- /dev/null
+++ b/mcs/class/System.XML/Test/NameTableTests.cs
@@ -0,0 +1,91 @@
+//
+// System.Xml.NameTableTests.cs
+//
+// Author: Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+using System;
+using System.Xml;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+ public class NameTableTests : TestCase
+ {
+ NameTable table;
+
+ public NameTableTests (string name)
+ : base (name)
+ {
+ }
+
+ protected override void SetUp ()
+ {
+ table = new NameTable ();
+ }
+
+ //
+ // Tests System.Xml.NameTable.Add (string)
+ //
+ public void TestAdd1 ()
+ {
+ string add = "add1";
+ string testAdd = table.Add (add);
+ AssertEquals (add, testAdd);
+ AssertSame (add, testAdd);
+ }
+
+ //
+ // Tests System.Xml.NameTable.Add (char[], int, int)
+ //
+ public void TestAdd2 ()
+ {
+ char[] test = new char [4] { 'a', 'd', 'd', '2' };
+ int index = 0;
+ int length = 3; // "add"
+
+ AssertEquals ("add", table.Add (test, index, length));
+ }
+
+ //
+ // Tests System.Xml.NameTable.Get (string)
+ //
+ public void TestGet1 ()
+ {
+ string get1 = "get1";
+ string testGet = table.Add (get1);
+
+ AssertEquals (table.Get (get1), testGet);
+ AssertSame (get1, testGet );
+ }
+
+ //
+ // Tests System.Xml.NameTable.Get (char[], int, int)
+ //
+ public void TestGet2 ()
+ {
+ char[] test = new char [4] { 'g', 'e', 't', '2' };
+ int index = 0;
+ int length = 3; // "get"
+
+ string testGet = table.Add (test, index, length);
+
+ AssertEquals (table.Get (test, index, length), testGet);
+ }
+
+ //
+ // Tests System.Xml.NameTable.Get (char[], int, 0)
+ //
+ public void TestGet3 ()
+ {
+ char[] test = new char [4] { 't', 'e', 's', 't' };
+ int index = 0;
+ int length = 0;
+
+ AssertEquals (table.Get (test, index, length), String.Empty);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/Test/SelectNodesTests.cs b/mcs/class/System.XML/Test/SelectNodesTests.cs
new file mode 100644
index 00000000000..74844240e40
--- /dev/null
+++ b/mcs/class/System.XML/Test/SelectNodesTests.cs
@@ -0,0 +1,227 @@
+//
+// MonoTests.System.Xml.SelectNodesTests
+//
+// Author:
+// Jason Diamond <jason@injektilo.org>
+//
+// (C) 2002 Jason Diamond
+//
+
+using System;
+using System.Xml;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+ public class SelectNodesTests : TestCase
+ {
+ public SelectNodesTests () : base ("MonoTests.System.Xml.SelectNodesTests testsuite") {}
+ public SelectNodesTests (string name) : base (name) {}
+
+ public void TestRoot ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo />");
+ XmlNodeList nodes = document.SelectNodes ("/");
+ AssertEquals (1, nodes.Count);
+ AssertSame (document, nodes [0]);
+ }
+
+ public void TestDocumentElement ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo />");
+ XmlNodeList nodes = document.SelectNodes ("/foo");
+ AssertEquals (1, nodes.Count);
+ AssertSame (document.DocumentElement, nodes [0]);
+ }
+
+ public void TestBadDocumentElement ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo />");
+ XmlNodeList nodes = document.SelectNodes ("/bar");
+ AssertEquals (0, nodes.Count);
+ }
+
+ public void TestElementWildcard ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo><bar /><baz /></foo>");
+ XmlNodeList nodes = document.SelectNodes ("/foo/*");
+ AssertEquals (2, nodes.Count);
+ AssertSame (document.DocumentElement.ChildNodes [0], nodes [0]);
+ AssertSame (document.DocumentElement.ChildNodes [1], nodes [1]);
+ }
+
+ public void TestOneChildElement ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo><bar /><baz /></foo>");
+ XmlNodeList nodes = document.SelectNodes ("/foo/bar");
+ AssertEquals (1, nodes.Count);
+ AssertSame (document.DocumentElement.ChildNodes [0], nodes [0]);
+ }
+
+ public void TestOneOtherChildElement ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo><bar /><baz /></foo>");
+ XmlNodeList nodes = document.SelectNodes ("/foo/baz");
+ AssertEquals (1, nodes.Count);
+ AssertSame (document.DocumentElement.ChildNodes [1], nodes [0]);
+ }
+
+ public void TestTextNode ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo>bar</foo>");
+ XmlNodeList nodes = document.SelectNodes ("/foo/text()");
+ AssertEquals (1, nodes.Count);
+ AssertSame (document.DocumentElement.ChildNodes [0], nodes [0]);
+ }
+
+ public void TestSplitTextNodes ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo>bar<baz />quux</foo>");
+ XmlNodeList nodes = document.SelectNodes ("/foo/text()");
+ AssertEquals (2, nodes.Count);
+ AssertSame (document.DocumentElement.ChildNodes [0], nodes [0]);
+ AssertSame (document.DocumentElement.ChildNodes [2], nodes [1]);
+ }
+
+ public void TestAbbreviatedParentAxis ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo><bar /></foo>");
+ XmlNodeList nodes = document.SelectNodes ("/foo/bar/..");
+ AssertEquals (1, nodes.Count);
+ AssertSame (document.DocumentElement, nodes [0]);
+ }
+
+ public void TestFullParentAxis ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo><bar /></foo>");
+ XmlNodeList nodes = document.SelectNodes ("/foo/bar/parent::node()");
+ AssertEquals (1, nodes.Count);
+ AssertSame (document.DocumentElement, nodes [0]);
+ }
+
+ public void TestAbbreviatedAttributeAxis ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo bar='baz' />");
+ XmlNodeList nodes = document.SelectNodes ("/foo/@bar");
+ AssertEquals (1, nodes.Count);
+ AssertSame (document.DocumentElement.Attributes ["bar"], nodes [0]);
+ }
+
+ public void TestFullAttributeAxis ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo bar='baz' />");
+ XmlNodeList nodes = document.SelectNodes ("/foo/attribute::bar");
+ AssertEquals (1, nodes.Count);
+ AssertSame (document.DocumentElement.Attributes ["bar"], nodes [0]);
+ }
+
+ public void TestAbbreviatedAttributeWildcard ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo bar='baz' quux='quuux' />");
+ XmlNodeList nodes = document.SelectNodes ("/foo/@*");
+ AssertEquals (2, nodes.Count);
+ // are the attributes guanteed to be ordered in the node list?
+ AssertSame (document.DocumentElement.Attributes ["bar"], nodes [0]);
+ AssertSame (document.DocumentElement.Attributes ["quux"], nodes [1]);
+ }
+
+ public void TestAttributeParent ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo bar='baz' />");
+ XmlNodeList nodes = document.SelectNodes ("/foo/@bar/..");
+ AssertEquals (1, nodes.Count);
+ AssertSame (document.DocumentElement, nodes [0]);
+ }
+
+ public void TestUnionOperator ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo><bar /><baz /></foo>");
+ XmlNodeList nodes = document.SelectNodes ("/foo/bar|/foo/baz");
+ AssertEquals (2, nodes.Count);
+ AssertSame (document.DocumentElement.ChildNodes [0], nodes [0]);
+ AssertSame (document.DocumentElement.ChildNodes [1], nodes [1]);
+ }
+
+ public void TestNodeWildcard ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo><bar />baz<quux /></foo>");
+ XmlNodeList nodes = document.SelectNodes ("/foo/node()");
+ AssertEquals (3, nodes.Count);
+ AssertSame (document.DocumentElement.ChildNodes [0], nodes [0]);
+ AssertSame (document.DocumentElement.ChildNodes [1], nodes [1]);
+ AssertSame (document.DocumentElement.ChildNodes [2], nodes [2]);
+ }
+
+ public void TestPositionalPredicate ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo><bar>1</bar><bar>2</bar></foo>");
+ XmlNodeList nodes = document.SelectNodes ("/foo/bar[1]");
+ AssertEquals (1, nodes.Count);
+ AssertSame (document.DocumentElement.ChildNodes [0], nodes [0]);
+ }
+
+ public void TestAllFollowingSiblings ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo><bar /><baz /><quux /></foo>");
+ XmlNodeList nodes = document.SelectNodes ("/foo/bar/following-sibling::*");
+ AssertEquals (2, nodes.Count);
+ AssertSame (document.DocumentElement.ChildNodes [1], nodes [0]);
+ AssertSame (document.DocumentElement.ChildNodes [2], nodes [1]);
+ }
+
+ public void TestFollowingSiblingBaz ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo><bar /><baz /><quux /></foo>");
+ XmlNodeList nodes = document.SelectNodes ("/foo/bar/following-sibling::baz");
+ AssertEquals (1, nodes.Count);
+ AssertSame (document.DocumentElement.ChildNodes [1], nodes [0]);
+ }
+
+ public void TestFollowingSiblingQuux ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo><bar /><baz /><quux /></foo>");
+ XmlNodeList nodes = document.SelectNodes ("/foo/bar/following-sibling::quux");
+ AssertEquals (1, nodes.Count);
+ AssertSame (document.DocumentElement.ChildNodes [2], nodes [0]);
+ }
+
+ public void TestUnion ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo />");
+ XmlNodeList nodes = document.SelectNodes ("(/foo) | (/foo)");
+ AssertEquals (1, nodes.Count); // bug #27548
+ AssertSame (document.DocumentElement, nodes [0]);
+ }
+
+ public void TestAlphabetDigitMixedName ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo1 />");
+ XmlNodeList nodes = document.SelectNodes ("/foo1");
+ AssertEquals (1, nodes.Count);
+ AssertSame (document.DocumentElement, nodes [0]);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/Test/System.XML_linux_test.args b/mcs/class/System.XML/Test/System.XML_linux_test.args
new file mode 100644
index 00000000000..728d1ed0fcd
--- /dev/null
+++ b/mcs/class/System.XML/Test/System.XML_linux_test.args
@@ -0,0 +1,32 @@
+--target library
+-o System.XML_linux_test.dll
+--noconfig
+-r ../../lib/corlib.dll
+-r ../../lib/System.dll
+-r ../../../nunit/NUnitCore_mono.dll
+AllTests.cs
+NameTableTests.cs
+SelectNodesTests.cs
+XmlAttributeCollectionTests.cs
+XmlAttributeTests.cs
+XmlCDataSectionTests.cs
+XmlCharacterDataTests.cs
+XmlCommentTests.cs
+XmlDeclarationTests.cs
+XmlDocumentTests.cs
+XmlDocumentFragmentTests.cs
+XmlDocumentTypeTests.cs
+XmlElementTests.cs
+XmlEntityReferenceTests.cs
+XmlNamespaceManagerTests.cs
+XmlNodeListTests.cs
+XmlNodeTests.cs
+XmlProcessingInstructionTests.cs
+XmlSignificantWhitespaceTests.cs
+XmlTextReaderTests.cs
+XmlTextTests.cs
+XmlTextWriterTests.cs
+XmlWhiteSpaceTests.cs
+XPathNavigatorEvaluateTests.cs
+XPathNavigatorTests.cs
+XPathNavigatorMatchesTests.cs
diff --git a/mcs/class/System.XML/Test/System.XML_test.build b/mcs/class/System.XML/Test/System.XML_test.build
new file mode 100644
index 00000000000..7e3e2b116e3
--- /dev/null
+++ b/mcs/class/System.XML/Test/System.XML_test.build
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+
+<!-- NAnt build file for System.XML_test.dll -->
+<!-- Target build (default) builds tests -->
+<!-- Target test runs tests -->
+
+<project name="System.XML_test" default="build">
+ <property name="debug" value="false"/>
+ <property name="nunit_home" value="..\..\..\nunit"/>
+
+ <target name="build">
+ </target>
+
+ <target name="assemblies">
+ <csc target="library" output="System.XML_test.dll" debug="${debug}">
+ <arg value="/nowarn:1595"/>
+ <sources>
+ <includes name="**/*.cs"/>
+ <excludes name="TheTests.cs"/>
+ </sources>
+ <references basedir="..\..\..\nunit">
+ <includes name="NUnitCore.dll"/>
+ </references>
+ <arg value="/r:.\System.XML.dll"/>
+ </csc>
+ </target>
+
+ <target name="test" depends="assemblies">
+ <exec program="..\..\..\nunit\NUnitConsole" commandline="MonoTests.System.Xml.AllTests,System.XML_test.dll" failonerror="false"/>
+ </target>
+
+ <target name="clean">
+ <delete file="System.XML.dll" failonerror="false"/>
+ <delete file="System.XML_test.dll" failonerror="false"/>
+ <delete file="System.XML_test.pdb" failonerror="false"/>
+ </target>
+</project>
diff --git a/mcs/class/System.XML/Test/TheTests.cs b/mcs/class/System.XML/Test/TheTests.cs
new file mode 100644
index 00000000000..6537bed3754
--- /dev/null
+++ b/mcs/class/System.XML/Test/TheTests.cs
@@ -0,0 +1,93 @@
+using NUnit.Framework;
+using System;
+using System.Threading;
+using System.Globalization;
+
+namespace MonoTests.System.Xml
+{
+ public class RunXmlTextReaderTests : XmlTextReaderTests
+ {
+ protected override void RunTest ()
+ {
+ TestEmptyElement ();
+ TestEmptyElementWithWhitespace ();
+ TestEmptyElementWithStartAndEndTag ();
+ TestEmptyElementWithStartAndEndTagWithWhitespace ();
+ TestNestedEmptyTag ();
+ TestNestedText ();
+ TestEmptyElementWithAttribute ();
+ TestStartAndEndTagWithAttribute ();
+ TestEmptyElementWithTwoAttributes ();
+ TestProcessingInstructionBeforeDocumentElement ();
+ TestCommentBeforeDocumentElement ();
+ TestPredefinedEntities ();
+ TestEntityReference ();
+ TestEntityReferenceInsideText ();
+ TestCharacterReferences ();
+ TestEntityReferenceInAttribute ();
+ TestPredefinedEntitiesInAttribute ();
+ TestCharacterReferencesInAttribute ();
+ TestCDATA ();
+ TestEmptyElementInNamespace ();
+ TestEmptyElementInDefaultNamespace ();
+ TestChildElementInNamespace ();
+ TestChildElementInDefaultNamespace ();
+ TestAttributeInNamespace ();
+ TestIsName ();
+ TestIsNameToken ();
+ }
+ }
+}
+
+namespace MonoTests.System.Xml
+{
+ public class RunXmlNamespaceManagerTests : XmlNamespaceManagerTests
+ {
+ protected override void RunTest ()
+ {
+ TestNewNamespaceManager ();
+ TestAddNamespace ();
+ TestPushScope ();
+ TestPopScope ();
+ }
+ }
+}
+
+namespace MonoTests.System.Xml
+{
+ public class RunXmlDocumentTests : XmlDocumentTests
+ {
+ protected override void RunTest ()
+ {
+ TestDocumentElement ();
+ }
+ }
+}
+
+namespace MonoTests
+{
+ public class RunAllTests
+ {
+ public static void AddAllTests (TestSuite suite)
+ {
+ suite.AddTest (new MonoTests.System.Xml.RunXmlTextReaderTests ());
+ suite.AddTest (new MonoTests.System.Xml.RunXmlNamespaceManagerTests ());
+ suite.AddTest (new MonoTests.System.Xml.RunXmlDocumentTests ());
+ }
+ }
+}
+
+class MainApp
+{
+ public static void Main()
+ {
+ Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US");
+
+ TestResult result = new TestResult ();
+ TestSuite suite = new TestSuite ();
+ MonoTests.RunAllTests.AddAllTests (suite);
+ suite.Run (result);
+ MonoTests.MyTestRunner.Print (result);
+ }
+}
+
diff --git a/mcs/class/System.XML/Test/XPathNavigatorEvaluateTests.cs b/mcs/class/System.XML/Test/XPathNavigatorEvaluateTests.cs
new file mode 100644
index 00000000000..a3001792bf5
--- /dev/null
+++ b/mcs/class/System.XML/Test/XPathNavigatorEvaluateTests.cs
@@ -0,0 +1,212 @@
+//
+// MonoTests.System.Xml.XPathNavigatorEvaluateTests
+//
+// Author:
+// Kral Ferch <kral_ferch@hotmail.com>
+//
+// (C) 2002 Kral Ferch
+//
+
+using System;
+using System.Xml;
+using System.Xml.XPath;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+ public class XPathNavigatorEvaluateTests : TestCase
+ {
+ public XPathNavigatorEvaluateTests () : base ("MonoTests.System.Xml.XPathNavigatorEvaluateTests testsuite") {}
+ public XPathNavigatorEvaluateTests (string name) : base (name) {}
+
+ XmlDocument document;
+ XPathNavigator navigator;
+ XmlDocument document2;
+ XPathNavigator navigator2;
+ XmlDocument document3;
+ XPathNavigator navigator3;
+ XPathExpression expression;
+ XPathNodeIterator iterator;
+
+ protected override void SetUp ()
+ {
+ document = new XmlDocument ();
+ document.LoadXml ("<foo><bar/><baz/><qux/><squonk/></foo>");
+ navigator = document.CreateNavigator ();
+
+ document2 = new XmlDocument ();
+ document2.LoadXml ("<foo><bar baz='1'/><bar baz='2'/><bar baz='3'/></foo>");
+ navigator2 = document2.CreateNavigator ();
+
+ document3 = new XmlDocument ();
+ document3.LoadXml ("<foo><bar/><baz/><qux/></foo>");
+ navigator3 = document3.CreateNavigator ();
+ }
+
+ // Testing Core Function Library functions defined at: http://www.w3.org/TR/xpath#corelib
+ public void TestCoreFunctionNodeSetLast ()
+ {
+ expression = navigator.Compile("last()");
+ iterator = navigator.Select("/foo");
+ AssertEquals ("0", navigator.Evaluate ("last()").ToString());
+ AssertEquals ("0", navigator.Evaluate (expression, null).ToString ());
+ AssertEquals ("1", navigator.Evaluate (expression, iterator).ToString ());
+ iterator = navigator.Select("/foo/*");
+ AssertEquals ("4", navigator.Evaluate (expression, iterator).ToString ());
+
+ AssertEquals("3", navigator2.Evaluate ("string(//bar[last()]/@baz)"));
+ }
+
+ public void TestCoreFunctionNodeSetPosition ()
+ {
+ expression = navigator.Compile("position()");
+ iterator = navigator.Select("/foo");
+ AssertEquals ("0", navigator.Evaluate ("position()").ToString ());
+ AssertEquals ("0", navigator.Evaluate (expression, null).ToString ());
+ AssertEquals ("0", navigator.Evaluate (expression, iterator).ToString ());
+ iterator = navigator.Select("/foo/*");
+ AssertEquals ("0", navigator.Evaluate (expression, iterator).ToString ());
+ iterator.MoveNext();
+ AssertEquals ("1", navigator.Evaluate (expression, iterator).ToString ());
+ iterator.MoveNext ();
+ AssertEquals ("2", navigator.Evaluate (expression, iterator).ToString ());
+ iterator.MoveNext ();
+ AssertEquals ("3", navigator.Evaluate (expression, iterator).ToString ());
+ }
+
+ public void TestCoreFunctionNodeSetCount ()
+ {
+ AssertEquals ("5", navigator.Evaluate ("count(//*)").ToString ());
+ AssertEquals ("1", navigator.Evaluate ("count(//foo)").ToString ());
+ AssertEquals ("1", navigator.Evaluate ("count(/foo)").ToString ());
+ AssertEquals ("1", navigator.Evaluate ("count(/foo/bar)").ToString ());
+
+ AssertEquals ("3", navigator2.Evaluate ("count(//bar)").ToString ());
+ }
+
+ public void saveTestCoreFunctionNodeSetID ()
+ {
+ document.LoadXml (
+ "<!DOCTYPE foo [" +
+ "<!ELEMENT foo (bar)>" +
+ "<!ELEMENT bar EMPTY>" +
+ "<!ATTLIST bar baz ID #REQUIRED>" +
+ "]>" +
+ "<foo><bar baz='1' qux='hello' /><bar baz='2' qux='world' /></foo>");
+ navigator = document.CreateNavigator();
+
+ AssertEquals ("hello", navigator.Evaluate ("string(id('1')/@qux)").ToString ());
+ AssertEquals ("world", navigator.Evaluate ("string(id('2')/@qux)").ToString ());
+ }
+
+ public void TestCoreFunctionLocalName ()
+ {
+ AssertEquals ("", navigator.Evaluate ("local-name()").ToString ());
+ AssertEquals ("", navigator.Evaluate ("local-name(/bogus)").ToString ());
+ AssertEquals ("foo", navigator.Evaluate ("local-name(/foo)").ToString ());
+ AssertEquals ("bar", navigator3.Evaluate ("local-name(/foo/*)").ToString ());
+ }
+
+ // TODO: umm. Unable to make this return a namespace-uri so far...
+ public void TestCoreFunctionNamespaceURI ()
+ {
+ document.LoadXml ("<foo:bar xmlns:foo='#foo'><foo:baz><foo:qux /></foo:baz></foo:bar>");
+ navigator = document.CreateNavigator ();
+
+ AssertEquals ("", navigator.Evaluate ("namespace-uri()").ToString ());
+ AssertEquals ("", navigator.Evaluate ("namespace-uri(/bogus)").ToString ());
+ //AssertEquals("foo", navigator.Evaluate ("namespace-uri(/bar)").ToString ());
+ AssertEquals ("", navigator2.Evaluate ("namespace-uri(//bar)").ToString ());
+ }
+
+ public void saveTestCoreFunctionString ()
+ {
+ document.LoadXml ("<foo>hello<bar>world</bar><baz>how are you</baz></foo>");
+ navigator = document.CreateNavigator ();
+
+ AssertEquals ("world", navigator.Evaluate ("string(/foo/*)").ToString ());
+ AssertEquals ("NaN", navigator.Evaluate ("string(0 div 0)").ToString ());
+
+ try {
+ navigator.Evaluate ("string(+0)");
+ Fail ("Expected an XPathException to be thrown.");
+ } catch (XPathException) {}
+
+ AssertEquals ("0", navigator.Evaluate ("string(-0)").ToString ());
+ AssertEquals ("Infinity", navigator.Evaluate ("string(1 div 0)").ToString ());
+ AssertEquals ("-Infinity", navigator.Evaluate ("string(-1 div 0)").ToString ());
+ AssertEquals ("45", navigator.Evaluate ("string(45)").ToString ());
+ AssertEquals ("-22", navigator.Evaluate ("string(-22)").ToString ());
+ AssertEquals ("0.25", navigator.Evaluate ("string(.25)").ToString ());
+ AssertEquals ("-0.25", navigator.Evaluate ("string(-.25)").ToString ());
+ AssertEquals ("2", navigator.Evaluate ("string(2.0)").ToString ());
+ AssertEquals ("2.01", navigator.Evaluate ("string(2.01)").ToString ());
+ AssertEquals ("-3", navigator.Evaluate ("string(-3.0)").ToString ());
+ AssertEquals ("3.45", navigator.Evaluate ("string(3.45)").ToString ());
+
+ // Wonder what this will look like under a different platform.
+ AssertEquals("0.33333333333333331", navigator.Evaluate ("string(1 div 3)").ToString ());
+ }
+
+ public void TestCoreFunctionConcat ()
+ {
+ try {
+ navigator.Evaluate ("concat()");
+ Fail ("Expected an XPathException to be thrown.");
+ } catch (XPathException) {}
+
+ try {
+ navigator.Evaluate ("concat('foo')");
+ Fail ("Expected an XPathException to be thrown.");
+ } catch (XPathException) {}
+
+ AssertEquals ("foobar", navigator.Evaluate ("concat('foo', 'bar')").ToString ());
+ AssertEquals ("foobarbaz", navigator.Evaluate ("concat('foo', 'bar', 'baz')").ToString ());
+ AssertEquals ("foobarbazqux", navigator.Evaluate ("concat('foo', 'bar', 'baz', 'qux')").ToString ());
+ AssertEquals ("foobarbazquxquux", navigator.Evaluate ("concat('foo', 'bar', 'baz', 'qux', 'quux')").ToString ());
+ }
+
+ public void TestCoreFunctionStartsWith ()
+ {
+ try {
+ navigator.Evaluate ("starts-with()");
+ Fail ("Expected an XPathException to be thrown.");
+ } catch (XPathException) {}
+
+ try {
+ navigator.Evaluate ("starts-with('foo')");
+ Fail ("Expected an XPathException to be thrown.");
+ } catch (XPathException) {}
+
+ try {
+ navigator.Evaluate ("starts-with('foo', 'bar', 'baz')");
+ Fail ("Expected an XPathException to be thrown.");
+ } catch (XPathException) {}
+
+ Assert ((bool)navigator.Evaluate ("starts-with('foobar', 'foo')"));
+ Assert (!(bool)navigator.Evaluate ("starts-with('foobar', 'bar')"));
+ }
+
+ public void TestCoreFunctionContains ()
+ {
+ try {
+ navigator.Evaluate ("contains()");
+ Fail ("Expected an XPathException to be thrown.");
+ } catch (XPathException) {}
+
+ try {
+ navigator.Evaluate ("contains('foo')");
+ Fail ("Expected an XPathException to be thrown.");
+ } catch (XPathException) {}
+
+ try {
+ navigator.Evaluate ("contains('foobar', 'oob', 'baz')");
+ Fail ("Expected an XPathException to be thrown.");
+ } catch (XPathException) {}
+
+ Assert ((bool)navigator.Evaluate ("contains('foobar', 'oob')"));
+ Assert (!(bool)navigator.Evaluate ("contains('foobar', 'baz')"));
+ }
+ }
+}
diff --git a/mcs/class/System.XML/Test/XPathNavigatorMatchesTests.cs b/mcs/class/System.XML/Test/XPathNavigatorMatchesTests.cs
new file mode 100644
index 00000000000..a844d80c6b4
--- /dev/null
+++ b/mcs/class/System.XML/Test/XPathNavigatorMatchesTests.cs
@@ -0,0 +1,116 @@
+//
+// MonoTests.System.Xml.XPathNavigatorMatchesTests
+//
+// Author:
+// Jason Diamond <jason@injektilo.org>
+//
+// (C) 2002 Jason Diamond
+//
+
+using System;
+using System.Xml;
+using System.Xml.XPath;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+ public class XPathNavigatorMatchesTests : TestCase
+ {
+ public XPathNavigatorMatchesTests () : base ("MonoTests.System.Xml.XPathNavigatorMatchesTests testsuite") {}
+ public XPathNavigatorMatchesTests (string name) : base (name) {}
+
+ public void TestMatchRoot ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo />");
+ XPathNavigator navigator = document.CreateNavigator ();
+
+ Assert (navigator.Matches ("/"));
+ }
+
+ public void TestFalseMatchRoot ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo />");
+ XPathNavigator navigator = document.CreateNavigator ();
+
+ Assert (!navigator.Matches ("foo"));
+ }
+
+ public void TestMatchDocumentElement ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo />");
+ XPathNavigator navigator = document.DocumentElement.CreateNavigator ();
+
+ Assert (navigator.Matches ("foo"));
+ }
+
+ public void TestMatchAbsoluteDocumentElement ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo />");
+ XPathNavigator navigator = document.DocumentElement.CreateNavigator ();
+
+ Assert (navigator.Matches ("/foo"));
+ }
+
+ public void TestMatchDocumentElementChild ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo><bar /></foo>");
+ XPathNavigator navigator = document.DocumentElement.FirstChild.CreateNavigator ();
+
+ Assert (navigator.Matches ("bar"));
+ Assert (navigator.Matches ("foo/bar"));
+ }
+
+ public void TestMatchAttribute ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo bar='baz' />");
+ XPathNavigator navigator = document.DocumentElement.Attributes[0].CreateNavigator ();
+
+ Assert (navigator.Matches ("@bar"));
+ Assert (navigator.Matches ("foo/@bar"));
+ }
+
+ public void TestSlashSlash ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo><bar><baz/></bar></foo>");
+ XPathNavigator navigator = document.DocumentElement.FirstChild.FirstChild.CreateNavigator ();
+
+ Assert (navigator.Matches ("foo//baz"));
+ }
+
+ public void TestAbsoluteSlashSlash ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo><bar><baz/></bar></foo>");
+ XPathNavigator navigator = document.DocumentElement.FirstChild.FirstChild.CreateNavigator ();
+
+ Assert (navigator.Matches ("//baz"));
+ }
+
+ public void TestMatchDocumentElementWithPredicate ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo><bar /></foo>");
+ XPathNavigator navigator = document.DocumentElement.CreateNavigator ();
+
+ Assert (navigator.Matches ("foo[bar]"));
+ }
+
+ public void TestFalseMatchDocumentElementWithPredicate ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo><bar /></foo>");
+ XPathNavigator navigator = document.DocumentElement.CreateNavigator ();
+
+ Assert (!navigator.Matches ("foo[baz]"));
+ }
+ }
+}
+
diff --git a/mcs/class/System.XML/Test/XPathNavigatorTests.cs b/mcs/class/System.XML/Test/XPathNavigatorTests.cs
new file mode 100644
index 00000000000..837b92430e5
--- /dev/null
+++ b/mcs/class/System.XML/Test/XPathNavigatorTests.cs
@@ -0,0 +1,172 @@
+//
+// MonoTests.System.Xml.XPathNavigatorTests
+//
+// Author:
+// Jason Diamond <jason@injektilo.org>
+//
+// (C) 2002 Jason Diamond
+//
+
+using System;
+using System.Xml;
+using System.Xml.XPath;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+ public class XPathNavigatorTests : TestCase
+ {
+ public XPathNavigatorTests () : base ("MonoTests.System.Xml.XPathNavigatorTests testsuite") {}
+ public XPathNavigatorTests (string name) : base (name) {}
+
+ public void TestCreateNavigator ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo />");
+ XPathNavigator navigator = document.CreateNavigator ();
+ AssertNotNull (navigator);
+ }
+
+ public void TestPropertiesOnDocument ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo:bar xmlns:foo='#foo' />");
+ XPathNavigator navigator = document.CreateNavigator ();
+
+ AssertEquals (XPathNodeType.Root, navigator.NodeType);
+ AssertEquals (String.Empty, navigator.Name);
+ AssertEquals (String.Empty, navigator.LocalName);
+ AssertEquals (String.Empty, navigator.NamespaceURI);
+ AssertEquals (String.Empty, navigator.Prefix);
+ Assert (!navigator.HasAttributes);
+ Assert (navigator.HasChildren);
+ Assert (!navigator.IsEmptyElement);
+ }
+
+ public void TestPropertiesOnElement ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo:bar xmlns:foo='#foo' />");
+ XPathNavigator navigator = document.DocumentElement.CreateNavigator ();
+
+ AssertEquals (XPathNodeType.Element, navigator.NodeType);
+ AssertEquals ("foo:bar", navigator.Name);
+ AssertEquals ("bar", navigator.LocalName);
+ AssertEquals ("#foo", navigator.NamespaceURI);
+ AssertEquals ("foo", navigator.Prefix);
+ Assert (!navigator.HasAttributes);
+ Assert (!navigator.HasChildren);
+ Assert (navigator.IsEmptyElement);
+ }
+
+ public void TestPropertiesOnAttribute ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo bar:baz='quux' xmlns:bar='#bar' />");
+ XPathNavigator navigator = document.DocumentElement.GetAttributeNode("baz", "#bar").CreateNavigator ();
+
+ AssertEquals (XPathNodeType.Attribute, navigator.NodeType);
+ AssertEquals ("bar:baz", navigator.Name);
+ AssertEquals ("baz", navigator.LocalName);
+ AssertEquals ("#bar", navigator.NamespaceURI);
+ AssertEquals ("bar", navigator.Prefix);
+ Assert (!navigator.HasAttributes);
+ Assert (!navigator.HasChildren);
+ Assert (!navigator.IsEmptyElement);
+ }
+
+ public void TestNavigation ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo><bar /><baz /></foo>");
+ XPathNavigator navigator = document.DocumentElement.CreateNavigator ();
+
+ AssertEquals ("foo", navigator.Name);
+ Assert (navigator.MoveToFirstChild ());
+ AssertEquals ("bar", navigator.Name);
+ Assert (navigator.MoveToNext ());
+ AssertEquals ("baz", navigator.Name);
+ Assert (!navigator.MoveToNext ());
+ AssertEquals ("baz", navigator.Name);
+ Assert (navigator.MoveToPrevious ());
+ AssertEquals ("bar", navigator.Name);
+ Assert (!navigator.MoveToPrevious ());
+ Assert (navigator.MoveToParent ());
+ AssertEquals ("foo", navigator.Name);
+ navigator.MoveToRoot ();
+ AssertEquals (XPathNodeType.Root, navigator.NodeType);
+ Assert (!navigator.MoveToParent ());
+ AssertEquals (XPathNodeType.Root, navigator.NodeType);
+ Assert (navigator.MoveToFirstChild ());
+ AssertEquals ("foo", navigator.Name);
+ Assert (navigator.MoveToFirst ());
+ AssertEquals ("foo", navigator.Name);
+ Assert (navigator.MoveToFirstChild ());
+ AssertEquals ("bar", navigator.Name);
+ Assert (navigator.MoveToNext ());
+ AssertEquals ("baz", navigator.Name);
+ Assert (navigator.MoveToFirst ());
+ AssertEquals ("bar", navigator.Name);
+ }
+
+ public void TestMoveToAndIsSamePosition ()
+ {
+ XmlDocument document1 = new XmlDocument ();
+ document1.LoadXml ("<foo><bar /></foo>");
+ XPathNavigator navigator1a = document1.DocumentElement.CreateNavigator ();
+ XPathNavigator navigator1b = document1.DocumentElement.CreateNavigator ();
+
+ XmlDocument document2 = new XmlDocument ();
+ document2.LoadXml ("<foo><bar /></foo>");
+ XPathNavigator navigator2 = document2.DocumentElement.CreateNavigator ();
+
+ AssertEquals ("foo", navigator1a.Name);
+ Assert (navigator1a.MoveToFirstChild ());
+ AssertEquals ("bar", navigator1a.Name);
+
+ Assert (!navigator1b.IsSamePosition (navigator1a));
+ AssertEquals ("foo", navigator1b.Name);
+ Assert (navigator1b.MoveTo (navigator1a));
+ Assert (navigator1b.IsSamePosition (navigator1a));
+ AssertEquals ("bar", navigator1b.Name);
+
+ Assert (!navigator2.IsSamePosition (navigator1a));
+ AssertEquals ("foo", navigator2.Name);
+ Assert (!navigator2.MoveTo (navigator1a));
+ AssertEquals ("foo", navigator2.Name);
+ }
+
+ public void TestAttributeNavigation ()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo bar='baz' quux='quuux' />");
+ XPathNavigator navigator = document.DocumentElement.CreateNavigator ();
+
+ AssertEquals (XPathNodeType.Element, navigator.NodeType);
+ AssertEquals ("foo", navigator.Name);
+ Assert (navigator.MoveToFirstAttribute ());
+ AssertEquals (XPathNodeType.Attribute, navigator.NodeType);
+ AssertEquals ("bar", navigator.Name);
+ AssertEquals ("baz", navigator.Value);
+ Assert (navigator.MoveToNextAttribute ());
+ AssertEquals (XPathNodeType.Attribute, navigator.NodeType);
+ AssertEquals ("quux", navigator.Name);
+ AssertEquals ("quuux", navigator.Value);
+ }
+
+ public void TestElementAndRootValues()
+ {
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo><bar>baz</bar><quux>quuux</quux></foo>");
+ XPathNavigator navigator = document.DocumentElement.CreateNavigator ();
+
+ AssertEquals (XPathNodeType.Element, navigator.NodeType);
+ AssertEquals ("foo", navigator.Name);
+ //AssertEquals ("bazquuux", navigator.Value);
+
+ navigator.MoveToRoot ();
+ //AssertEquals ("bazquuux", navigator.Value);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/Test/XmlAttributeCollectionTests.cs b/mcs/class/System.XML/Test/XmlAttributeCollectionTests.cs
new file mode 100644
index 00000000000..774344fe106
--- /dev/null
+++ b/mcs/class/System.XML/Test/XmlAttributeCollectionTests.cs
@@ -0,0 +1,149 @@
+// XmlAttributeCollectionTests.cs : Tests for the XmlAttributeCollection class
+//
+// Author: Matt Hunter <xrkune@tconl.com>
+//
+// <c> 2002 Matt Hunter
+
+using System;
+using System.Xml;
+using System.Text;
+using System.IO;
+using System.Collections;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+ public class XmlAttributeCollectionTests : TestCase
+ {
+ public XmlAttributeCollectionTests() : base("MonoTests.System.Xml.XmlAttributeCollectionTests testsuite") { }
+ public XmlAttributeCollectionTests(string name) : base(name) { }
+
+ private XmlDocument document;
+
+ protected override void SetUp()
+ {
+ document = new XmlDocument ();
+ }
+ public void TestRemoveAll ()
+ {
+ StringBuilder xml = new StringBuilder ();
+ xml.Append ("<?xml version=\"1.0\" ?><library><book type=\"non-fiction\" price=\"34.95\"> ");
+ xml.Append ("<title type=\"intro\">XML Fun</title> " );
+ xml.Append ("<author>John Doe</author></book></library>");
+
+ MemoryStream memoryStream = new MemoryStream (Encoding.UTF8.GetBytes (xml.ToString ()));
+ document = new XmlDocument ();
+ document.Load (memoryStream);
+ XmlNodeList bookList = document.GetElementsByTagName ("book");
+ XmlNode xmlNode = bookList.Item (0);
+ XmlElement xmlElement = xmlNode as XmlElement;
+ XmlAttributeCollection attributes = xmlElement.Attributes;
+ attributes.RemoveAll ();
+ AssertEquals ("not all attributes removed.", false, xmlElement.HasAttribute ("type"));
+ }
+
+ public void TestAppend ()
+ {
+ XmlDocument xmlDoc = new XmlDocument ();
+ XmlElement xmlEl = xmlDoc.CreateElement ("TestElement");
+ XmlAttribute xmlAttribute = xmlEl.SetAttributeNode ("attr1", "namespace1");
+ XmlNode xmlNode = xmlDoc.CreateNode (XmlNodeType.Attribute, "attr3", "namespace1");
+ XmlAttribute xmlAttribute3 = xmlNode as XmlAttribute;
+ XmlAttributeCollection attributeCol = xmlEl.Attributes;
+ xmlAttribute3 = attributeCol.Append (xmlAttribute3);
+ AssertEquals ("attribute name not properly created.", true, xmlAttribute3.Name.Equals ("attr3"));
+ AssertEquals ("attribute namespace not properly created.", true, xmlAttribute3.NamespaceURI.Equals ("namespace1"));
+ }
+
+ public void TestCopyTo ()
+ {
+ XmlDocument xmlDoc = new XmlDocument ();
+ xmlDoc.LoadXml("<root a1='garnet' a2='amethyst' a3='Bloodstone' a4='diamond' a5='emerald' a6='pearl' a7='ruby' a8='sapphire' a9='moonstone' a10='opal' a11='topaz' a12='turquoize' />");
+ XmlAttributeCollection col = xmlDoc.DocumentElement.Attributes;
+ XmlAttribute[] array = new XmlAttribute[24];
+ col.CopyTo(array, 0);
+ AssertEquals("garnet", array[0].Value);
+ AssertEquals("moonstone", array[8].Value);
+ AssertEquals("turquoize", array[11].Value);
+ col.CopyTo(array, 12);
+ AssertEquals("garnet", array[12].Value);
+ AssertEquals("moonstone", array[20].Value);
+ AssertEquals("turquoize", array[23].Value);
+ }
+
+ public void TestSetNamedItem ()
+ {
+ XmlDocument xmlDoc = new XmlDocument ();
+ xmlDoc.LoadXml("<root />");
+ XmlElement el = xmlDoc.DocumentElement;
+ XmlAttributeCollection col = xmlDoc.DocumentElement.Attributes;
+
+ XmlAttribute attr = xmlDoc.CreateAttribute("b3");
+ attr.Value = "bloodstone";
+ col.SetNamedItem(attr);
+ AssertEquals("SetNamedItem.Normal", "bloodstone", el.GetAttribute("b3"));
+
+ attr = xmlDoc.CreateAttribute("b3");
+ attr.Value = "aquamaline";
+ col.SetNamedItem(attr);
+ AssertEquals("SetNamedItem.Override", "aquamaline", el.GetAttribute("b3"));
+ AssertEquals("SetNamedItem.Override.Count.1", 1, el.Attributes.Count);
+ AssertEquals("SetNamedItem.Override.Count.2", 1, col.Count);
+ }
+
+ public void TestInsertBeforeAfterPrepend ()
+ {
+ XmlDocument xmlDoc = new XmlDocument ();
+ xmlDoc.LoadXml("<root b2='amethyst' />");
+ XmlElement el = xmlDoc.DocumentElement;
+ XmlAttributeCollection col = xmlDoc.DocumentElement.Attributes;
+ XmlAttribute attr = xmlDoc.CreateAttribute("b1");
+ attr.Value = "garnet";
+ col.InsertAfter(attr, null);
+ AssertEquals("InsertAfterNull", "garnet", el.GetAttributeNode("b1").Value);
+ AssertEquals("InsertAfterNull.Pos", el.GetAttribute("b1"), col[0].Value);
+
+ attr = xmlDoc.CreateAttribute("b3");
+ attr.Value = "bloodstone";
+ col.InsertAfter(attr, el.GetAttributeNode("b2"));
+ AssertEquals("InsertAfterAttr", "bloodstone", el.GetAttributeNode("b3").Value);
+ AssertEquals("InsertAfterAttr.Pos", el.GetAttribute("b3"), col[2].Value);
+
+ attr = xmlDoc.CreateAttribute("b4");
+ attr.Value = "diamond";
+ col.InsertBefore(attr, null);
+ AssertEquals("InsertBeforeNull", "diamond", el.GetAttributeNode("b4").Value);
+ AssertEquals("InsertBeforeNull.Pos", el.GetAttribute("b4"), col[3].Value);
+
+ attr = xmlDoc.CreateAttribute("warning");
+ attr.Value = "mixed modern and traditional;-)";
+ col.InsertBefore(attr, el.GetAttributeNode("b1"));
+ AssertEquals("InsertBeforeAttr", "mixed modern and traditional;-)", el.GetAttributeNode("warning").Value);
+ AssertEquals("InsertBeforeAttr.Pos", el.GetAttributeNode("warning").Value, col[0].Value);
+
+ attr = xmlDoc.CreateAttribute("about");
+ attr.Value = "lists of birthstone.";
+ col.Prepend(attr);
+ AssertEquals("Prepend", "lists of birthstone.", col[0].Value);
+ }
+
+ public void TestRemove ()
+ {
+ XmlDocument xmlDoc = new XmlDocument ();
+ xmlDoc.LoadXml("<root a1='garnet' a2='amethyst' a3='bloodstone' a4='diamond' a5='emerald' a6='pearl' a7='ruby' a8='sapphire' a9='moonstone' a10='opal' a11='topaz' a12='turquoize' />");
+ XmlElement el = xmlDoc.DocumentElement;
+ XmlAttributeCollection col = el.Attributes;
+
+ // Remove
+ XmlAttribute attr = col.Remove(el.GetAttributeNode("a12"));
+ AssertEquals("Remove", 11, col.Count);
+ AssertEquals("Remove.Removed", "a12", attr.Name);
+
+ // RemoveAt
+ attr = col.RemoveAt(5);
+ AssertEquals("RemoveAt", null, el.GetAttributeNode("a6"));
+ AssertEquals("Remove.Removed", "pearl", attr.Value);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/Test/XmlAttributeTests.cs b/mcs/class/System.XML/Test/XmlAttributeTests.cs
new file mode 100644
index 00000000000..404be564fec
--- /dev/null
+++ b/mcs/class/System.XML/Test/XmlAttributeTests.cs
@@ -0,0 +1,124 @@
+// XmlAttributeTests.cs : Tests for the XmlAttribute class
+//
+// Author: Mike Kestner <mkestner@speakeasy.net>
+//
+// <c> 2002 Mike Kestner
+
+using System;
+using System.Xml;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+ public class XmlAttributeTests : TestCase
+ {
+ public XmlAttributeTests () : base("MonoTests.System.Xml.XmlAttributeTests testsuite") { }
+ public XmlAttributeTests (string name) : base(name) { }
+
+ XmlDocument doc;
+ XmlAttribute attr;
+
+ protected override void SetUp()
+ {
+ doc = new XmlDocument ();
+ attr = doc.CreateAttribute ("attr1");
+ attr.Value = "val1";
+ }
+
+ public void TestAttributes ()
+ {
+ AssertNull (attr.Attributes);
+ }
+
+ public void TestAttributeInnerAndOuterXml ()
+ {
+ attr = doc.CreateAttribute ("foo", "bar", "http://abc.def");
+ attr.Value = "baz";
+ AssertEquals ("baz", attr.InnerXml);
+ AssertEquals ("foo:bar=\"baz\"", attr.OuterXml);
+ }
+
+ public void TestAttributeWithNoValue ()
+ {
+ XmlAttribute attribute = doc.CreateAttribute ("name");
+ AssertEquals (String.Empty, attribute.Value);
+ Assert (!attribute.HasChildNodes);
+ AssertNull (attribute.FirstChild);
+ AssertNull (attribute.LastChild);
+ AssertEquals (0, attribute.ChildNodes.Count);
+ }
+
+ public void TestAttributeWithValue ()
+ {
+ XmlAttribute attribute = doc.CreateAttribute ("name");
+ attribute.Value = "value";
+ AssertEquals ("value", attribute.Value);
+ Assert (attribute.HasChildNodes);
+ AssertNotNull (attribute.FirstChild);
+ AssertNotNull (attribute.LastChild);
+ AssertEquals (1, attribute.ChildNodes.Count);
+ AssertEquals (XmlNodeType.Text, attribute.ChildNodes [0].NodeType);
+ AssertEquals ("value", attribute.ChildNodes [0].Value);
+ }
+
+ public void TestHasChildNodes ()
+ {
+ Assert (attr.HasChildNodes);
+ }
+
+ public void TestName ()
+ {
+ AssertEquals ("attr1", attr.Name);
+ }
+
+ public void TestNodeType ()
+ {
+ AssertEquals (XmlNodeType.Attribute, attr.NodeType);
+ }
+
+ public void TestOwnerDocument ()
+ {
+ AssertSame (doc, attr.OwnerDocument);
+ }
+
+ public void TestParentNode ()
+ {
+ AssertNull ("Attr parents not allowed", attr.ParentNode);
+ }
+
+ public void TestValue ()
+ {
+ AssertEquals ("val1", attr.Value);
+ }
+
+ public void TestSetInnerTextAndXml ()
+ {
+ string original = doc.OuterXml;
+ doc.LoadXml ("<root name='value' />");
+ XmlNodeChangedEventHandler eh = new XmlNodeChangedEventHandler (OnSetInnerText);
+ try {
+ doc.DocumentElement.Attributes ["name"].InnerText = "a&b";
+ AssertEquals ("setInnerText", "a&b", doc.DocumentElement.Attributes ["name"].Value);
+ doc.DocumentElement.Attributes ["name"].InnerXml = "a&amp;b";
+ AssertEquals ("setInnerXml", "a&b", doc.DocumentElement.Attributes ["name"].Value);
+
+ doc.NodeChanged += eh;
+ doc.DocumentElement.Attributes ["name"].InnerText = "fire";
+ // If you failed to pass it, then the reason may be loop of event.
+ AssertEquals ("setInnerText.Event", "event was fired", doc.DocumentElement.GetAttribute ("appended"));
+ } catch(Exception ex) {
+ Fail(ex.Message);
+ } finally {
+ doc.LoadXml (original);
+ doc.NodeChanged -= eh;
+ }
+ }
+
+ public void OnSetInnerText (object o, XmlNodeChangedEventArgs e)
+ {
+ if(e.NewParent.Value == "fire")
+ doc.DocumentElement.SetAttribute ("appended", "event was fired");
+ }
+ }
+}
diff --git a/mcs/class/System.XML/Test/XmlCDataSectionTests.cs b/mcs/class/System.XML/Test/XmlCDataSectionTests.cs
new file mode 100755
index 00000000000..dad1050fcf6
--- /dev/null
+++ b/mcs/class/System.XML/Test/XmlCDataSectionTests.cs
@@ -0,0 +1,99 @@
+//
+// System.Xml.XmlCDataSectionTests.cs
+//
+// Author:
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+using System;
+using System.Xml;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+ public class XmlCDataSectionTests : TestCase
+ {
+ XmlDocument document;
+ XmlCDataSection section;
+ XmlNode original;
+ XmlNode deep;
+ XmlNode shallow;
+
+ public XmlCDataSectionTests ()
+ : base ("MonoTests.System.Xml.XmlCDataSectionTests testsuite")
+ {
+ }
+
+ public XmlCDataSectionTests (string name)
+ : base (name)
+ {
+ }
+
+ protected override void SetUp ()
+ {
+ document = new XmlDocument ();
+ document.LoadXml ("<root><foo></foo></root>");
+ section = document.CreateCDataSection ("CDataSection");
+ }
+
+ internal void TestXmlNodeBaseProperties (XmlNode original, XmlNode cloned)
+ {
+ // AssertEquals (original.nodetype + " was incorrectly cloned.",
+ // original.baseuri, cloned.baseuri);
+ AssertNull (cloned.ParentNode);
+ Assert ("Copies, not pointers", !Object.ReferenceEquals (original,cloned));
+ }
+
+ public void TestXmlCDataSectionInnerAndOuterXml ()
+ {
+ section = document.CreateCDataSection ("foo");
+ AssertEquals (String.Empty, section.InnerXml);
+ AssertEquals ("<![CDATA[foo]]>", section.OuterXml);
+ }
+
+ public void TestXmlCDataSectionName ()
+ {
+ AssertEquals (section.NodeType + " Name property broken",
+ section.Name, "#cdata-section");
+ }
+
+ public void TestXmlCDataSectionLocalName ()
+ {
+ AssertEquals (section.NodeType + " LocalName property broken",
+ section.LocalName, "#cdata-section");
+ }
+
+ public void TestXmlCDataSectionNodeType ()
+ {
+ AssertEquals ("XmlCDataSection NodeType property broken",
+ section.NodeType.ToString (), "CDATA");
+ }
+
+ public void TestXmlCDataSectionIsReadOnly ()
+ {
+ AssertEquals ("XmlCDataSection IsReadOnly property broken",
+ section.IsReadOnly, false);
+ }
+
+ public void TestXmlCDataSectionCloneNode ()
+ {
+ original = section;
+
+ shallow = section.CloneNode (false); // shallow
+ TestXmlNodeBaseProperties (original, shallow);
+ AssertEquals ("Value incorrectly cloned",
+ original.Value, shallow.Value);
+
+ deep = section.CloneNode (true); // deep
+ TestXmlNodeBaseProperties (original, deep);
+ AssertEquals ("Value incorrectly cloned",
+ original.Value, deep.Value);
+
+ AssertEquals ("deep cloning differs from shallow cloning",
+ deep.OuterXml, shallow.OuterXml);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/Test/XmlCharacterDataTests.cs b/mcs/class/System.XML/Test/XmlCharacterDataTests.cs
new file mode 100644
index 00000000000..1fbe0b8295c
--- /dev/null
+++ b/mcs/class/System.XML/Test/XmlCharacterDataTests.cs
@@ -0,0 +1,175 @@
+//
+// System.Xml.XmlTextWriterTests
+//
+// Author:
+// Kral Ferch <kral_ferch@hotmail.com>
+//
+// (C) 2002 Kral Ferch
+//
+
+using System;
+using System.Xml;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+ public class XmlCharacterDataTests : TestCase
+ {
+ public XmlCharacterDataTests () : base ("MonoTests.System.Xml.XmlCharacterDataTests testsuite") {}
+ public XmlCharacterDataTests (string name) : base (name) {}
+
+ XmlDocument document;
+ XmlComment comment;
+ bool changed;
+ bool changing;
+
+ protected override void SetUp ()
+ {
+ document = new XmlDocument ();
+ document.NodeChanged += new XmlNodeChangedEventHandler (this.EventNodeChanged);
+ document.NodeChanging += new XmlNodeChangedEventHandler (this.EventNodeChanging);
+ comment = document.CreateComment ("foo");
+ }
+
+ private void EventNodeChanged(Object sender, XmlNodeChangedEventArgs e)
+ {
+ changed = true;
+ }
+
+ private void EventNodeChanging (Object sender, XmlNodeChangedEventArgs e)
+ {
+ changing = true;
+ }
+
+ public void TestAppendData ()
+ {
+ changed = false;
+ changing = false;
+ comment.AppendData ("bar");
+ Assert (changed);
+ Assert (changing);
+ AssertEquals ("foobar", comment.Data);
+
+ comment.Value = "foo";
+ comment.AppendData (null);
+ AssertEquals ("foo", comment.Data);
+ }
+
+ public void TestDeleteData ()
+ {
+ comment.Value = "bar";
+ changed = false;
+ changing = false;
+ comment.DeleteData (1, 1);
+ Assert (changed);
+ Assert (changing);
+ AssertEquals ("br", comment.Data);
+
+ try
+ {
+ comment.Value = "foo";
+ comment.DeleteData(-1, 1);
+ Fail ("Expected an ArgumentOutOfRangeException to be thrown.");
+ }
+ catch (ArgumentOutOfRangeException) {}
+
+ comment.Value = "foo";
+ comment.DeleteData(1, 5);
+ AssertEquals("f", comment.Data);
+
+ comment.Value = "foo";
+ comment.DeleteData(3, 10);
+ AssertEquals("foo", comment.Data);
+ }
+
+ public void TestInsertData ()
+ {
+ comment.Value = "foobaz";
+ changed = false;
+ changing = false;
+ comment.InsertData (3, "bar");
+ Assert (changed);
+ Assert (changing);
+ AssertEquals ("foobarbaz", comment.Data);
+
+ try
+ {
+ comment.Value = "foo";
+ comment.InsertData (-1, "bar");
+ Fail ("Expected an ArgumentOutOfRangeException to be thrown.");
+ }
+ catch (ArgumentOutOfRangeException) {}
+
+ comment.Value = "foo";
+ comment.InsertData (3, "bar");
+ AssertEquals ("foobar", comment.Data);
+
+ try
+ {
+ comment.Value = "foo";
+ comment.InsertData (4, "bar");
+ Fail ("Expected an ArgumentOutOfRangeException to be thrown.");
+ }
+ catch (ArgumentOutOfRangeException) {}
+
+ try
+ {
+ comment.Value = "foo";
+ comment.InsertData (1, null);
+ Fail ("Expected an ArgumentNullException to be thrown.");
+ }
+ catch (ArgumentNullException) {}
+ }
+
+ public void TestReplaceData ()
+ {
+ changed = false;
+ changing = false;
+ comment.ReplaceData (0, 3, "bar");
+ Assert (changed);
+ Assert (changing);
+ AssertEquals ("bar", comment.Data);
+
+ comment.Value = "foo";
+ comment.ReplaceData (2, 3, "bar");
+ AssertEquals ("fobar", comment.Data);
+
+ comment.Value = "foo";
+ comment.ReplaceData (3, 3, "bar");
+ AssertEquals ("foobar", comment.Data);
+
+ try
+ {
+ comment.Value = "foo";
+ comment.ReplaceData (4, 3, "bar");
+ Fail ("Expected an ArgumentOutOfRangeException to be thrown.");
+ }
+ catch (ArgumentOutOfRangeException) {}
+
+ try
+ {
+ comment.Value = "foo";
+ comment.ReplaceData (-1, 3, "bar");
+ Fail ("Expected an ArgumentOutOfRangeException to be thrown.");
+ }
+ catch (ArgumentOutOfRangeException) {}
+
+ comment.Value = "foo";
+ comment.ReplaceData (0, 2, "bar");
+ AssertEquals ("baro", comment.Data);
+
+ comment.Value = "foo";
+ comment.ReplaceData (0, 5, "bar");
+ AssertEquals ("bar", comment.Data);
+
+ try
+ {
+ comment.Value = "foo";
+ comment.ReplaceData (1, 1, null);
+ Fail ("Expected an ArgumentNullException to be thrown.");
+ }
+ catch (ArgumentNullException) {}
+ }
+ }
+}
diff --git a/mcs/class/System.XML/Test/XmlCommentTests.cs b/mcs/class/System.XML/Test/XmlCommentTests.cs
new file mode 100755
index 00000000000..77ff9abe1b7
--- /dev/null
+++ b/mcs/class/System.XML/Test/XmlCommentTests.cs
@@ -0,0 +1,107 @@
+//
+// System.Xml.XmlCommentTests.cs
+//
+// Author:
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+using System;
+using System.Xml;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+ public class XmlCommentTests : TestCase
+ {
+ XmlDocument document;
+ XmlComment comment;
+ XmlNode original;
+ XmlNode deep;
+ XmlNode shallow;
+
+ public XmlCommentTests () : base ("MonoTests.System.Xml.XmlCommentTests testsuite") {}
+
+ public XmlCommentTests (string name) : base (name) {}
+
+ protected override void SetUp ()
+ {
+ document = new XmlDocument ();
+ }
+
+ public void TestXmlCommentCloneNode ()
+ {
+ document.LoadXml ("<root><foo></foo></root>");
+ comment = document.CreateComment ("Comment");
+ original = comment;
+
+ shallow = comment.CloneNode (false); // shallow
+ TestXmlNodeBaseProperties (original, shallow);
+
+ deep = comment.CloneNode (true); // deep
+ TestXmlNodeBaseProperties (original, deep);
+ AssertEquals ("Value incorrectly cloned",
+ original.Value, deep.Value);
+
+ AssertEquals ("deep cloning differs from shallow cloning",
+ deep.OuterXml, shallow.OuterXml);
+ }
+
+ public void TestXmlCommentInnerAndOuterXml ()
+ {
+ comment = document.CreateComment ("foo");
+ AssertEquals (String.Empty, comment.InnerXml);
+ AssertEquals ("<!--foo-->", comment.OuterXml);
+ }
+
+ public void TestXmlCommentIsReadOnly ()
+ {
+ document.LoadXml ("<root><foo></foo></root>");
+ comment = document.CreateComment ("Comment");
+ AssertEquals ("XmlComment IsReadOnly property broken",
+ comment.IsReadOnly, false);
+ }
+
+ public void TestXmlCommentLocalName ()
+ {
+ document.LoadXml ("<root><foo></foo></root>");
+ comment = document.CreateComment ("Comment");
+ AssertEquals (comment.NodeType + " LocalName property broken",
+ comment.LocalName, "#comment");
+ }
+
+ public void TestXmlCommentName ()
+ {
+ document.LoadXml ("<root><foo></foo></root>");
+ comment = document.CreateComment ("Comment");
+ AssertEquals (comment.NodeType + " Name property broken",
+ comment.Name, "#comment");
+ }
+
+ public void TestXmlCommentNodeType ()
+ {
+ document.LoadXml ("<root><foo></foo></root>");
+ comment = document.CreateComment ("Comment");
+ AssertEquals ("XmlComment NodeType property broken",
+ comment.NodeType.ToString (), "Comment");
+ }
+
+ internal void TestXmlNodeBaseProperties (XmlNode original, XmlNode cloned)
+ {
+ document.LoadXml ("<root><foo></foo></root>");
+ comment = document.CreateComment ("Comment");
+
+ // assertequals (original.nodetype + " was incorrectly cloned.",
+ // original.baseuri, cloned.baseuri);
+
+ AssertNull (cloned.ParentNode);
+ AssertEquals ("Value incorrectly cloned",
+ original.Value, cloned.Value);
+
+ Assert ("Copies, not pointers", !Object.ReferenceEquals (original,cloned));
+ }
+
+ }
+}
diff --git a/mcs/class/System.XML/Test/XmlDeclarationTests.cs b/mcs/class/System.XML/Test/XmlDeclarationTests.cs
new file mode 100755
index 00000000000..5445f9ae624
--- /dev/null
+++ b/mcs/class/System.XML/Test/XmlDeclarationTests.cs
@@ -0,0 +1,153 @@
+//
+// System.Xml.XmlDeclarationTests.cs
+//
+// Author:
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+using System;
+using System.Xml;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+ public class XmlDeclarationTests : TestCase
+ {
+
+ XmlDocument document;
+ XmlDeclaration declaration;
+
+ public XmlDeclarationTests () : base ("MonoTests.System.Xml.XmlDeclarationTests testsuite") {}
+
+ public XmlDeclarationTests (string name) : base (name) {}
+
+ protected override void SetUp ()
+ {
+ document = new XmlDocument ();
+ document.LoadXml ("<foo><bar></bar></foo>");
+ declaration = document.CreateXmlDeclaration ("1.0", null, null);
+ }
+
+ public void TestInnerAndOuterXml ()
+ {
+ declaration = document.CreateXmlDeclaration ("1.0", null, null);
+ AssertEquals (String.Empty, declaration.InnerXml);
+ AssertEquals ("<?xml version=\"1.0\"?>", declaration.OuterXml);
+
+ declaration = document.CreateXmlDeclaration ("1.0", "doesn't check", null);
+ AssertEquals (String.Empty, declaration.InnerXml);
+ AssertEquals ("<?xml version=\"1.0\" encoding=\"doesn't check\"?>", declaration.OuterXml);
+
+ declaration = document.CreateXmlDeclaration ("1.0", null, "yes");
+ AssertEquals (String.Empty, declaration.InnerXml);
+ AssertEquals ("<?xml version=\"1.0\" standalone=\"yes\"?>", declaration.OuterXml);
+
+ declaration = document.CreateXmlDeclaration ("1.0", "foo", "no");
+ AssertEquals (String.Empty, declaration.InnerXml);
+ AssertEquals ("<?xml version=\"1.0\" encoding=\"foo\" standalone=\"no\"?>", declaration.OuterXml);
+ }
+
+ internal void TestXmlNodeBaseProperties (XmlNode original, XmlNode cloned)
+ {
+// assertequals (original.nodetype + " was incorrectly cloned.",
+// original.baseuri, cloned.baseuri);
+ AssertNull (cloned.ParentNode);
+
+ AssertEquals ("Value incorrectly cloned",
+ original.Value, cloned.Value);
+
+ Assert ("Copies, not pointers", !Object.ReferenceEquals (original,cloned));
+ }
+
+ public void TestConstructor ()
+ {
+ try {
+ XmlDeclaration broken = document.CreateXmlDeclaration ("2.0", null, null);
+ } catch (ArgumentException) {
+ return;
+
+ } catch (Exception e) {
+ Fail("first arg null, wrong exception: " + e.ToString());
+ }
+ }
+
+ public void TestNodeType ()
+ {
+ AssertEquals ("incorrect NodeType returned", XmlNodeType.XmlDeclaration, declaration.NodeType);
+ }
+
+ public void TestNames ()
+ {
+ AssertEquals ("Name is incorrect", "xml", declaration.Name);
+ AssertEquals ("LocalName is incorrect", "xml", declaration.LocalName);
+ }
+
+ public void TestEncodingProperty ()
+ {
+ XmlDeclaration d1 = document.CreateXmlDeclaration ("1.0", "foo", null);
+ AssertEquals ("Encoding property", "foo", d1.Encoding);
+
+ XmlDeclaration d2 = document.CreateXmlDeclaration ("1.0", null, null);
+ AssertEquals ("null Encoding property", String.Empty, d2.Encoding);
+ }
+
+ public void TestStandaloneProperty ()
+ {
+ XmlDeclaration d1 = document.CreateXmlDeclaration ("1.0", null, "yes");
+ AssertEquals ("Yes standalone property", "yes", d1.Standalone);
+
+ XmlDeclaration d2 = document.CreateXmlDeclaration ("1.0", null, "no");
+ AssertEquals ("No standalone property", "no", d2.Standalone);
+
+ XmlDeclaration d3 = document.CreateXmlDeclaration ("1.0", null, null);
+ AssertEquals ("null Standalone property", String.Empty, d3.Standalone);
+ }
+
+ public void TestValueProperty ()
+ {
+ string expected = "version=\"1.0\" encoding=\"ISO-8859-1\" standalone=\"yes\"" ;
+
+ XmlDeclaration d = document.CreateXmlDeclaration ("1.0", "ISO-8859-1", "yes");
+ AssertEquals ("Value property", expected, d.Value);
+
+ d.Value = expected;
+ AssertEquals ("Value round-trip", expected, d.Value);
+
+ d.Value = " " + expected;
+ AssertEquals ("Value round-trip (padded)", expected, d.Value);
+
+ d.Value = "version=\"1.0\" encoding=\"ISO-8859-1\" standalone=\"yes\"" ;
+ AssertEquals ("Value round-trip (padded 2)", expected, d.Value);
+
+ d.Value = "version=\"1.0\"\tencoding=\"ISO-8859-1\" standalone=\"yes\"" ;
+ AssertEquals ("Value round-trip (\\t)", expected, d.Value);
+
+ d.Value = "version=\"1.0\"\n encoding=\"ISO-8859-1\" standalone=\"yes\"" ;
+ AssertEquals ("Value round-trip (\\n)", expected, d.Value);
+
+ d.Value = "version=\"1.0\" encoding = \"ISO-8859-1\" standalone = \"yes\"" ;
+ AssertEquals ("Value round-trip (spaces)", expected, d.Value);
+
+ d.Value = "version='1.0' encoding='ISO-8859-1' standalone='yes'" ;
+ AssertEquals ("Value round-trip ('s)", expected, d.Value);
+
+ }
+
+ public void TestXmlCommentCloneNode ()
+ {
+ XmlNode original = declaration;
+
+ XmlNode shallow = declaration.CloneNode (false); // shallow
+ TestXmlNodeBaseProperties (original, shallow);
+
+ XmlNode deep = declaration.CloneNode (true); // deep
+ TestXmlNodeBaseProperties (original, deep);
+
+ AssertEquals ("deep cloning differs from shallow cloning",
+ deep.OuterXml, shallow.OuterXml);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/Test/XmlDocumentFragmentTests.cs b/mcs/class/System.XML/Test/XmlDocumentFragmentTests.cs
new file mode 100755
index 00000000000..4c9699f5dcb
--- /dev/null
+++ b/mcs/class/System.XML/Test/XmlDocumentFragmentTests.cs
@@ -0,0 +1,93 @@
+//
+// System.Xml.XmlDocumentFragment.cs
+//
+// Author: Atsushi Enomoto (ginga@kit.hi-ho.ne.jp)
+//
+// (C) 2002 Atsushi Enomoto
+//
+
+using System;
+using System.Xml;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+ public class XmlDocumentFragmentTests : TestCase
+ {
+ XmlDocument document;
+ XmlDocumentFragment fragment;
+
+ public XmlDocumentFragmentTests (string name)
+ : base (name)
+ {
+ }
+
+ protected override void SetUp ()
+ {
+ }
+
+ public void TestConstructor ()
+ {
+ XmlDocument d = new XmlDocument ();
+ XmlDocumentFragment df = d.CreateDocumentFragment ();
+ AssertEquals ("#Constructor.NodeName", "#document-fragment", df.Name);
+ AssertEquals ("#Constructor.NodeType", XmlNodeType.DocumentFragment, df.NodeType);
+ }
+
+ public void TestAppendChildToFragment ()
+ {
+ document = new XmlDocument ();
+ fragment = document.CreateDocumentFragment ();
+ document.LoadXml ("<html><head></head><body></body></html>");
+ XmlElement el = document.CreateElement ("p");
+ el.InnerXml = "Test Paragraph";
+
+ // appending element to fragment
+ fragment.AppendChild (el);
+ AssertNotNull ("#AppendChildToFragment.Element", fragment.FirstChild);
+ AssertNotNull ("#AppendChildToFragment.Element.Children", fragment.FirstChild.FirstChild);
+ AssertEquals ("#AppendChildToFragment.Element.Child.Text", "Test Paragraph", fragment.FirstChild.FirstChild.Value);
+ }
+
+ public void TestAppendFragmentToElement ()
+ {
+ document = new XmlDocument ();
+ fragment = document.CreateDocumentFragment ();
+ document.LoadXml ("<html><head></head><body></body></html>");
+ XmlElement body = document.DocumentElement.LastChild as XmlElement;
+ fragment.AppendChild (document.CreateElement ("p"));
+ fragment.AppendChild (document.CreateElement ("div"));
+
+ // appending fragment to element
+ body.AppendChild (fragment);
+ AssertNotNull ("#AppendFragmentToElement.Exist", body.FirstChild);
+ AssertEquals ("#AppendFragmentToElement.ChildIsElement", XmlNodeType.Element, body.FirstChild.NodeType);
+ AssertEquals ("#AppendFragmentToElement.FirstChild", "p", body.FirstChild.Name);
+ AssertEquals ("#AppendFragmentToElement.LastChild", "div", body.LastChild.Name);
+ }
+
+ public void TestGetInnerXml ()
+ {
+ // this will be also tests of TestWriteTo()/TestWriteContentTo()
+
+ document = new XmlDocument ();
+ fragment = document.CreateDocumentFragment ();
+ fragment.AppendChild (document.CreateElement ("foo"));
+ fragment.AppendChild (document.CreateElement ("bar"));
+ fragment.AppendChild (document.CreateElement ("baz"));
+ AssertEquals ("#Simple", "<foo /><bar /><baz />", fragment.InnerXml);
+ }
+
+ public void TestSetInnerXml ()
+ {
+ document = new XmlDocument ();
+ fragment = document.CreateDocumentFragment ();
+ fragment.InnerXml = "<foo /><bar><child /></bar><baz />";
+ AssertEquals ("foo", fragment.FirstChild.Name);
+ AssertEquals ("bar", fragment.FirstChild.NextSibling.Name);
+ AssertEquals ("child", fragment.FirstChild.NextSibling.FirstChild.Name);
+ AssertEquals ("baz", fragment.LastChild.Name);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/Test/XmlDocumentTests.cs b/mcs/class/System.XML/Test/XmlDocumentTests.cs
new file mode 100644
index 00000000000..362f9429357
--- /dev/null
+++ b/mcs/class/System.XML/Test/XmlDocumentTests.cs
@@ -0,0 +1,875 @@
+
+// System.Xml.XmlDocumentTests
+//
+// Authors:
+// Jason Diamond <jason@injektilo.org>
+// Kral Ferch <kral_ferch@hotmail.com>
+//
+// (C) 2002 Jason Diamond, Kral Ferch
+//
+
+using System;
+using System.Collections;
+using System.Xml;
+using System.IO;
+using System.Text;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+ public class XmlDocumentTests : TestCase
+ {
+ public XmlDocumentTests () : base ("MonoTests.System.Xml.XmlDocumentTests testsuite") {}
+ public XmlDocumentTests (string name) : base (name) {}
+
+ private XmlDocument document;
+ private ArrayList eventStrings = new ArrayList();
+
+ // These Event* methods support the TestEventNode* Tests in this file.
+ // Most of them are event handlers for the XmlNodeChangedEventHandler
+ // delegate.
+ private void EventStringAdd(string eventName, XmlNodeChangedEventArgs e)
+ {
+ string oldParent = (e.OldParent != null) ? e.OldParent.Name : "<none>";
+ string newParent = (e.NewParent != null) ? e.NewParent.Name : "<none>";
+ eventStrings.Add (String.Format ("{0}, {1}, {2}, {3}, {4}", eventName, e.Action.ToString (), e.Node.OuterXml, oldParent, newParent));
+ }
+
+ private void EventNodeChanged(Object sender, XmlNodeChangedEventArgs e)
+ {
+ EventStringAdd ("NodeChanged", e);
+ }
+
+ private void EventNodeChanging (Object sender, XmlNodeChangedEventArgs e)
+ {
+ EventStringAdd ("NodeChanging", e);
+ }
+
+ private void EventNodeChangingException (Object sender, XmlNodeChangedEventArgs e)
+ {
+ throw new Exception ("don't change the value.");
+ }
+
+ private void EventNodeInserted(Object sender, XmlNodeChangedEventArgs e)
+ {
+ EventStringAdd ("NodeInserted", e);
+ }
+
+ private void EventNodeInserting(Object sender, XmlNodeChangedEventArgs e)
+ {
+ EventStringAdd ("NodeInserting", e);
+ }
+
+ private void EventNodeInsertingException(Object sender, XmlNodeChangedEventArgs e)
+ {
+ throw new Exception ("don't insert the element.");
+ }
+
+ private void EventNodeRemoved(Object sender, XmlNodeChangedEventArgs e)
+ {
+ EventStringAdd ("NodeRemoved", e);
+ }
+
+ private void EventNodeRemoving(Object sender, XmlNodeChangedEventArgs e)
+ {
+ EventStringAdd ("NodeRemoving", e);
+ }
+
+ private void EventNodeRemovingException(Object sender, XmlNodeChangedEventArgs e)
+ {
+ throw new Exception ("don't remove the element.");
+ }
+
+ protected override void SetUp ()
+ {
+ document = new XmlDocument ();
+ document.PreserveWhitespace = true;
+ }
+
+ public void TestCreateNodeNodeTypeNameEmptyParams ()
+ {
+ XmlNode node;
+
+ try {
+ node = document.CreateNode (null, null, null);
+ Fail ("Expected an ArgumentException to be thrown.");
+ } catch (ArgumentException) {}
+
+ try {
+ node = document.CreateNode ("attribute", null, null);
+ Fail ("Expected a NullReferenceException to be thrown.");
+ } catch (NullReferenceException) {}
+
+ try {
+ node = document.CreateNode ("attribute", "", null);
+ Fail ("Expected an ArgumentException to be thrown.");
+ } catch (ArgumentException) {}
+
+ try {
+ node = document.CreateNode ("element", null, null);
+ Fail ("Expected a NullReferenceException to be thrown.");
+ } catch (NullReferenceException) {}
+
+ try {
+ node = document.CreateNode ("element", "", null);
+ Fail ("Expected an ArgumentException to be thrown.");
+ } catch (ArgumentException) {}
+
+ try {
+ node = document.CreateNode ("entityreference", null, null);
+ Fail ("Expected a NullReferenceException to be thrown.");
+ } catch (NullReferenceException) {}
+ }
+
+ public void TestCreateNodeInvalidXmlNodeType ()
+ {
+ XmlNode node;
+
+ try {
+ node = document.CreateNode (XmlNodeType.EndElement, null, null);
+ Fail ("Expected an ArgumentOutOfRangeException to be thrown.");
+ } catch (ArgumentOutOfRangeException) {}
+
+ try {
+ node = document.CreateNode (XmlNodeType.EndEntity, null, null);
+ Fail ("Expected an ArgumentOutOfRangeException to be thrown.");
+ } catch (ArgumentOutOfRangeException) {}
+
+ try {
+ node = document.CreateNode (XmlNodeType.Entity, null, null);
+ Fail ("Expected an ArgumentOutOfRangeException to be thrown.");
+ } catch (ArgumentOutOfRangeException) {}
+
+ try {
+ node = document.CreateNode (XmlNodeType.None, null, null);
+ Fail ("Expected an ArgumentOutOfRangeException to be thrown.");
+ } catch (ArgumentOutOfRangeException) {}
+
+ try {
+ node = document.CreateNode (XmlNodeType.Notation, null, null);
+ Fail ("Expected an ArgumentOutOfRangeException to be thrown.");
+ } catch (ArgumentOutOfRangeException) {}
+
+ // TODO: undocumented allowable type.
+ node = document.CreateNode (XmlNodeType.XmlDeclaration, null, null);
+ AssertEquals (XmlNodeType.XmlDeclaration, node.NodeType);
+ }
+
+ public void TestCreateNodeWhichParamIsUsed ()
+ {
+ XmlNode node;
+
+ // No constructor params for Document, DocumentFragment.
+
+ node = document.CreateNode (XmlNodeType.CDATA, "a", "b", "c");
+ AssertEquals (String.Empty, ((XmlCDataSection)node).Value);
+
+ node = document.CreateNode (XmlNodeType.Comment, "a", "b", "c");
+ AssertEquals (String.Empty, ((XmlComment)node).Value);
+
+ node = document.CreateNode (XmlNodeType.DocumentType, "a", "b", "c");
+ AssertNull (((XmlDocumentType)node).Value);
+
+// TODO: add this back in to test when it's implemented.
+// node = document.CreateNode (XmlNodeType.EntityReference, "a", "b", "c");
+// AssertNull (((XmlEntityReference)node).Value);
+
+ node = document.CreateNode (XmlNodeType.ProcessingInstruction, "a", "b", "c");
+ AssertEquals (String.Empty, ((XmlProcessingInstruction)node).Value);
+
+ node = document.CreateNode (XmlNodeType.SignificantWhitespace, "a", "b", "c");
+ AssertEquals (String.Empty, ((XmlSignificantWhitespace)node).Value);
+
+ node = document.CreateNode (XmlNodeType.Text, "a", "b", "c");
+ AssertEquals (String.Empty, ((XmlText)node).Value);
+
+ node = document.CreateNode (XmlNodeType.Whitespace, "a", "b", "c");
+ AssertEquals (String.Empty, ((XmlWhitespace)node).Value);
+
+ node = document.CreateNode (XmlNodeType.XmlDeclaration, "a", "b", "c");
+ AssertEquals ("version=\"1.0\"", ((XmlDeclaration)node).Value);
+ }
+
+ public void TestCreateNodeNodeTypeName ()
+ {
+ XmlNode node;
+
+ try {
+ node = document.CreateNode ("foo", null, null);
+ Fail ("Expected an ArgumentException to be thrown.");
+ } catch (ArgumentException) {}
+
+ node = document.CreateNode("attribute", "foo", null);
+ AssertEquals (XmlNodeType.Attribute, node.NodeType);
+
+ node = document.CreateNode("cdatasection", null, null);
+ AssertEquals (XmlNodeType.CDATA, node.NodeType);
+
+ node = document.CreateNode("comment", null, null);
+ AssertEquals (XmlNodeType.Comment, node.NodeType);
+
+ node = document.CreateNode("document", null, null);
+ AssertEquals (XmlNodeType.Document, node.NodeType);
+ // TODO: test which constructor this ended up calling,
+ // i.e. reuse underlying NameTable or not?
+
+// TODO: add this back in to test when it's implemented.
+// node = document.CreateNode("documentfragment", null, null);
+// AssertEquals (XmlNodeType.DocumentFragment, node.NodeType);
+
+ node = document.CreateNode("documenttype", null, null);
+ AssertEquals (XmlNodeType.DocumentType, node.NodeType);
+
+ node = document.CreateNode("element", "foo", null);
+ AssertEquals (XmlNodeType.Element, node.NodeType);
+
+// TODO: add this back in to test when it's implemented.
+// node = document.CreateNode("entityreference", "foo", null);
+// AssertEquals (XmlNodeType.EntityReference, node.NodeType);
+
+ node = document.CreateNode("processinginstruction", null, null);
+ AssertEquals (XmlNodeType.ProcessingInstruction, node.NodeType);
+
+ node = document.CreateNode("significantwhitespace", null, null);
+ AssertEquals (XmlNodeType.SignificantWhitespace, node.NodeType);
+
+ node = document.CreateNode("text", null, null);
+ AssertEquals (XmlNodeType.Text, node.NodeType);
+
+ node = document.CreateNode("whitespace", null, null);
+ AssertEquals (XmlNodeType.Whitespace, node.NodeType);
+ }
+
+ public void TestDocumentElement ()
+ {
+ AssertNull (document.DocumentElement);
+ XmlElement element = document.CreateElement ("foo", "bar", "http://foo/");
+ AssertNotNull (element);
+
+ AssertEquals ("foo", element.Prefix);
+ AssertEquals ("bar", element.LocalName);
+ AssertEquals ("http://foo/", element.NamespaceURI);
+
+ AssertEquals ("foo:bar", element.Name);
+
+ AssertSame (element, document.AppendChild (element));
+
+ AssertSame (element, document.DocumentElement);
+ }
+
+ public void TestDocumentEmpty()
+ {
+ AssertEquals ("Incorrect output for empty document.", "", document.OuterXml);
+ }
+
+ public void TestEventNodeChanged()
+ {
+ XmlElement element;
+ XmlComment comment;
+
+ document.NodeChanged += new XmlNodeChangedEventHandler (this.EventNodeChanged);
+
+ // Node that is part of the document.
+ document.AppendChild (document.CreateElement ("foo"));
+ comment = document.CreateComment ("bar");
+ document.DocumentElement.AppendChild (comment);
+ AssertEquals ("<!--bar-->", document.DocumentElement.InnerXml);
+ comment.Value = "baz";
+ Assert (eventStrings.Contains ("NodeChanged, Change, <!--baz-->, foo, foo"));
+ AssertEquals ("<!--baz-->", document.DocumentElement.InnerXml);
+
+ // Node that isn't part of the document but created by the document.
+ element = document.CreateElement ("foo");
+ comment = document.CreateComment ("bar");
+ element.AppendChild (comment);
+ AssertEquals ("<!--bar-->", element.InnerXml);
+ comment.Value = "baz";
+ Assert (eventStrings.Contains ("NodeChanged, Change, <!--baz-->, foo, foo"));
+ AssertEquals ("<!--baz-->", element.InnerXml);
+
+/*
+ TODO: Insert this when XmlNode.InnerText() and XmlNode.InnerXml() have been implemented.
+
+ // Node that is part of the document.
+ element = document.CreateElement ("foo");
+ element.InnerText = "bar";
+ document.AppendChild(element);
+ element.InnerText = "baz";
+ Assert(eventStrings.Contains("NodeChanged, Change, baz, foo, foo"));
+
+ // Node that isn't part of the document but created by the document.
+ element = document.CreateElement("qux");
+ element.InnerText = "quux";
+ element.InnerText = "quuux";
+ Assert(eventStrings.Contains("NodeChanged, Change, quuux, qux, qux"));
+*/
+ }
+
+ public void TestEventNodeChanging()
+ {
+ XmlElement element;
+ XmlComment comment;
+
+ document.NodeChanging += new XmlNodeChangedEventHandler (this.EventNodeChanging);
+
+ // Node that is part of the document.
+ document.AppendChild (document.CreateElement ("foo"));
+ comment = document.CreateComment ("bar");
+ document.DocumentElement.AppendChild (comment);
+ AssertEquals ("<!--bar-->", document.DocumentElement.InnerXml);
+ comment.Value = "baz";
+ Assert (eventStrings.Contains ("NodeChanging, Change, <!--bar-->, foo, foo"));
+ AssertEquals ("<!--baz-->", document.DocumentElement.InnerXml);
+
+ // Node that isn't part of the document but created by the document.
+ element = document.CreateElement ("foo");
+ comment = document.CreateComment ("bar");
+ element.AppendChild (comment);
+ AssertEquals ("<!--bar-->", element.InnerXml);
+ comment.Value = "baz";
+ Assert (eventStrings.Contains ("NodeChanging, Change, <!--bar-->, foo, foo"));
+ AssertEquals ("<!--baz-->", element.InnerXml);
+
+ // If an exception is thrown the Document returns to original state.
+ document.NodeChanging += new XmlNodeChangedEventHandler (this.EventNodeChangingException);
+ element = document.CreateElement("foo");
+ comment = document.CreateComment ("bar");
+ element.AppendChild (comment);
+ AssertEquals ("<!--bar-->", element.InnerXml);
+ try
+ {
+ comment.Value = "baz";
+ Fail("Expected an exception to be thrown by the NodeChanging event handler method EventNodeChangingException().");
+ } catch (Exception) {}
+ AssertEquals ("<!--bar-->", element.InnerXml);
+
+ // Yes it's a bit anal but this tests whether the node changing event exception fires before the
+ // ArgumentOutOfRangeException. Turns out it does so that means our implementation needs to raise
+ // the node changing event before doing any work.
+ try
+ {
+ comment.ReplaceData(-1, 0, "qux");
+ Fail("Expected an ArgumentOutOfRangeException to be thrown.");
+ }
+ catch (Exception) {}
+
+ /*
+ TODO: Insert this when XmlNode.InnerText() and XmlNode.InnerXml() have been implemented.
+
+ // Node that is part of the document.
+ element = document.CreateElement ("foo");
+ element.InnerText = "bar";
+ document.AppendChild(element);
+ element.InnerText = "baz";
+ Assert(eventStrings.Contains("NodeChanging, Change, bar, foo, foo"));
+
+ // Node that isn't part of the document but created by the document.
+ element = document.CreateElement("foo");
+ element.InnerText = "bar";
+ element.InnerText = "baz";
+ Assert(eventStrings.Contains("NodeChanging, Change, bar, foo, foo"));
+
+ // If an exception is thrown the Document returns to original state.
+ document.NodeChanging += new XmlNodeChangedEventHandler (this.EventNodeChangingException);
+ element = document.CreateElement("foo");
+ element.InnerText = "bar";
+ try {
+ element.InnerText = "baz";
+ Fail("Expected an exception to be thrown by the NodeChanging event handler method EventNodeChangingException().");
+ } catch (Exception) {}
+ AssertEquals("bar", element.InnerText);
+*/
+ }
+
+ public void TestEventNodeInserted()
+ {
+ XmlElement element;
+
+ document.NodeInserted += new XmlNodeChangedEventHandler (this.EventNodeInserted);
+
+ // Inserted 'foo' element to the document.
+ element = document.CreateElement ("foo");
+ document.AppendChild (element);
+ Assert (eventStrings.Contains ("NodeInserted, Insert, <foo />, <none>, #document"));
+
+ // Append child on node in document
+ element = document.CreateElement ("foo");
+ document.DocumentElement.AppendChild (element);
+ Assert (eventStrings.Contains ("NodeInserted, Insert, <foo />, <none>, foo"));
+
+ // Append child on node not in document but created by document
+ element = document.CreateElement ("bar");
+ element.AppendChild(document.CreateElement ("bar"));
+ Assert(eventStrings.Contains("NodeInserted, Insert, <bar />, <none>, bar"));
+ }
+
+ public void TestEventNodeInserting()
+ {
+ XmlElement element;
+
+ document.NodeInserting += new XmlNodeChangedEventHandler (this.EventNodeInserting);
+
+ // Inserting 'foo' element to the document.
+ element = document.CreateElement ("foo");
+ document.AppendChild (element);
+ Assert (eventStrings.Contains ("NodeInserting, Insert, <foo />, <none>, #document"));
+
+ // Append child on node in document
+ element = document.CreateElement ("foo");
+ document.DocumentElement.AppendChild (element);
+ Assert(eventStrings.Contains ("NodeInserting, Insert, <foo />, <none>, foo"));
+
+ // Append child on node not in document but created by document
+ element = document.CreateElement ("bar");
+ AssertEquals (0, element.ChildNodes.Count);
+ element.AppendChild (document.CreateElement ("bar"));
+ Assert (eventStrings.Contains ("NodeInserting, Insert, <bar />, <none>, bar"));
+ AssertEquals (1, element.ChildNodes.Count);
+
+ // If an exception is thrown the Document returns to original state.
+ document.NodeInserting += new XmlNodeChangedEventHandler (this.EventNodeInsertingException);
+ AssertEquals (1, element.ChildNodes.Count);
+ try
+ {
+ element.AppendChild (document.CreateElement("baz"));
+ Fail ("Expected an exception to be thrown by the NodeInserting event handler method EventNodeInsertingException().");
+ }
+ catch (Exception) {}
+ AssertEquals (1, element.ChildNodes.Count);
+ }
+
+ public void TestEventNodeRemoved()
+ {
+ XmlElement element;
+ XmlElement element2;
+
+ document.NodeRemoved += new XmlNodeChangedEventHandler (this.EventNodeRemoved);
+
+ // Removed 'bar' element from 'foo' outside document.
+ element = document.CreateElement ("foo");
+ element2 = document.CreateElement ("bar");
+ element.AppendChild (element2);
+ AssertEquals (1, element.ChildNodes.Count);
+ element.RemoveChild (element2);
+ Assert (eventStrings.Contains ("NodeRemoved, Remove, <bar />, foo, <none>"));
+ AssertEquals (0, element.ChildNodes.Count);
+
+/*
+ * TODO: put this test back in when AttributeCollection.RemoveAll() is implemented.
+
+ // RemoveAll.
+ element = document.CreateElement ("foo");
+ element2 = document.CreateElement ("bar");
+ element.AppendChild(element2);
+ AssertEquals(1, element.ChildNodes.Count);
+ element.RemoveAll();
+ Assert (eventStrings.Contains ("NodeRemoved, Remove, <bar />, foo, <none>"));
+ AssertEquals(0, element.ChildNodes.Count);
+*/
+
+ // Removed 'bar' element from 'foo' inside document.
+ element = document.CreateElement ("foo");
+ document.AppendChild (element);
+ element = document.CreateElement ("bar");
+ document.DocumentElement.AppendChild (element);
+ AssertEquals (1, document.DocumentElement.ChildNodes.Count);
+ document.DocumentElement.RemoveChild (element);
+ Assert (eventStrings.Contains ("NodeRemoved, Remove, <bar />, foo, <none>"));
+ AssertEquals (0, document.DocumentElement.ChildNodes.Count);
+ }
+
+ public void TestEventNodeRemoving()
+ {
+ XmlElement element;
+ XmlElement element2;
+
+ document.NodeRemoving += new XmlNodeChangedEventHandler (this.EventNodeRemoving);
+
+ // Removing 'bar' element from 'foo' outside document.
+ element = document.CreateElement ("foo");
+ element2 = document.CreateElement ("bar");
+ element.AppendChild (element2);
+ AssertEquals (1, element.ChildNodes.Count);
+ element.RemoveChild (element2);
+ Assert (eventStrings.Contains ("NodeRemoving, Remove, <bar />, foo, <none>"));
+ AssertEquals (0, element.ChildNodes.Count);
+
+/*
+ * TODO: put this test back in when AttributeCollection.RemoveAll() is implemented.
+
+ // RemoveAll.
+ element = document.CreateElement ("foo");
+ element2 = document.CreateElement ("bar");
+ element.AppendChild(element2);
+ AssertEquals(1, element.ChildNodes.Count);
+ element.RemoveAll();
+ Assert (eventStrings.Contains ("NodeRemoving, Remove, <bar />, foo, <none>"));
+ AssertEquals(0, element.ChildNodes.Count);
+*/
+
+ // Removing 'bar' element from 'foo' inside document.
+ element = document.CreateElement ("foo");
+ document.AppendChild (element);
+ element = document.CreateElement ("bar");
+ document.DocumentElement.AppendChild (element);
+ AssertEquals (1, document.DocumentElement.ChildNodes.Count);
+ document.DocumentElement.RemoveChild (element);
+ Assert (eventStrings.Contains ("NodeRemoving, Remove, <bar />, foo, <none>"));
+ AssertEquals (0, document.DocumentElement.ChildNodes.Count);
+
+ // If an exception is thrown the Document returns to original state.
+ document.NodeRemoving += new XmlNodeChangedEventHandler (this.EventNodeRemovingException);
+ element.AppendChild (element2);
+ AssertEquals (1, element.ChildNodes.Count);
+ try
+ {
+ element.RemoveChild(element2);
+ Fail ("Expected an exception to be thrown by the NodeRemoving event handler method EventNodeRemovingException().");
+ }
+ catch (Exception) {}
+ AssertEquals (1, element.ChildNodes.Count);
+ }
+
+ public void TestGetElementsByTagNameNoNameSpace ()
+ {
+ string xml = @"<library><book><title>XML Fun</title><author>John Doe</author>
+ <price>34.95</price></book><book><title>Bear and the Dragon</title>
+ <author>Tom Clancy</author><price>6.95</price></book><book>
+ <title>Bourne Identity</title><author>Robert Ludlum</author>
+ <price>9.95</price></book><Fluffer><Nutter><book>
+ <title>Bourne Ultimatum</title><author>Robert Ludlum</author>
+ <price>9.95</price></book></Nutter></Fluffer></library>";
+
+ MemoryStream memoryStream = new MemoryStream (Encoding.UTF8.GetBytes (xml));
+ document = new XmlDocument ();
+ document.Load (memoryStream);
+ XmlNodeList bookList = document.GetElementsByTagName ("book");
+ AssertEquals ("GetElementsByTagName (string) returned incorrect count.", 4, bookList.Count);
+ }
+
+ public void TestGetElementsByTagNameUsingNameSpace ()
+ {
+ StringBuilder xml = new StringBuilder ();
+ xml.Append ("<?xml version=\"1.0\" ?><library xmlns:North=\"http://www.foo.com\" ");
+ xml.Append ("xmlns:South=\"http://www.goo.com\"><North:book type=\"non-fiction\"> ");
+ xml.Append ("<North:title type=\"intro\">XML Fun</North:title> " );
+ xml.Append ("<North:author>John Doe</North:author> " );
+ xml.Append ("<North:price>34.95</North:price></North:book> " );
+ xml.Append ("<South:book type=\"fiction\"> " );
+ xml.Append ("<South:title>Bear and the Dragon</South:title> " );
+ xml.Append ("<South:author>Tom Clancy</South:author> " );
+ xml.Append ("<South:price>6.95</South:price></South:book> " );
+ xml.Append ("<South:book type=\"fiction\"><South:title>Bourne Identity</South:title> " );
+ xml.Append ("<South:author>Robert Ludlum</South:author> " );
+ xml.Append ("<South:price>9.95</South:price></South:book></library>");
+
+ MemoryStream memoryStream = new MemoryStream (Encoding.UTF8.GetBytes (xml.ToString ()));
+ document = new XmlDocument ();
+ document.Load (memoryStream);
+ XmlNodeList bookList = document.GetElementsByTagName ("book", "http://www.goo.com");
+ AssertEquals ("GetElementsByTagName (string, uri) returned incorrect count.", 2, bookList.Count);
+ }
+
+
+ public void TestInnerAndOuterXml ()
+ {
+ AssertEquals (String.Empty, document.InnerXml);
+ AssertEquals (document.InnerXml, document.OuterXml);
+
+ XmlDeclaration declaration = document.CreateXmlDeclaration ("1.0", null, null);
+ document.AppendChild (declaration);
+ AssertEquals ("<?xml version=\"1.0\"?>", document.InnerXml);
+ AssertEquals (document.InnerXml, document.OuterXml);
+
+ XmlElement element = document.CreateElement ("foo");
+ document.AppendChild (element);
+ AssertEquals ("<?xml version=\"1.0\"?><foo />", document.InnerXml);
+ AssertEquals (document.InnerXml, document.OuterXml);
+
+ XmlComment comment = document.CreateComment ("bar");
+ document.DocumentElement.AppendChild (comment);
+ AssertEquals ("<?xml version=\"1.0\"?><foo><!--bar--></foo>", document.InnerXml);
+ AssertEquals (document.InnerXml, document.OuterXml);
+
+ XmlText text = document.CreateTextNode ("baz");
+ document.DocumentElement.AppendChild (text);
+ AssertEquals ("<?xml version=\"1.0\"?><foo><!--bar-->baz</foo>", document.InnerXml);
+ AssertEquals (document.InnerXml, document.OuterXml);
+
+ element = document.CreateElement ("quux");
+ element.SetAttribute ("quuux", "squonk");
+ document.DocumentElement.AppendChild (element);
+ AssertEquals ("<?xml version=\"1.0\"?><foo><!--bar-->baz<quux quuux=\"squonk\" /></foo>", document.InnerXml);
+ AssertEquals (document.InnerXml, document.OuterXml);
+ }
+
+ public void TestLoadWithSystemIOStream ()
+ {
+ string xml = @"<library><book><title>XML Fun</title><author>John Doe</author>
+ <price>34.95</price></book><book><title>Bear and the Dragon</title>
+ <author>Tom Clancy</author><price>6.95</price></book><book>
+ <title>Bourne Identity</title><author>Robert Ludlum</author>
+ <price>9.95</price></book><Fluffer><Nutter><book>
+ <title>Bourne Ultimatum</title><author>Robert Ludlum</author>
+ <price>9.95</price></book></Nutter></Fluffer></library>";
+
+ MemoryStream memoryStream = new MemoryStream (Encoding.UTF8.GetBytes (xml));
+ document = new XmlDocument ();
+ document.Load (memoryStream);
+ AssertEquals ("Not Loaded From IOStream", true, document.HasChildNodes);
+ }
+
+ public void TestLoadXmlCDATA ()
+ {
+ document.LoadXml ("<foo><![CDATA[bar]]></foo>");
+ Assert (document.DocumentElement.FirstChild.NodeType == XmlNodeType.CDATA);
+ AssertEquals ("bar", document.DocumentElement.FirstChild.Value);
+ }
+
+ public void TestLoadXMLComment()
+ {
+// XmlTextReader needs to throw this exception
+// try {
+// document.LoadXml("<!--foo-->");
+// Fail("XmlException should have been thrown.");
+// }
+// catch (XmlException e) {
+// AssertEquals("Exception message doesn't match.", "The root element is missing.", e.Message);
+// }
+
+ document.LoadXml ("<foo><!--Comment--></foo>");
+ Assert (document.DocumentElement.FirstChild.NodeType == XmlNodeType.Comment);
+ AssertEquals ("Comment", document.DocumentElement.FirstChild.Value);
+
+ document.LoadXml (@"<foo><!--bar--></foo>");
+ AssertEquals ("Incorrect target.", "bar", ((XmlComment)document.FirstChild.FirstChild).Data);
+ }
+
+ public void TestLoadXmlElementSingle ()
+ {
+ AssertNull (document.DocumentElement);
+ document.LoadXml ("<foo/>");
+
+ AssertNotNull (document.DocumentElement);
+ AssertSame (document.FirstChild, document.DocumentElement);
+
+ AssertEquals (String.Empty, document.DocumentElement.Prefix);
+ AssertEquals ("foo", document.DocumentElement.LocalName);
+ AssertEquals (String.Empty, document.DocumentElement.NamespaceURI);
+ AssertEquals ("foo", document.DocumentElement.Name);
+ }
+
+ public void TestLoadXmlElementWithAttributes ()
+ {
+ AssertNull (document.DocumentElement);
+ document.LoadXml ("<foo bar='baz' quux='quuux' hoge='hello &amp; world' />");
+
+ XmlElement documentElement = document.DocumentElement;
+
+ AssertEquals ("baz", documentElement.GetAttribute ("bar"));
+ AssertEquals ("quuux", documentElement.GetAttribute ("quux"));
+ AssertEquals ("hello & world", documentElement.GetAttribute ("hoge"));
+ AssertEquals ("hello & world", documentElement.Attributes ["hoge"].Value);
+ AssertEquals (1, documentElement.GetAttributeNode ("hoge").ChildNodes.Count);
+ }
+
+ public void TestLoadXmlElementWithChildElement ()
+ {
+ document.LoadXml ("<foo><bar/></foo>");
+ Assert (document.ChildNodes.Count == 1);
+ Assert (document.FirstChild.ChildNodes.Count == 1);
+ AssertEquals ("foo", document.DocumentElement.LocalName);
+ AssertEquals ("bar", document.DocumentElement.FirstChild.LocalName);
+ }
+
+ public void TestLoadXmlElementWithTextNode ()
+ {
+ document.LoadXml ("<foo>bar</foo>");
+ Assert (document.DocumentElement.FirstChild.NodeType == XmlNodeType.Text);
+ AssertEquals ("bar", document.DocumentElement.FirstChild.Value);
+ }
+
+ public void TestLoadXmlExceptionClearsDocument ()
+ {
+ document.LoadXml ("<foo/>");
+ Assert (document.FirstChild != null);
+
+ try {
+ document.LoadXml ("<123/>");
+ Fail ("An XmlException should have been thrown.");
+ } catch (XmlException) {}
+
+ Assert (document.FirstChild == null);
+ }
+
+ public void TestLoadXmlProcessingInstruction ()
+ {
+ document.LoadXml (@"<?foo bar='baaz' quux='quuux'?><quuuux></quuuux>");
+ AssertEquals ("Incorrect target.", "foo", ((XmlProcessingInstruction)document.FirstChild).Target);
+ AssertEquals ("Incorrect data.", "bar='baaz' quux='quuux'", ((XmlProcessingInstruction)document.FirstChild).Data);
+ }
+
+ public void TestOuterXml ()
+ {
+ string xml;
+
+ xml = "<root><![CDATA[foo]]></root>";
+ document.LoadXml (xml);
+ AssertEquals("XmlDocument with cdata OuterXml is incorrect.", xml, document.OuterXml);
+
+ xml = "<root><!--foo--></root>";
+ document.LoadXml (xml);
+ AssertEquals("XmlDocument with comment OuterXml is incorrect.", xml, document.OuterXml);
+
+ xml = "<root><?foo bar?></root>";
+ document.LoadXml (xml);
+ AssertEquals("XmlDocument with processing instruction OuterXml is incorrect.", xml, document.OuterXml);
+ }
+
+ public void TestParentNodes ()
+ {
+ document.LoadXml ("<foo><bar><baz/></bar></foo>");
+ XmlNode node = document.FirstChild.FirstChild.FirstChild;
+ AssertEquals ("Wrong child found.", "baz", node.LocalName);
+ AssertEquals ("Wrong parent.", "bar", node.ParentNode.LocalName);
+ AssertEquals ("Wrong parent.", "foo", node.ParentNode.ParentNode.LocalName);
+ AssertEquals ("Wrong parent.", "#document", node.ParentNode.ParentNode.ParentNode.LocalName);
+ AssertNull ("Expected parent to be null.", node.ParentNode.ParentNode.ParentNode.ParentNode);
+ }
+
+ public void TestRemovedElementNextSibling ()
+ {
+ XmlNode node;
+ XmlNode nextSibling;
+
+ document.LoadXml ("<foo><child1/><child2/></foo>");
+ node = document.DocumentElement.FirstChild;
+ document.DocumentElement.RemoveChild (node);
+ nextSibling = node.NextSibling;
+ AssertNull ("Expected removed node's next sibling to be null.", nextSibling);
+ }
+
+ // ImportNode
+ public void TestImportNode ()
+ {
+ XmlNode n;
+
+ string xlinkURI = "http://www.w3.org/1999/XLink";
+ string xml1 = "<?xml version='1.0' encoding='utf-8' ?><foo xmlns:xlink='" + xlinkURI + "'><bar a1='v1' xlink:href='#foo'><baz><![CDATA[cdata section.\n\titem 1\n\titem 2\n]]>From here, simple text node.</baz></bar></foo>";
+ document.LoadXml(xml1);
+ XmlDocument newDoc = new XmlDocument();
+ newDoc.LoadXml("<hoge><fuga /></hoge>");
+ XmlElement bar = document.DocumentElement.FirstChild as XmlElement;
+
+ // Attribute
+ n = newDoc.ImportNode(bar.GetAttributeNode("href", xlinkURI), true);
+ AssertEquals("#ImportNode.Attr.NS.LocalName", "href", n.LocalName);
+ AssertEquals("#ImportNode.Attr.NS.NSURI", xlinkURI, n.NamespaceURI);
+ AssertEquals("#ImportNode.Attr.NS.Value", "#foo", n.Value);
+
+ // CDATA
+ n = newDoc.ImportNode(bar.FirstChild.FirstChild, true);
+ AssertEquals("#ImportNode.CDATA", "cdata section.\n\titem 1\n\titem 2\n", n.Value);
+
+ // Element
+ XmlElement e = newDoc.ImportNode(bar, true) as XmlElement;
+ AssertEquals("#ImportNode.Element.Name", "bar", e.Name);
+ AssertEquals("#ImportNode.Element.Attr", "#foo", e.GetAttribute("href", xlinkURI));
+ AssertEquals("#ImportNode.Element.deep", "baz", e.FirstChild.Name);
+
+ // Entity Reference:
+ // [2002/10/14] CreateEntityReference was not implemented.
+// document.LoadXml("<!DOCTYPE test PUBLIC 'dummy' [<!ENTITY FOOENT 'foo'>]><root>&FOOENT;</root>");
+// n = newDoc.ImportNode(document.DocumentElement.FirstChild);
+// AssertEquals("#ImportNode.EntityReference", "FOOENT", n.Name);
+// AssertEquals("#ImportNode.EntityReference", "foo_", n.Value);
+
+ // Processing Instruction
+ document.LoadXml("<foo><?xml-stylesheet href='foo.xsl' ?></foo>");
+ XmlProcessingInstruction pi = (XmlProcessingInstruction)newDoc.ImportNode(document.DocumentElement.FirstChild, false);
+ AssertEquals("#ImportNode.ProcessingInstruction.Name", "xml-stylesheet", pi.Name);
+ AssertEquals("#ImportNode.ProcessingInstruction.Data", "href='foo.xsl'", pi.Data.Trim());
+
+ // Text
+ document.LoadXml(xml1);
+ n = newDoc.ImportNode((XmlText)bar.FirstChild.ChildNodes[1], true);
+ AssertEquals("#ImportNode.Text", "From here, simple text node.", n.Value);
+
+ // XmlDeclaration
+ document.LoadXml(xml1);
+ XmlDeclaration decl = (XmlDeclaration)newDoc.ImportNode(document.FirstChild, false);
+ AssertEquals("#ImportNode.XmlDeclaration.Type", XmlNodeType.XmlDeclaration, decl.NodeType);
+ AssertEquals("#ImportNode.XmlDeclaration.Encoding", "utf-8", decl.Encoding);
+ }
+
+ public void TestNameTable()
+ {
+ XmlDocument doc = new XmlDocument();
+ AssertNotNull(doc.NameTable);
+ }
+
+ public void TestSingleEmptyRootDocument()
+ {
+ XmlDocument doc = new XmlDocument();
+ doc.LoadXml("<root />");
+ AssertNotNull(doc.DocumentElement);
+ }
+
+ public void TestDocumentWithDoctypeDecl ()
+ {
+ XmlDocument doc = new XmlDocument ();
+ try {
+ doc.LoadXml ("<!DOCTYPE test><root />");
+ } catch (XmlException) {
+ Fail ("#DoctypeDecl.OnlyName");
+ }
+ try
+ {
+ doc.LoadXml ("<!DOCTYPE test SYSTEM 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><root />");
+ } catch (XmlException) {
+ Fail("#DoctypeDecl.System");
+ }
+ try {
+ doc.LoadXml ("<!DOCTYPE test PUBLIC '-//test' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><root />");
+ } catch (XmlException) {
+ Fail ("#DoctypeDecl.Public");
+ }
+ // Should this be commented out?
+// try {
+// doc.LoadXml ("<!DOCTYPE test [<!ELEMENT foo >]><root />");
+// } catch (XmlException) {
+// Fail("#DoctypeDecl.ElementDecl");
+// }
+ }
+
+ public void TestCloneNode ()
+ {
+ XmlDocument doc = new XmlDocument ();
+ doc.LoadXml ("<foo><bar /><baz hoge='fuga'>TEST Text</baz></foo>");
+ XmlDocument doc2 = (XmlDocument)doc.CloneNode (false);
+ AssertEquals ("ShallowCopy", 0, doc2.ChildNodes.Count);
+ doc2 = (XmlDocument)doc.CloneNode (true);
+ AssertEquals ("DeepCopy", "foo", doc2.DocumentElement.Name);
+ }
+
+ public void TestOuterXmlWithDefaultXmlns ()
+ {
+ XmlDocument doc = new XmlDocument ();
+ doc.LoadXml ("<iq type=\"get\" id=\"ATECLIENT_1\"><query xmlns=\"jabber:iq:auth\"><username></username></query></iq>");
+ AssertEquals ("<iq type=\"get\" id=\"ATECLIENT_1\"><query xmlns=\"jabber:iq:auth\"><username /></query></iq>", doc.OuterXml);
+ }
+
+ public void TestPreserveWhitespace ()
+ {
+ string input =
+ "<?xml version=\"1.0\" encoding=\"utf-8\" ?><!-- --> <foo/>";
+
+ XmlDocument dom = new XmlDocument ();
+ XmlTextReader reader = new XmlTextReader (new StringReader (input));
+ dom.Load (reader);
+
+ AssertEquals (XmlNodeType.Element, dom.FirstChild.NextSibling.NextSibling.NodeType);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/Test/XmlDocumentTypeTests.cs b/mcs/class/System.XML/Test/XmlDocumentTypeTests.cs
new file mode 100755
index 00000000000..857478bc51c
--- /dev/null
+++ b/mcs/class/System.XML/Test/XmlDocumentTypeTests.cs
@@ -0,0 +1,104 @@
+//
+// System.Xml.XmlDocumentTypeTests.cs
+//
+// Author: Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+using System;
+using System.Xml;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+ public class XmlDocumentTypeTests : TestCase
+ {
+ XmlDocument document;
+ XmlDocumentType docType;
+ public XmlDocumentTypeTests ()
+ : base ("MonoTests.System.Xml.XmlDocumentTypeTests testsuite")
+ {
+ }
+
+ public XmlDocumentTypeTests (string name)
+ : base (name)
+ {
+ }
+
+ protected override void SetUp ()
+ {
+ document = new XmlDocument ();
+ docType = document.CreateDocumentType ("book", null, null, "<!ELEMENT book ANY>");
+ document.AppendChild (docType);
+ }
+
+ internal void TestXmlNodeBaseProperties (XmlNode original, XmlNode cloned)
+ {
+// assertequals (original.nodetype + " was incorrectly cloned.",
+// original.baseuri, cloned.baseuri);
+
+ AssertNull (cloned.ParentNode);
+ AssertEquals ("Value incorrectly cloned",
+ original.Value, cloned.Value);
+
+ Assert ("Copies, not pointers", !Object.ReferenceEquals (original, cloned));
+ }
+
+ public void TestName ()
+ {
+ AssertEquals ("Getting Name property", "book", docType.Name);
+ }
+
+ public void TestLocalName ()
+ {
+ AssertEquals ("Getting LocalName property", "book", docType.LocalName);
+ }
+
+ public void TestInternalSubset ()
+ {
+ AssertEquals ("Getting Internal Subset property",
+ "<!ELEMENT book ANY>", docType.InternalSubset);
+ }
+
+ public void TestAppendChild ()
+ {
+ try {
+ XmlDocumentType type1 = document.CreateDocumentType ("book", null, null, null);
+ document.AppendChild (type1);
+
+ } catch (InvalidOperationException) {
+ return;
+
+ } catch (Exception) {
+ Fail ("Incorrect Exception thrown.");
+ }
+ }
+
+ public void TestNodeType ()
+ {
+ AssertEquals ("NodeType property broken",
+ docType.NodeType.ToString (), "DocumentType");
+ }
+
+ public void TestIsReadOnly ()
+ {
+ AssertEquals ("IsReadOnly property", "True", docType.IsReadOnly.ToString ());
+ }
+
+ public void TestCloneNode ()
+ {
+ XmlNode original = docType;
+
+ XmlNode cloned1 = docType.CloneNode (true);
+ TestXmlNodeBaseProperties (original, cloned1);
+
+ XmlNode cloned2 = docType.CloneNode (false);
+ TestXmlNodeBaseProperties (original, cloned2);
+
+ AssertEquals ("Deep and shallow cloning", cloned1.Value, cloned2.Value);
+ }
+
+ }
+}
diff --git a/mcs/class/System.XML/Test/XmlElementTests.cs b/mcs/class/System.XML/Test/XmlElementTests.cs
new file mode 100644
index 00000000000..5122a42adc8
--- /dev/null
+++ b/mcs/class/System.XML/Test/XmlElementTests.cs
@@ -0,0 +1,337 @@
+//
+// XmlElementTests
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2002 Jason Diamond http://injektilo.org/
+//
+
+using System;
+using System.Xml;
+using System.IO;
+using System.Text;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+ public class XmlElementTests : TestCase
+ {
+ public XmlElementTests () : base ("MonoTests.System.Xml.XmlElementTests testsuite") { }
+ public XmlElementTests (string name) : base (name) { }
+
+ private XmlDocument document;
+
+ protected override void SetUp()
+ {
+ document = new XmlDocument ();
+ }
+
+ private void AssertElement (XmlElement element, string prefix,
+ string localName, string namespaceURI,
+ int attributesCount)
+ {
+ AssertEquals (prefix != String.Empty ? prefix + ":" + localName : localName, element.Name);
+ AssertEquals (prefix, element.Prefix);
+ AssertEquals (localName, element.LocalName);
+ AssertEquals (namespaceURI, element.NamespaceURI);
+ //AssertEquals (attributesCount, element.Attributes.Count);
+ }
+
+ // for NodeInserted Event
+ private bool Inserted = false;
+ private void OnNodeInserted (object o, XmlNodeChangedEventArgs e)
+ {
+ Inserted = true;
+ }
+
+ // for NodeChanged Event
+ private bool Changed = false;
+ private void OnNodeChanged (object o, XmlNodeChangedEventArgs e)
+ {
+ Changed = true;
+ }
+
+ // for NodeRemoved Event
+ private bool Removed = false;
+ private void OnNodeRemoved (object o, XmlNodeChangedEventArgs e)
+ {
+ Removed = true;
+ }
+
+
+ public void TestCloneNode ()
+ {
+ XmlElement element = document.CreateElement ("foo");
+ XmlElement child = document.CreateElement ("bar");
+ XmlElement grandson = document.CreateElement ("baz");
+
+ element.SetAttribute ("attr1", "val1");
+ element.SetAttribute ("attr2", "val2");
+ element.AppendChild (child);
+ child.SetAttribute ("attr3", "val3");
+ child.AppendChild (grandson);
+
+ document.AppendChild (element);
+ XmlNode deep = element.CloneNode (true);
+ // AssertEquals ("These should be the same", deep.OuterXml, element.OuterXml);
+ AssertNull ("This is not null", deep.ParentNode);
+ Assert ("Copies, not pointers", !Object.ReferenceEquals (element,deep));
+
+ XmlNode shallow = element.CloneNode (false);
+ AssertNull ("This is not null", shallow.ParentNode);
+ Assert ("Copies, not pointers", !Object.ReferenceEquals (element,shallow));
+ AssertEquals ("Shallow clones shalt have no children!", false, shallow.HasChildNodes);
+ }
+
+ public void TestCreateElement1 ()
+ {
+ XmlElement element = document.CreateElement ("name");
+ AssertElement (element, String.Empty, "name", String.Empty, 0);
+ }
+
+ public void TestCreateElement1WithPrefix ()
+ {
+ XmlElement element = document.CreateElement ("prefix:localName");
+ AssertElement (element, "prefix", "localName", String.Empty, 0);
+ }
+
+ public void TestCreateElement2 ()
+ {
+ XmlElement element = document.CreateElement ("qualifiedName", "namespaceURI");
+ AssertElement (element, String.Empty, "qualifiedName",
+ "namespaceURI", 0);
+ }
+
+ public void TestCreateElement2WithPrefix ()
+ {
+ XmlElement element = document.CreateElement ("prefix:localName", "namespaceURI");
+ AssertElement (element, "prefix", "localName", "namespaceURI", 0);
+ }
+
+ public void TestCreateElement3 ()
+ {
+ XmlElement element = document.CreateElement ("prefix", "localName", "namespaceURI");
+ AssertElement (element, "prefix", "localName", "namespaceURI", 0);
+ }
+
+ public void TestCreateElement3WithNullNamespace ()
+ {
+ // bug #26855, NamespaceURI should NEVER be null.
+ XmlElement element = document.CreateElement (null, "localName", null);
+ AssertElement (element, String.Empty, "localName", String.Empty, 0);
+ }
+
+ public void TestInnerAndOuterXml ()
+ {
+ XmlElement element;
+ XmlText text;
+ XmlComment comment;
+
+ element = document.CreateElement ("foo");
+ AssertEquals (String.Empty, element.InnerXml);
+ AssertEquals ("<foo />", element.OuterXml);
+
+ text = document.CreateTextNode ("bar");
+ element.AppendChild (text);
+ AssertEquals ("bar", element.InnerXml);
+ AssertEquals ("<foo>bar</foo>", element.OuterXml);
+
+ element.SetAttribute ("baz", "quux");
+ AssertEquals ("bar", element.InnerXml);
+ AssertEquals ("<foo baz=\"quux\">bar</foo>", element.OuterXml);
+
+ comment = document.CreateComment ("squonk");
+ element.AppendChild (comment);
+ AssertEquals ("bar<!--squonk-->", element.InnerXml);
+ AssertEquals ("<foo baz=\"quux\">bar<!--squonk--></foo>", element.OuterXml);
+
+ element.RemoveAll();
+ element.AppendChild(document.CreateElement("hoge"));
+ AssertEquals ("<hoge />", element.InnerXml);
+ }
+
+ public void TestSetGetAttribute ()
+ {
+ XmlElement element = document.CreateElement ("foo");
+ element.SetAttribute ("attr1", "val1");
+ element.SetAttribute ("attr2", "val2");
+ AssertEquals ("val1", element.GetAttribute ("attr1"));
+ AssertEquals ("val2", element.GetAttribute ("attr2"));
+ }
+
+ public void TestGetElementsByTagNameNoNameSpace ()
+ {
+ string xml = @"<library><book><title>XML Fun</title><author>John Doe</author>
+ <price>34.95</price></book><book><title>Bear and the Dragon</title>
+ <author>Tom Clancy</author><price>6.95</price></book><book>
+ <title>Bourne Identity</title><author>Robert Ludlum</author>
+ <price>9.95</price></book><Fluffer><Nutter><book>
+ <title>Bourne Ultimatum</title><author>Robert Ludlum</author>
+ <price>9.95</price></book></Nutter></Fluffer></library>";
+
+ MemoryStream memoryStream = new MemoryStream (Encoding.UTF8.GetBytes (xml));
+ document = new XmlDocument ();
+ document.Load (memoryStream);
+ XmlNodeList libraryList = document.GetElementsByTagName ("library");
+ XmlNode xmlNode = libraryList.Item (0);
+ XmlElement xmlElement = xmlNode as XmlElement;
+ XmlNodeList bookList = xmlElement.GetElementsByTagName ("book");
+ AssertEquals ("GetElementsByTagName (string) returned incorrect count.", 4, bookList.Count);
+ }
+
+ public void TestGetElementsByTagNameUsingNameSpace ()
+ {
+ StringBuilder xml = new StringBuilder ();
+ xml.Append ("<?xml version=\"1.0\" ?><library xmlns:North=\"http://www.foo.com\" ");
+ xml.Append ("xmlns:South=\"http://www.goo.com\"><North:book type=\"non-fiction\"> ");
+ xml.Append ("<North:title type=\"intro\">XML Fun</North:title> " );
+ xml.Append ("<North:author>John Doe</North:author> " );
+ xml.Append ("<North:price>34.95</North:price></North:book> " );
+ xml.Append ("<South:book type=\"fiction\"> " );
+ xml.Append ("<South:title>Bear and the Dragon</South:title> " );
+ xml.Append ("<South:author>Tom Clancy</South:author> " );
+ xml.Append ("<South:price>6.95</South:price></South:book> " );
+ xml.Append ("<South:book type=\"fiction\"><South:title>Bourne Identity</South:title> " );
+ xml.Append ("<South:author>Robert Ludlum</South:author> " );
+ xml.Append ("<South:price>9.95</South:price></South:book></library>");
+
+ MemoryStream memoryStream = new MemoryStream (Encoding.UTF8.GetBytes (xml.ToString ()));
+ document = new XmlDocument ();
+ document.Load (memoryStream);
+ XmlNodeList libraryList = document.GetElementsByTagName ("library");
+ XmlNode xmlNode = libraryList.Item (0);
+ XmlElement xmlElement = xmlNode as XmlElement;
+ XmlNodeList bookList = xmlElement.GetElementsByTagName ("book", "http://www.foo.com");
+ AssertEquals ("GetElementsByTagName (string, uri) returned incorrect count.", 1, bookList.Count);
+ }
+
+ public void TestOuterXmlWithNamespace ()
+ {
+ XmlElement element = document.CreateElement ("foo", "bar", "#foo");
+ AssertEquals ("<foo:bar xmlns:foo=\"#foo\" />", element.OuterXml);
+ }
+
+ public void TestRemoveAllAttributes ()
+ {
+ StringBuilder xml = new StringBuilder ();
+ xml.Append ("<?xml version=\"1.0\" ?><library><book type=\"non-fiction\" price=\"34.95\"> ");
+ xml.Append ("<title type=\"intro\">XML Fun</title> " );
+ xml.Append ("<author>John Doe</author></book></library>");
+
+ MemoryStream memoryStream = new MemoryStream (Encoding.UTF8.GetBytes (xml.ToString ()));
+ document = new XmlDocument ();
+ document.Load (memoryStream);
+ XmlNodeList bookList = document.GetElementsByTagName ("book");
+ XmlNode xmlNode = bookList.Item (0);
+ XmlElement xmlElement = xmlNode as XmlElement;
+ xmlElement.RemoveAllAttributes ();
+ AssertEquals ("attributes not properly removed.", false, xmlElement.HasAttribute ("type"));
+ }
+
+ public void TestSetAttributeNode ()
+ {
+ XmlDocument xmlDoc = new XmlDocument ();
+ XmlElement xmlEl = xmlDoc.CreateElement ("TestElement");
+ XmlAttribute xmlAttribute = xmlEl.SetAttributeNode ("attr1", "namespace1");
+ XmlAttribute xmlAttribute2 = xmlEl.SetAttributeNode ("attr2", "namespace2");
+ AssertEquals ("attribute name not properly created.", true, xmlAttribute.Name.Equals ("attr1"));
+ AssertEquals ("attribute namespace not properly created.", true, xmlAttribute.NamespaceURI.Equals ("namespace1"));
+ }
+
+ public void TestInnerXmlSetter ()
+ {
+ XmlDocument doc = new XmlDocument ();
+ doc.LoadXml ("<root/>");
+ XmlElement el = doc.DocumentElement;
+ AssertNull ("#Simple", el.FirstChild);
+ el.InnerXml = "<foo><bar att='baz'/></foo>";
+ XmlElement child = el.FirstChild as XmlElement;
+ AssertNotNull ("#Simple.Child", child);
+ AssertEquals ("#Simple.Child.Name", "foo", child.LocalName);
+
+ XmlElement grandchild = child.FirstChild as XmlElement;
+ AssertNotNull ("#Simple.GrandChild", grandchild);
+ AssertEquals ("#Simple.GrandChild.Name", "bar", grandchild.LocalName);
+ AssertEquals ("#Simple.GrandChild.Attr", "baz", grandchild.GetAttribute ("att"));
+
+ doc.LoadXml ("<root xmlns='NS0' xmlns:ns1='NS1'><foo/><ns1:bar/><ns2:bar xmlns:ns2='NS2' /></root>");
+ el = doc.DocumentElement.FirstChild.NextSibling as XmlElement; // ns1:bar
+ AssertNull ("#Namespaced.Prepare", el.FirstChild);
+ el.InnerXml = "<ns1:baz />";
+ AssertNotNull ("#Namespaced.Child", el.FirstChild);
+ AssertEquals ("#Namespaced.Child.Name", "baz", el.FirstChild.LocalName);
+ AssertEquals ("#Namespaced.Child.NSURI", "NS1", el.FirstChild.NamespaceURI); // important!
+
+ el.InnerXml = "<hoge />";
+ AssertEquals ("#Namespaced.VerifyPreviousCleared", "hoge", el.FirstChild.Name);
+ }
+
+ public void TestRemoveAttribute ()
+ {
+ string xlinkURI = "http://www.w3.org/1999/XLink";
+ XmlDocument doc = new XmlDocument ();
+ doc.LoadXml ("<root a1='1' a2='2' xlink:href='urn:foo' xmlns:xlink='" + xlinkURI + "' />");
+
+ XmlElement el = doc.DocumentElement;
+ el.RemoveAttribute ("a1");
+ AssertNull ("RemoveAttribute", el.GetAttributeNode ("a1"));
+ el.RemoveAttribute ("xlink:href");
+ AssertNull ("RemoveAttribute", el.GetAttributeNode ("href", xlinkURI));
+ el.RemoveAllAttributes ();
+ AssertNull ("RemoveAllAttributes", el.GetAttributeNode ("a2"));
+ }
+
+ public void TestWriteToWithDefaultNamespace ()
+ {
+ XmlDocument doc = new XmlDocument ();
+ doc.LoadXml ("<RetrievalElement URI=\"\"xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />");
+ StringWriter sw = new StringWriter ();
+ XmlTextWriter xtw = new XmlTextWriter (sw);
+ doc.DocumentElement.WriteTo (xtw);
+ AssertEquals ("<RetrievalElement URI=\"\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", sw.ToString());
+ }
+
+ public void TestWriteToWithDeletedNamespacePrefix ()
+ {
+ XmlDocument doc = new XmlDocument ();
+ doc.LoadXml ("<root xmlns:foo='urn:dummy'><foo foo:bar='baz' /></root>");
+ doc.DocumentElement.RemoveAllAttributes ();
+
+ Assert (doc.DocumentElement.FirstChild.OuterXml.IndexOf("xmlns:foo") > 0);
+ }
+
+ public void TestWriteToWithDifferentNamespaceAttributes ()
+ {
+ XmlDocument doc = new XmlDocument ();
+ doc.LoadXml ("<root xmlns:foo='urn:dummy' xmlns:html='http://www.w3.org/1999/xhtml' html:style='font-size: 1em'></root>");
+ Assert (doc.OuterXml.IndexOf ("xmlns:html=\"http://www.w3.org/1999/xhtml\"") > 0);
+ }
+
+ public void TestInnerTextAndEvent ()
+ {
+ XmlDocument doc = new XmlDocument ();
+ doc.LoadXml ("<root><child>text</child><child2><![CDATA[cdata]]></child2></root>");
+ doc.NodeInserted += new XmlNodeChangedEventHandler (
+ OnNodeInserted);
+ doc.NodeRemoved += new XmlNodeChangedEventHandler (
+ OnNodeRemoved);
+ // If only one child of the element is Text node,
+ // then no events are fired.
+ doc.DocumentElement.FirstChild.InnerText = "no events fired.";
+ AssertEquals ("NoInsertEventFired", false, Inserted);
+ AssertEquals ("NoRemoveEventFired", false, Removed);
+ AssertEquals ("SetInnerTextToSingleText", "no events fired.", doc.DocumentElement.FirstChild.InnerText);
+ Inserted = false;
+ Removed = false;
+
+ // if only one child of the element is CDataSection,
+ // then events are fired.
+ doc.DocumentElement.LastChild.InnerText = "events are fired.";
+ AssertEquals ("InsertedEventFired", true, Inserted);
+ AssertEquals ("RemovedEventFired", true, Removed);
+ AssertEquals ("SetInnerTextToCDataSection", "events are fired.", doc.DocumentElement.LastChild.InnerText);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/Test/XmlEntityReferenceTests.cs b/mcs/class/System.XML/Test/XmlEntityReferenceTests.cs
new file mode 100755
index 00000000000..8cb9c647069
--- /dev/null
+++ b/mcs/class/System.XML/Test/XmlEntityReferenceTests.cs
@@ -0,0 +1,35 @@
+//
+// System.Xml.XmlEntityReference.cs
+//
+// Author:
+// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//
+// (C) 2002 Atsushi Enomoto
+//
+
+using System;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+ public class XmlEntityReferenceTests : TestCase
+ {
+ public XmlEntityReferenceTests () : base ("MonoTests.System.Xml.XmlEntityReferenceTests testsuite") {}
+ public XmlEntityReferenceTests (string name) : base (name) {}
+
+ protected override void SetUp ()
+ {
+ }
+
+ public void TestWriteTo ()
+ {
+ XmlDocument doc = new XmlDocument();
+ doc.LoadXml("<root/>");
+ XmlEntityReference er = doc.CreateEntityReference("foo");
+ doc.DocumentElement.AppendChild(er);
+ AssertEquals ("Name", "foo", er.Name);
+ AssertEquals ("WriteTo", "<root>&foo;</root>", doc.DocumentElement.OuterXml);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/Test/XmlNamespaceManagerTests.cs b/mcs/class/System.XML/Test/XmlNamespaceManagerTests.cs
new file mode 100644
index 00000000000..176c76765cb
--- /dev/null
+++ b/mcs/class/System.XML/Test/XmlNamespaceManagerTests.cs
@@ -0,0 +1,138 @@
+//
+// XmlNamespaceManagerTests.cs
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2002 Jason Diamond http://injektilo.org/
+//
+
+using System;
+using System.Xml;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+ public class XmlNamespaceManagerTests : TestCase
+ {
+ public XmlNamespaceManagerTests () : base ("MonoTests.System.Xml.XmlNameSpaceManagerTests testsuite") { }
+ public XmlNamespaceManagerTests (string name) : base (name) { }
+
+ private XmlNameTable nameTable;
+ private XmlNamespaceManager namespaceManager;
+
+ protected override void SetUp ()
+ {
+ nameTable = new NameTable ();
+ namespaceManager = new XmlNamespaceManager (nameTable);
+ }
+
+ public void TestNewNamespaceManager ()
+ {
+ // make sure that you can call PopScope when there aren't any to pop.
+ Assert (!namespaceManager.PopScope ());
+
+ // the following strings should have been added to the name table by the
+ // namespace manager.
+ string xmlnsPrefix = nameTable.Get ("xmlns");
+ string xmlPrefix = nameTable.Get ("xml");
+ string stringEmpty = nameTable.Get (String.Empty);
+ string xmlnsNamespace = "http://www.w3.org/2000/xmlns/";
+ string xmlNamespace = "http://www.w3.org/XML/1998/namespace";
+
+ // none of them should be null.
+ AssertNotNull (xmlnsPrefix);
+ AssertNotNull (xmlPrefix);
+ AssertNotNull (stringEmpty);
+ AssertNotNull (xmlnsNamespace);
+ AssertNotNull (xmlNamespace);
+
+ // Microsoft's XmlNamespaceManager reports that these three
+ // namespaces aren't declared for some reason.
+ Assert (!namespaceManager.HasNamespace ("xmlns"));
+ Assert (!namespaceManager.HasNamespace ("xml"));
+ Assert (!namespaceManager.HasNamespace (String.Empty));
+
+ // these three namespaces are declared by default.
+ AssertEquals ("http://www.w3.org/2000/xmlns/", namespaceManager.LookupNamespace ("xmlns"));
+ AssertEquals ("http://www.w3.org/XML/1998/namespace", namespaceManager.LookupNamespace ("xml"));
+ AssertEquals (String.Empty, namespaceManager.LookupNamespace (String.Empty));
+
+ // the namespaces should be the same references found in the name table.
+ AssertSame (xmlnsNamespace, namespaceManager.LookupNamespace ("xmlns"));
+ AssertSame (xmlNamespace, namespaceManager.LookupNamespace ("xml"));
+ AssertSame (stringEmpty, namespaceManager.LookupNamespace (String.Empty));
+
+ // looking up undeclared namespaces should return null.
+ AssertNull (namespaceManager.LookupNamespace ("foo"));
+ }
+
+ public void TestAddNamespace ()
+ {
+ // add a new namespace.
+ namespaceManager.AddNamespace ("foo", "http://foo/");
+ // make sure the new namespace is there.
+ Assert (namespaceManager.HasNamespace ("foo"));
+ AssertEquals ("http://foo/", namespaceManager.LookupNamespace ("foo"));
+ }
+
+ public void TestAddNamespaceWithNameTable ()
+ {
+ // add a known reference to the name table.
+ string fooNamespace = "http://foo/";
+ nameTable.Add(fooNamespace);
+
+ // create a new string with the same value but different address.
+ string fooNamespace2 = "http://";
+ fooNamespace2 += "foo/";
+
+ // the references must be different in order for this test to prove anything.
+ Assert (!Object.ReferenceEquals (fooNamespace, fooNamespace2));
+
+ // add the namespace with the reference that's not in the name table.
+ namespaceManager.AddNamespace ("foo", fooNamespace2);
+
+ // the returned reference should be the same one that's in the name table.
+ AssertSame (fooNamespace, namespaceManager.LookupNamespace ("foo"));
+ }
+
+ public void TestPushScope ()
+ {
+ // add a new namespace.
+ namespaceManager.AddNamespace ("foo", "http://foo/");
+ // make sure the new namespace is there.
+ Assert (namespaceManager.HasNamespace ("foo"));
+ AssertEquals ("http://foo/", namespaceManager.LookupNamespace ("foo"));
+ // push a new scope.
+ namespaceManager.PushScope ();
+ // add a new namespace.
+ namespaceManager.AddNamespace ("bar", "http://bar/");
+ // make sure the old namespace is not in this new scope.
+ Assert (!namespaceManager.HasNamespace ("foo"));
+ // but we're still supposed to be able to lookup the old namespace.
+ AssertEquals ("http://foo/", namespaceManager.LookupNamespace ("foo"));
+ // make sure the new namespace is there.
+ Assert (namespaceManager.HasNamespace ("bar"));
+ AssertEquals ("http://bar/", namespaceManager.LookupNamespace ("bar"));
+ }
+
+ public void TestPopScope ()
+ {
+ // add some namespaces and a scope.
+ TestPushScope ();
+ // pop the scope.
+ Assert (namespaceManager.PopScope ());
+ // make sure the first namespace is still there.
+ Assert (namespaceManager.HasNamespace ("foo"));
+ AssertEquals ("http://foo/", namespaceManager.LookupNamespace ("foo"));
+ // make sure the second namespace is no longer there.
+ Assert (!namespaceManager.HasNamespace ("bar"));
+ AssertNull (namespaceManager.LookupNamespace ("bar"));
+ // make sure there are no more scopes to pop.
+ Assert (!namespaceManager.PopScope ());
+ // make sure that popping again doesn't cause an exception.
+ Assert (!namespaceManager.PopScope ());
+ }
+ }
+}
diff --git a/mcs/class/System.XML/Test/XmlNodeListTests.cs b/mcs/class/System.XML/Test/XmlNodeListTests.cs
new file mode 100644
index 00000000000..66279bb7664
--- /dev/null
+++ b/mcs/class/System.XML/Test/XmlNodeListTests.cs
@@ -0,0 +1,215 @@
+//
+// System.Xml.XmlTextWriterTests
+//
+// Author:
+// Kral Ferch <kral_ferch@hotmail.com>
+//
+// (C) 2002 Kral Ferch
+//
+
+using System;
+using System.Xml;
+using System.Collections;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+ public class XmlNodeListTests : TestCase
+ {
+ public XmlNodeListTests () : base ("MonoTests.System.Xml.XmlNodeListTests testsuite") {}
+ public XmlNodeListTests (string name) : base (name) {}
+
+ XmlDocument document;
+ XmlElement documentElement;
+ XmlElement element;
+ XmlNode node;
+ Object obj;
+ IEnumerator enumerator;
+ int index;
+
+ protected override void SetUp ()
+ {
+ document = new XmlDocument ();
+ }
+
+ public void TestNodeTypesThatCantHaveChildren ()
+ {
+ document.LoadXml ("<foo>bar</foo>");
+ documentElement = document.DocumentElement;
+ node = documentElement.FirstChild;
+ AssertEquals ("Expected a text node.", node.NodeType, XmlNodeType.Text);
+ AssertEquals ("Shouldn't have children.", node.HasChildNodes, false);
+ AssertEquals ("Should be empty node list.", node.ChildNodes.Count, 0);
+ AssertEquals ("Should be empty node list.", node.GetEnumerator().MoveNext(), false);
+ }
+
+ public void TestZeroChildren ()
+ {
+ document.LoadXml ("<foo/>");
+ documentElement = document.DocumentElement;
+ AssertEquals ("Should be empty node list.", documentElement.GetEnumerator().MoveNext(), false);
+ }
+
+ public void TestOneChild ()
+ {
+ document.LoadXml ("<foo><child1/></foo>");
+ documentElement = document.DocumentElement;
+ AssertEquals ("Incorrect number of children returned from Count property.", documentElement.ChildNodes.Count, 1);
+ index = 1;
+ foreach (XmlNode childNode in documentElement.ChildNodes)
+ {
+ AssertEquals ("Enumerator didn't return correct node.", "child" + index.ToString(), childNode.LocalName);
+ index++;
+ }
+ AssertEquals ("foreach didn't loop over all children correctly.", index, 2);
+ }
+
+ public void TestMultipleChildren ()
+ {
+ document.LoadXml ("<foo><child1/><child2/><child3/></foo>");
+ element = document.DocumentElement;
+ AssertEquals ("Incorrect number of children returned from Count property.", element.ChildNodes.Count, 3);
+ AssertNull ("Index less than zero should have returned null.", element.ChildNodes [-1]);
+ AssertNull ("Index greater than or equal to Count should have returned null.", element.ChildNodes [3]);
+ AssertEquals ("Didn't return the correct child.", element.FirstChild, element.ChildNodes[0]);
+ AssertEquals ("Didn't return the correct child.", "child1", element.ChildNodes[0].LocalName);
+ AssertEquals ("Didn't return the correct child.", "child2", element.ChildNodes[1].LocalName);
+ AssertEquals ("Didn't return the correct child.", "child3", element.ChildNodes[2].LocalName);
+
+ index = 1;
+ foreach (XmlNode childNode in element.ChildNodes)
+ {
+ AssertEquals ("Enumerator didn't return correct node.", "child" + index.ToString(), childNode.LocalName);
+ index++;
+ }
+ AssertEquals ("foreach didn't loop over all children correctly.", index, 4);
+ }
+
+ public void TestAppendChildAffectOnEnumeration ()
+ {
+ document.LoadXml ("<foo><child1/></foo>");
+ element = document.DocumentElement;
+ enumerator = element.GetEnumerator();
+ AssertEquals ("MoveNext should have succeeded.", enumerator.MoveNext(), true);
+ AssertEquals ("MoveNext should have failed.", enumerator.MoveNext(), false);
+ enumerator.Reset();
+ AssertEquals ("MoveNext should have succeeded.", enumerator.MoveNext(), true);
+ element.AppendChild(document.CreateElement("child2"));
+ AssertEquals ("MoveNext should have succeeded.", enumerator.MoveNext(), true);
+ AssertEquals ("MoveNext should have failed.", enumerator.MoveNext(), false);
+ }
+
+ public void TestRemoveChildAffectOnEnumeration ()
+ {
+ document.LoadXml ("<foo><child1/><child2/></foo>");
+ element = document.DocumentElement;
+ enumerator = element.GetEnumerator();
+ element.RemoveChild(element.FirstChild);
+ enumerator.MoveNext();
+ AssertEquals ("Expected child2 element.", ((XmlElement)enumerator.Current).LocalName, "child2");
+ }
+
+ public void TestRemoveChildAffectOnEnumerationWhenEnumeratorIsOnRemovedChild ()
+ {
+ document.LoadXml ("<foo><child1/><child2/><child3/></foo>");
+ element = document.DocumentElement;
+ enumerator = element.GetEnumerator ();
+ enumerator.MoveNext ();
+ enumerator.MoveNext ();
+ AssertEquals ("Expected child2 element.", "child2", ((XmlElement)enumerator.Current).LocalName);
+ AssertEquals ("Expected child2 element.", "child2", element.FirstChild.NextSibling.LocalName);
+ element.RemoveChild (element.FirstChild.NextSibling);
+ enumerator.MoveNext ();
+
+ try {
+ element = (XmlElement) enumerator.Current;
+ Fail ("Expected an InvalidOperationException.");
+ } catch (InvalidOperationException) { }
+ }
+
+ // TODO: Take the word save off front of this method when XmlNode.ReplaceChild() is implemented.
+ public void saveTestReplaceChildAffectOnEnumeration ()
+ {
+ document.LoadXml ("<foo><child1/><child2/></foo>");
+ element = document.DocumentElement;
+ node = document.CreateElement("child3");
+ enumerator = element.GetEnumerator();
+ AssertEquals ("MoveNext should have succeeded.", enumerator.MoveNext(), true);
+ element.ReplaceChild(node, element.LastChild);
+ enumerator.MoveNext();
+ AssertEquals ("Expected child3 element.", ((XmlElement)enumerator.Current).LocalName, "child3");
+ AssertEquals ("MoveNext should have failed.", enumerator.MoveNext(), false);
+ }
+
+ public void TestRemoveOnlyChildAffectOnEnumeration ()
+ {
+ document.LoadXml ("<foo><child1/></foo>");
+ element = document.DocumentElement;
+ enumerator = element.GetEnumerator();
+ element.RemoveChild(element.FirstChild);
+ AssertEquals ("MoveNext should have failed.", enumerator.MoveNext(), false);
+ }
+
+ // TODO: Take the word save off front of this method when XmlNode.RemoveAll() is fully implemented.
+ public void saveTestRemoveAllAffectOnEnumeration ()
+ {
+ document.LoadXml ("<foo><child1/><child2/><child3/></foo>");
+ element = document.DocumentElement;
+ enumerator = element.GetEnumerator();
+ AssertEquals ("Expected 3 children.", element.ChildNodes.Count, 3);
+ AssertEquals ("MoveNext should have succeeded.", enumerator.MoveNext(), true);
+ element.RemoveAll();
+ AssertEquals ("MoveNext should have failed.", enumerator.MoveNext(), false);
+ }
+
+ public void TestCurrentBeforeFirstNode ()
+ {
+ document.LoadXml ("<foo><child1/></foo>");
+ element = document.DocumentElement;
+ enumerator = element.GetEnumerator();
+ try
+ {
+ obj = enumerator.Current;
+ Fail ("Calling Current property before first node in list should have thrown InvalidOperationException.");
+ } catch (InvalidOperationException) { }
+ }
+
+ public void TestCurrentAfterLastNode ()
+ {
+ document.LoadXml ("<foo><child1/></foo>");
+ element = document.DocumentElement;
+ enumerator = element.GetEnumerator();
+ enumerator.MoveNext();
+ enumerator.MoveNext();
+ try
+ {
+ obj = enumerator.Current;
+ Fail ("Calling Current property after last node in list should have thrown InvalidOperationException.");
+ }
+ catch (InvalidOperationException) { }
+ }
+
+ public void TestCurrentDoesntMove ()
+ {
+ document.LoadXml ("<foo><child1/></foo>");
+ element = document.DocumentElement;
+ enumerator = element.GetEnumerator();
+ enumerator.MoveNext();
+ AssertEquals("Consecutive calls to Current property should yield same reference.", Object.ReferenceEquals(enumerator.Current, enumerator.Current), true);
+ }
+
+ public void TestReset ()
+ {
+ document.LoadXml ("<foo><child1/><child2/></foo>");
+ element = document.DocumentElement;
+ enumerator = element.GetEnumerator();
+ enumerator.MoveNext();
+ enumerator.MoveNext();
+ AssertEquals("Expected child2.", ((XmlElement)enumerator.Current).LocalName, "child2");
+ enumerator.Reset();
+ enumerator.MoveNext();
+ AssertEquals("Expected child1.", ((XmlElement)enumerator.Current).LocalName, "child1");
+ }
+ }
+}
diff --git a/mcs/class/System.XML/Test/XmlNodeTests.cs b/mcs/class/System.XML/Test/XmlNodeTests.cs
new file mode 100644
index 00000000000..9a8689b10e6
--- /dev/null
+++ b/mcs/class/System.XML/Test/XmlNodeTests.cs
@@ -0,0 +1,182 @@
+//
+// System.Xml.XmlNodeTests
+//
+// Author:
+// Kral Ferch <kral_ferch@hotmail.com>
+//
+// (C) 2002 Kral Ferch
+//
+
+using System;
+using System.IO;
+using System.Text;
+using System.Xml;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+ public class XmlNodeTests : TestCase
+ {
+ public XmlNodeTests () : base ("MonoTests.System.Xml.XmlNodeTests testsuite") {}
+ public XmlNodeTests (string name) : base (name) {}
+
+ XmlDocument document;
+ XmlElement element;
+ XmlElement element2;
+ bool inserted;
+ bool inserting;
+ bool removed;
+ bool removing;
+
+ protected override void SetUp ()
+ {
+ document = new XmlDocument ();
+ document.NodeInserted += new XmlNodeChangedEventHandler (this.EventNodeInserted);
+ document.NodeInserting += new XmlNodeChangedEventHandler (this.EventNodeInserting);
+ document.NodeRemoved += new XmlNodeChangedEventHandler (this.EventNodeRemoved);
+ document.NodeRemoving += new XmlNodeChangedEventHandler (this.EventNodeRemoving);
+ element = document.CreateElement ("foo");
+ element2 = document.CreateElement ("bar");
+ }
+
+ private void EventNodeInserted(Object sender, XmlNodeChangedEventArgs e)
+ {
+ inserted = true;
+ }
+
+ private void EventNodeInserting (Object sender, XmlNodeChangedEventArgs e)
+ {
+ inserting = true;
+ }
+
+ private void EventNodeRemoved(Object sender, XmlNodeChangedEventArgs e)
+ {
+ removed = true;
+ }
+
+ private void EventNodeRemoving (Object sender, XmlNodeChangedEventArgs e)
+ {
+ removing = true;
+ }
+
+ public void TestAppendChild ()
+ {
+ XmlComment comment;
+
+ inserted = false;
+ inserting = false;
+ element.AppendChild (element2);
+ Assert (inserted);
+ Assert (inserting);
+
+ // Can only append to elements, documents, and attributes
+ try
+ {
+ comment = document.CreateComment ("baz");
+ comment.AppendChild (element2);
+ Fail ("Expected an InvalidOperationException to be thrown.");
+ }
+ catch (InvalidOperationException) {}
+
+ // Can't append a node from one document into another document.
+ XmlDocument document2 = new XmlDocument();
+ AssertEquals (1, element.ChildNodes.Count);
+ try
+ {
+ element2 = document2.CreateElement ("qux");
+ element.AppendChild (element2);
+ Fail ("Expected an ArgumentException to be thrown.");
+ }
+ catch (ArgumentException) {}
+ AssertEquals (1, element.ChildNodes.Count);
+
+ // Can't append to a readonly node.
+/* TODO put this in when I figure out how to create a read-only node.
+ try
+ {
+ XmlElement element3 = (XmlElement)element.CloneNode (false);
+ Assert (!element.IsReadOnly);
+ Assert (element3.IsReadOnly);
+ element2 = document.CreateElement ("quux");
+ element3.AppendChild (element2);
+ Fail ("Expected an ArgumentException to be thrown.");
+ }
+ catch (ArgumentException) {}
+*/
+ }
+
+ public void TestInsertBefore()
+ {
+ document = new XmlDocument();
+ document.LoadXml("<root><sub /></root>");
+ XmlElement docelem = document.DocumentElement;
+ docelem.InsertBefore(document.CreateElement("good_child"), docelem.FirstChild);
+ AssertEquals("InsertBefore.Normal", "good_child", docelem.FirstChild.Name);
+ try {
+ document.InsertBefore(document.CreateElement("BAD_MAN"), docelem);
+ Fail("#InsertBefore.BadPositionButNoError.1");
+ }
+ catch(XmlException) {}
+ }
+
+ public void TestInsertAfter()
+ {
+ document = new XmlDocument();
+ document.LoadXml("<root><sub1 /><sub2 /></root>");
+ XmlElement docelem = document.DocumentElement;
+ XmlElement newelem = document.CreateElement("good_child");
+ docelem.InsertAfter(newelem, docelem.FirstChild);
+ AssertEquals("InsertAfter.Normal", 3, docelem.ChildNodes.Count);
+ AssertEquals("InsertAfter.First", "sub1", docelem.FirstChild.Name);
+ AssertEquals("InsertAfter.Last", "sub2", docelem.LastChild.Name);
+ AssertEquals("InsertAfter.Prev", "good_child", docelem.FirstChild.NextSibling.Name);
+ AssertEquals("InsertAfter.Next", "good_child", docelem.LastChild.PreviousSibling.Name);
+ // this doesn't throw an exception
+ document.InsertAfter(document.CreateElement("BAD_MAN"), docelem);
+ AssertEquals("InsertAfter with bad location",
+ "<root><sub1 /><good_child /><sub2 /></root><BAD_MAN />",
+ document.InnerXml);
+}
+
+ public void TestPrependChild()
+ {
+ document = new XmlDocument();
+ document.LoadXml("<root><sub1 /><sub2 /></root>");
+ XmlElement docelem = document.DocumentElement;
+ docelem.PrependChild(document.CreateElement("prepender"));
+ AssertEquals("PrependChild", "prepender", docelem.FirstChild.Name);
+ }
+
+ public void saveTestRemoveAll ()
+ {
+ // TODO: put this test back in when AttributeCollection.RemoveAll() is implemented.
+ element.AppendChild(element2);
+ removed = false;
+ removing = false;
+ element.RemoveAll ();
+ Assert (removed);
+ Assert (removing);
+ }
+
+ public void TestRemoveChild ()
+ {
+ element.AppendChild(element2);
+ removed = false;
+ removing = false;
+ element.RemoveChild (element2);
+ Assert (removed);
+ Assert (removing);
+ }
+
+ public void TestGetPrefixOfNamespace ()
+ {
+ document.LoadXml ("<root><c1 xmlns='urn:foo'><c2 xmlns:foo='urn:foo' xmlns='urn:bar'><c3 xmlns=''/></c2></c1></root>");
+ AssertEquals ("root", String.Empty, document.DocumentElement.GetPrefixOfNamespace ("urn:foo"));
+ AssertEquals ("c1", String.Empty, document.DocumentElement.GetPrefixOfNamespace ("urn:foo"));
+ AssertEquals ("c2", String.Empty, document.DocumentElement.FirstChild.GetPrefixOfNamespace ("urn:foo"));
+ AssertEquals ("c3", "foo", document.DocumentElement.FirstChild.FirstChild.GetPrefixOfNamespace ("urn:foo"));
+
+ }
+ }
+}
diff --git a/mcs/class/System.XML/Test/XmlProcessingInstructionTests.cs b/mcs/class/System.XML/Test/XmlProcessingInstructionTests.cs
new file mode 100644
index 00000000000..0926af316aa
--- /dev/null
+++ b/mcs/class/System.XML/Test/XmlProcessingInstructionTests.cs
@@ -0,0 +1,36 @@
+//
+// System.Xml.XmlTextWriterTests
+//
+// Author:
+// Kral Ferch <kral_ferch@hotmail.com>
+//
+// (C) 2002 Kral Ferch
+//
+
+using System;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+ public class XmlProcessingInstructionTests : TestCase
+ {
+ public XmlProcessingInstructionTests () : base ("MonoTests.System.Xml.XmlProcessingInstructionTests testsuite") {}
+ public XmlProcessingInstructionTests (string name) : base (name) {}
+
+ XmlDocument document;
+ XmlProcessingInstruction pi;
+
+ protected override void SetUp ()
+ {
+ document = new XmlDocument ();
+ }
+
+ public void TestInnerAndOuterXml ()
+ {
+ pi = document.CreateProcessingInstruction ("foo", "bar");
+ AssertEquals (String.Empty, pi.InnerXml);
+ AssertEquals ("<?foo bar?>", pi.OuterXml);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/Test/XmlSignificantWhitespaceTests.cs b/mcs/class/System.XML/Test/XmlSignificantWhitespaceTests.cs
new file mode 100755
index 00000000000..870d9869720
--- /dev/null
+++ b/mcs/class/System.XML/Test/XmlSignificantWhitespaceTests.cs
@@ -0,0 +1,127 @@
+//
+// System.Xml.XmlWhitespaceTests.cs
+//
+// Author:
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+using System;
+using System.Xml;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+ public class XmlSignificantWhitespaceTests : TestCase
+ {
+ XmlDocument document;
+ XmlDocument doc2;
+ XmlSignificantWhitespace whitespace;
+ XmlSignificantWhitespace broken;
+ XmlNode original;
+ XmlNode deep;
+ XmlNode shallow;
+
+ public XmlSignificantWhitespaceTests () : base ("MonoTests.System.Xml.XmlWhitespaceTests testsuite") {}
+ public XmlSignificantWhitespaceTests (string name) : base (name) {}
+
+ protected override void SetUp ()
+ {
+ document = new XmlDocument ();
+ document.LoadXml ("<root><foo></foo></root>");
+ XmlElement element = document.CreateElement ("foo");
+ whitespace = document.CreateSignificantWhitespace ("\r\n");
+ element.AppendChild (whitespace);
+
+ doc2 = new XmlDocument ();
+ }
+
+ public void TestInnerAndOuterXml ()
+ {
+ whitespace = doc2.CreateSignificantWhitespace ("\r\n\t ");
+ AssertEquals (String.Empty, whitespace.InnerXml);
+ AssertEquals ("\r\n\t ", whitespace.OuterXml);
+ }
+
+ public void TestDataAndValue ()
+ {
+ string val = "\t\t\r\n ";
+ whitespace = doc2.CreateSignificantWhitespace (val);
+ AssertEquals ("#DataValue.1", val, whitespace.Data);
+ AssertEquals ("#DataValue.2", val, whitespace.Value);
+ whitespace.Value = val + "\t";
+ AssertEquals ("#DataValue.3", val + "\t", whitespace.Data);
+ }
+
+ internal void TestXmlNodeBaseProperties (XmlNode original, XmlNode cloned)
+ {
+// assertequals (original.nodetype + " was incorrectly cloned.",
+// original.baseuri, cloned.baseuri);
+ AssertNull (cloned.ParentNode);
+ AssertEquals ("Value incorrectly cloned",
+ cloned.Value, original.Value);
+
+ Assert ("Copies, not pointers", !Object.ReferenceEquals (original,cloned));
+ }
+
+ public void TestXmlSignificantWhitespaceBadConstructor ()
+ {
+ try {
+ broken = document.CreateSignificantWhitespace ("black");
+
+ } catch (ArgumentException) {
+ return;
+
+ } catch (Exception) {
+ Fail ("Incorrect Exception thrown.");
+ }
+ }
+
+ public void TestXmlSignificantWhitespaceConstructor ()
+ {
+ AssertEquals ("whitespace char didn't get copied right",
+ "\r\n", whitespace.Data);
+ }
+
+
+ public void TestXmlSignificantWhitespaceName ()
+ {
+ AssertEquals (whitespace.NodeType + " Name property broken",
+ whitespace.Name, "#significant-whitespace");
+ }
+
+ public void TestXmlSignificantWhitespaceLocalName ()
+ {
+ AssertEquals (whitespace.NodeType + " LocalName property broken",
+ whitespace.LocalName, "#significant-whitespace");
+ }
+
+ public void TestXmlSignificantWhitespaceNodeType ()
+ {
+ AssertEquals ("XmlSignificantWhitespace NodeType property broken",
+ whitespace.NodeType.ToString (), "SignificantWhitespace");
+ }
+
+ public void TestXmlSignificantWhitespaceIsReadOnly ()
+ {
+ AssertEquals ("XmlSignificantWhitespace IsReadOnly property broken",
+ whitespace.IsReadOnly, false);
+ }
+
+ public void TestXmlSignificantWhitespaceCloneNode ()
+ {
+ original = whitespace;
+
+ shallow = whitespace.CloneNode (false); // shallow
+ TestXmlNodeBaseProperties (original, shallow);
+
+ deep = whitespace.CloneNode (true); // deep
+ TestXmlNodeBaseProperties (original, deep);
+
+ AssertEquals ("deep cloning differs from shallow cloning",
+ deep.OuterXml, shallow.OuterXml);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/Test/XmlTextReaderTests.cs b/mcs/class/System.XML/Test/XmlTextReaderTests.cs
new file mode 100644
index 00000000000..83d9c8f160d
--- /dev/null
+++ b/mcs/class/System.XML/Test/XmlTextReaderTests.cs
@@ -0,0 +1,1776 @@
+//
+// XmlTextReaderTests.cs
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2001, 2002 Jason Diamond http://injektilo.org/
+//
+
+using System;
+using System.IO;
+using System.Xml;
+using System.Text;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+ public class XmlTextReaderTests : TestCase
+ {
+ public XmlTextReaderTests () : base ("MonoTests.System.Xml.XmlTextReaderTests testsuite") { }
+ public XmlTextReaderTests (string name) : base (name) { }
+
+ private void AssertStartDocument (XmlReader xmlReader)
+ {
+ Assert (xmlReader.ReadState == ReadState.Initial);
+ Assert (xmlReader.NodeType == XmlNodeType.None);
+ Assert (xmlReader.Depth == 0);
+ Assert (!xmlReader.EOF);
+ }
+
+ private void AssertNode (
+ XmlReader xmlReader,
+ XmlNodeType nodeType,
+ int depth,
+ bool isEmptyElement,
+ string name,
+ string prefix,
+ string localName,
+ string namespaceURI,
+ string value,
+ int attributeCount)
+ {
+ Assert (xmlReader.Read ());
+ Assert (xmlReader.ReadState == ReadState.Interactive);
+ Assert (!xmlReader.EOF);
+ AssertNodeValues (xmlReader, nodeType, depth, isEmptyElement, name, prefix, localName, namespaceURI, value, attributeCount);
+ }
+
+ private void AssertNodeValues (
+ XmlReader xmlReader,
+ XmlNodeType nodeType,
+ int depth,
+ bool isEmptyElement,
+ string name,
+ string prefix,
+ string localName,
+ string namespaceURI,
+ string value,
+ int attributeCount)
+ {
+ AssertEquals ("NodeType", nodeType, xmlReader.NodeType);
+ AssertEquals ("Depth", depth, xmlReader.Depth);
+ AssertEquals ("IsEmptyElement", isEmptyElement, xmlReader.IsEmptyElement);
+
+ AssertEquals ("name", name, xmlReader.Name);
+
+ AssertEquals ("prefix", prefix, xmlReader.Prefix);
+
+ AssertEquals ("localName", localName, xmlReader.LocalName);
+
+ AssertEquals ("namespaceURI", namespaceURI, xmlReader.NamespaceURI);
+
+ AssertEquals ("hasValue", (value != String.Empty), xmlReader.HasValue);
+
+ AssertEquals ("Value", value, xmlReader.Value);
+
+ AssertEquals ("hasAttributes", attributeCount > 0, xmlReader.HasAttributes);
+
+ AssertEquals ("attributeCount", attributeCount, xmlReader.AttributeCount);
+ }
+
+ private void AssertAttribute (
+ XmlReader xmlReader,
+ string name,
+ string prefix,
+ string localName,
+ string namespaceURI,
+ string value)
+ {
+ AssertEquals ("value", value, xmlReader [name]);
+
+ Assert (xmlReader.GetAttribute (name) == value);
+
+ if (namespaceURI != String.Empty) {
+ Assert (xmlReader[localName, namespaceURI] == value);
+ Assert (xmlReader.GetAttribute (localName, namespaceURI) == value);
+ }
+ }
+
+ private void AssertEndDocument (XmlReader xmlReader)
+ {
+ Assert ("could read", !xmlReader.Read ());
+ AssertEquals ("NodeType is not XmlNodeType.None", XmlNodeType.None, xmlReader.NodeType);
+ AssertEquals ("Depth is not 0", 0, xmlReader.Depth);
+ AssertEquals ("ReadState is not ReadState.EndOfFile", ReadState.EndOfFile, xmlReader.ReadState);
+ Assert ("not EOF", xmlReader.EOF);
+
+ xmlReader.Close ();
+ AssertEquals ("ReadState is not ReadState.Cosed", ReadState.Closed, xmlReader.ReadState);
+ }
+
+ public void TestEmptyElement ()
+ {
+ string xml = "<foo/>";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ AssertStartDocument (xmlReader);
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 0, // depth
+ true, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertEndDocument (xmlReader);
+ }
+
+ public void TestEmptyElementWithBadName ()
+ {
+ string xml = "<1foo/>";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ bool caughtXmlException = false;
+
+ try {
+ xmlReader.Read();
+ } catch (XmlException) {
+ caughtXmlException = true;
+ }
+
+ Assert(caughtXmlException);
+ }
+
+ public void TestEmptyElementWithWhitespace ()
+ {
+ string xml = "<foo />";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ AssertStartDocument (xmlReader);
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 0, //depth
+ true, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertEndDocument (xmlReader);
+ }
+
+ public void TestEmptyElementWithStartAndEndTag ()
+ {
+ string xml = "<foo></foo>";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ AssertStartDocument (xmlReader);
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 0, //depth
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.EndElement, // nodeType
+ 0, //depth
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertEndDocument (xmlReader);
+ }
+
+ public void TestEmptyElementWithStartAndEndTagWithWhitespace ()
+ {
+ string xml = "<foo ></foo >";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ AssertStartDocument (xmlReader);
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 0, //depth
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.EndElement, // nodeType
+ 0, //depth
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertEndDocument (xmlReader);
+ }
+
+ public void TestNestedEmptyTag ()
+ {
+ string xml = "<foo><bar/></foo>";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ AssertStartDocument (xmlReader);
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 0, //depth
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 1, //depth
+ true, // isEmptyElement
+ "bar", // name
+ String.Empty, // prefix
+ "bar", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.EndElement, // nodeType
+ 0, //depth
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertEndDocument (xmlReader);
+ }
+
+ public void TestNestedText ()
+ {
+ string xml = "<foo>bar</foo>";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ AssertStartDocument (xmlReader);
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 0, //depth
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Text, // nodeType
+ 1, //depth
+ false, // isEmptyElement
+ String.Empty, // name
+ String.Empty, // prefix
+ String.Empty, // localName
+ String.Empty, // namespaceURI
+ "bar", // value
+ 0 // attributeCount
+ );
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.EndElement, // nodeType
+ 0, //depth
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertEndDocument (xmlReader);
+ }
+
+ public void TestEmptyElementWithAttribute ()
+ {
+ string xml = @"<foo bar=""baz""/>";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ AssertStartDocument (xmlReader);
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 0, //depth
+ true, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 1 // attributeCount
+ );
+
+ AssertAttribute (
+ xmlReader, // xmlReader
+ "bar", // name
+ String.Empty, // prefix
+ "bar", // localName
+ String.Empty, // namespaceURI
+ "baz" // value
+ );
+
+ AssertEndDocument (xmlReader);
+ }
+
+ public void TestStartAndEndTagWithAttribute ()
+ {
+ string xml = @"<foo bar='baz'></foo>";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ AssertStartDocument (xmlReader);
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 0, //depth
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 1 // attributeCount
+ );
+
+ AssertAttribute (
+ xmlReader, // xmlReader
+ "bar", // name
+ String.Empty, // prefix
+ "bar", // localName
+ String.Empty, // namespaceURI
+ "baz" // value
+ );
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.EndElement, // nodeType
+ 0, //depth
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertEndDocument (xmlReader);
+ }
+
+ public void TestEmptyElementWithTwoAttributes ()
+ {
+ string xml = @"<foo bar=""baz"" quux='quuux'/>";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ AssertStartDocument (xmlReader);
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 0, //depth
+ true, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 2 // attributeCount
+ );
+
+ AssertAttribute (
+ xmlReader, // xmlReader
+ "bar", // name
+ String.Empty, // prefix
+ "bar", // localName
+ String.Empty, // namespaceURI
+ "baz" // value
+ );
+
+ AssertAttribute (
+ xmlReader, // xmlReader
+ "quux", // name
+ String.Empty, // prefix
+ "quux", // localName
+ String.Empty, // namespaceURI
+ "quuux" // value
+ );
+
+ AssertEndDocument (xmlReader);
+ }
+
+ public void TestProcessingInstructionBeforeDocumentElement ()
+ {
+ string xml = "<?foo bar?><baz/>";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ AssertStartDocument (xmlReader);
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.ProcessingInstruction, // nodeType
+ 0, //depth
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ "bar", // value
+ 0 // attributeCount
+ );
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 0, //depth
+ true, // isEmptyElement
+ "baz", // name
+ String.Empty, // prefix
+ "baz", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertEndDocument (xmlReader);
+ }
+
+ public void TestCommentBeforeDocumentElement ()
+ {
+ string xml = "<!--foo--><bar/>";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ AssertStartDocument (xmlReader);
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Comment, // nodeType
+ 0, //depth
+ false, // isEmptyElement
+ String.Empty, // name
+ String.Empty, // prefix
+ String.Empty, // localName
+ String.Empty, // namespaceURI
+ "foo", // value
+ 0 // attributeCount
+ );
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 0, //depth
+ true, // isEmptyElement
+ "bar", // name
+ String.Empty, // prefix
+ "bar", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertEndDocument (xmlReader);
+ }
+
+ public void TestPredefinedEntities ()
+ {
+ string xml = "<foo>&lt;&gt;&amp;&apos;&quot;</foo>";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ AssertStartDocument (xmlReader);
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 0, //depth
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Text, // nodeType
+ 1, //depth
+ false, // isEmptyElement
+ String.Empty, // name
+ String.Empty, // prefix
+ String.Empty, // localName
+ String.Empty, // namespaceURI
+ "<>&'\"", // value
+ 0 // attributeCount
+ );
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.EndElement, // nodeType
+ 0, //depth
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertEndDocument (xmlReader);
+ }
+
+ public void TestEntityReference ()
+ {
+ string xml = "<foo>&bar;</foo>";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ AssertStartDocument (xmlReader);
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 0, //depth
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.EntityReference, // nodeType
+ 1, //depth
+ false, // isEmptyElement
+ "bar", // name
+ String.Empty, // prefix
+ "bar", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.EndElement, // nodeType
+ 0, //depth
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertEndDocument (xmlReader);
+ }
+
+ public void TestEntityReferenceInsideText ()
+ {
+ string xml = "<foo>bar&baz;quux</foo>";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ AssertStartDocument (xmlReader);
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 0, //depth
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Text, // nodeType
+ 1, //depth
+ false, // isEmptyElement
+ String.Empty, // name
+ String.Empty, // prefix
+ String.Empty, // localName
+ String.Empty, // namespaceURI
+ "bar", // value
+ 0 // attributeCount
+ );
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.EntityReference, // nodeType
+ 1, //depth
+ false, // isEmptyElement
+ "baz", // name
+ String.Empty, // prefix
+ "baz", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Text, // nodeType
+ 1, //depth
+ false, // isEmptyElement
+ String.Empty, // name
+ String.Empty, // prefix
+ String.Empty, // localName
+ String.Empty, // namespaceURI
+ "quux", // value
+ 0 // attributeCount
+ );
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.EndElement, // nodeType
+ 0, //depth
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertEndDocument (xmlReader);
+ }
+
+ public void TestCharacterReferences ()
+ {
+ string xml = "<foo>&#70;&#x4F;&#x4f;</foo>";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ AssertStartDocument (xmlReader);
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 0, //depth
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Text, // nodeType
+ 1, //depth
+ false, // isEmptyElement
+ String.Empty, // name
+ String.Empty, // prefix
+ String.Empty, // localName
+ String.Empty, // namespaceURI
+ "FOO", // value
+ 0 // attributeCount
+ );
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.EndElement, // nodeType
+ 0, //depth
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertEndDocument (xmlReader);
+ }
+
+ public void TestEntityReferenceInAttribute ()
+ {
+ string xml = "<foo bar='&baz;'/>";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ AssertStartDocument (xmlReader);
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 0, //depth
+ true, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 1 // attributeCount
+ );
+
+ AssertAttribute (
+ xmlReader, // xmlReader
+ "bar", // name
+ String.Empty, // prefix
+ "bar", // localName
+ String.Empty, // namespaceURI
+ "&baz;" // value
+ );
+
+ AssertEndDocument (xmlReader);
+ }
+
+ public void TestPredefinedEntitiesInAttribute ()
+ {
+ string xml = "<foo bar='&lt;&gt;&amp;&apos;&quot;'/>";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ AssertStartDocument (xmlReader);
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 0, //depth
+ true, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 1 // attributeCount
+ );
+
+ AssertAttribute (
+ xmlReader, // xmlReader
+ "bar", // name
+ String.Empty, // prefix
+ "bar", // localName
+ String.Empty, // namespaceURI
+ "<>&'\"" // value
+ );
+
+ AssertEndDocument (xmlReader);
+ }
+
+ public void TestCharacterReferencesInAttribute ()
+ {
+ string xml = "<foo bar='&#70;&#x4F;&#x4f;'/>";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ AssertStartDocument (xmlReader);
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 0, //depth
+ true, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 1 // attributeCount
+ );
+
+ AssertAttribute (
+ xmlReader, // xmlReader
+ "bar", // name
+ String.Empty, // prefix
+ "bar", // localName
+ String.Empty, // namespaceURI
+ "FOO" // value
+ );
+
+ AssertEndDocument (xmlReader);
+ }
+
+ public void TestCDATA ()
+ {
+ string xml = "<foo><![CDATA[<>&]]></foo>";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ AssertStartDocument (xmlReader);
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 0, //depth
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.CDATA, // nodeType
+ 1, //depth
+ false, // isEmptyElement
+ String.Empty, // name
+ String.Empty, // prefix
+ String.Empty, // localName
+ String.Empty, // namespaceURI
+ "<>&", // value
+ 0 // attributeCount
+ );
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.EndElement, // nodeType
+ 0, //depth
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertEndDocument (xmlReader);
+ }
+
+ public void TestEmptyElementInNamespace ()
+ {
+ string xml = @"<foo:bar xmlns:foo='http://foo/' />";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ AssertStartDocument (xmlReader);
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 0, // depth
+ true, // isEmptyElement
+ "foo:bar", // name
+ "foo", // prefix
+ "bar", // localName
+ "http://foo/", // namespaceURI
+ String.Empty, // value
+ 1 // attributeCount
+ );
+
+ AssertAttribute (
+ xmlReader, // xmlReader
+ "xmlns:foo", // name
+ "xmlns", // prefix
+ "foo", // localName
+ "http://www.w3.org/2000/xmlns/", // namespaceURI
+ "http://foo/" // value
+ );
+
+ AssertEquals ("http://foo/", xmlReader.LookupNamespace ("foo"));
+
+ AssertEndDocument (xmlReader);
+ }
+
+ public void TestEmptyElementInDefaultNamespace ()
+ {
+ string xml = @"<foo xmlns='http://foo/' />";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ AssertStartDocument (xmlReader);
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 0, // depth
+ true, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ "http://foo/", // namespaceURI
+ String.Empty, // value
+ 1 // attributeCount
+ );
+
+ AssertAttribute (
+ xmlReader, // xmlReader
+ "xmlns", // name
+ String.Empty, // prefix
+ "xmlns", // localName
+ "http://www.w3.org/2000/xmlns/", // namespaceURI
+ "http://foo/" // value
+ );
+
+ AssertEquals ("http://foo/", xmlReader.LookupNamespace (String.Empty));
+
+ AssertEndDocument (xmlReader);
+ }
+
+ public void TestChildElementInNamespace ()
+ {
+ string xml = @"<foo:bar xmlns:foo='http://foo/'><baz:quux xmlns:baz='http://baz/' /></foo:bar>";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ AssertStartDocument (xmlReader);
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 0, // depth
+ false, // isEmptyElement
+ "foo:bar", // name
+ "foo", // prefix
+ "bar", // localName
+ "http://foo/", // namespaceURI
+ String.Empty, // value
+ 1 // attributeCount
+ );
+
+ AssertAttribute (
+ xmlReader, // xmlReader
+ "xmlns:foo", // name
+ "xmlns", // prefix
+ "foo", // localName
+ "http://www.w3.org/2000/xmlns/", // namespaceURI
+ "http://foo/" // value
+ );
+
+ AssertEquals ("http://foo/", xmlReader.LookupNamespace ("foo"));
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 1, // depth
+ true, // isEmptyElement
+ "baz:quux", // name
+ "baz", // prefix
+ "quux", // localName
+ "http://baz/", // namespaceURI
+ String.Empty, // value
+ 1 // attributeCount
+ );
+
+ AssertAttribute (
+ xmlReader, // xmlReader
+ "xmlns:baz", // name
+ "xmlns", // prefix
+ "baz", // localName
+ "http://www.w3.org/2000/xmlns/", // namespaceURI
+ "http://baz/" // value
+ );
+
+ AssertEquals ("http://foo/", xmlReader.LookupNamespace ("foo"));
+ AssertEquals ("http://baz/", xmlReader.LookupNamespace ("baz"));
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.EndElement, // nodeType
+ 0, // depth
+ false, // isEmptyElement
+ "foo:bar", // name
+ "foo", // prefix
+ "bar", // localName
+ "http://foo/", // namespaceURI
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertEquals ("http://foo/", xmlReader.LookupNamespace ("foo"));
+ AssertNull (xmlReader.LookupNamespace ("baz"));
+
+ AssertEndDocument (xmlReader);
+ }
+
+ public void TestChildElementInDefaultNamespace ()
+ {
+ string xml = @"<foo:bar xmlns:foo='http://foo/'><baz xmlns='http://baz/' /></foo:bar>";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ AssertStartDocument (xmlReader);
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 0, // depth
+ false, // isEmptyElement
+ "foo:bar", // name
+ "foo", // prefix
+ "bar", // localName
+ "http://foo/", // namespaceURI
+ String.Empty, // value
+ 1 // attributeCount
+ );
+
+ AssertAttribute (
+ xmlReader, // xmlReader
+ "xmlns:foo", // name
+ "xmlns", // prefix
+ "foo", // localName
+ "http://www.w3.org/2000/xmlns/", // namespaceURI
+ "http://foo/" // value
+ );
+
+ AssertEquals ("http://foo/", xmlReader.LookupNamespace ("foo"));
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 1, // depth
+ true, // isEmptyElement
+ "baz", // name
+ String.Empty, // prefix
+ "baz", // localName
+ "http://baz/", // namespaceURI
+ String.Empty, // value
+ 1 // attributeCount
+ );
+
+ AssertAttribute (
+ xmlReader, // xmlReader
+ "xmlns", // name
+ String.Empty, // prefix
+ "xmlns", // localName
+ "http://www.w3.org/2000/xmlns/", // namespaceURI
+ "http://baz/" // value
+ );
+
+ AssertEquals ("http://foo/", xmlReader.LookupNamespace ("foo"));
+ AssertEquals ("http://baz/", xmlReader.LookupNamespace (String.Empty));
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.EndElement, // nodeType
+ 0, // depth
+ false, // isEmptyElement
+ "foo:bar", // name
+ "foo", // prefix
+ "bar", // localName
+ "http://foo/", // namespaceURI
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertEquals ("http://foo/", xmlReader.LookupNamespace ("foo"));
+
+ AssertEndDocument (xmlReader);
+ }
+
+ public void TestAttributeInNamespace ()
+ {
+ string xml = @"<foo bar:baz='quux' xmlns:bar='http://bar/' />";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ AssertStartDocument (xmlReader);
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 0, // depth
+ true, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 2 // attributeCount
+ );
+
+ AssertAttribute (
+ xmlReader, // xmlReader
+ "bar:baz", // name
+ "bar", // prefix
+ "baz", // localName
+ "http://bar/", // namespaceURI
+ "quux" // value
+ );
+
+ AssertAttribute (
+ xmlReader, // xmlReader
+ "xmlns:bar", // name
+ "xmlns", // prefix
+ "bar", // localName
+ "http://www.w3.org/2000/xmlns/", // namespaceURI
+ "http://bar/" // value
+ );
+
+ AssertEquals ("http://bar/", xmlReader.LookupNamespace ("bar"));
+
+ AssertEndDocument (xmlReader);
+ }
+
+// The following is #if'ed out because it's specific to the Mono
+// implementation and won't compile when testing Microsoft's code.
+// Feel free to turn it on if you want to test Mono's name tables.
+
+#if false
+
+ public void TestIsFirstNameChar ()
+ {
+ for (int ch = 0; ch <= 0xFFFF; ++ch) {
+ Assert (
+ XmlChar.IsFirstNameChar (ch) ==
+ IsFirstNameChar (ch));
+ }
+ }
+
+ public void TestIsNameChar ()
+ {
+ for (int ch = 0; ch <= 0xFFFF; ++ch) {
+ Assert (
+ XmlChar.IsNameChar (ch) ==
+ IsNameChar (ch));
+ }
+ }
+
+ private static bool IsFirstNameChar (int ch)
+ {
+ return
+ IsLetter (ch) ||
+ (ch == '_') ||
+ (ch == ':');
+ }
+
+ private static bool IsNameChar (int ch)
+ {
+ return
+ IsLetter (ch) ||
+ IsDigit (ch) ||
+ (ch == '.') ||
+ (ch == '-') ||
+ (ch == '_') ||
+ (ch == ':') ||
+ IsCombiningChar (ch) ||
+ IsExtender (ch);
+ }
+
+ private static bool IsLetter (int ch)
+ {
+ return
+ IsBaseChar (ch) ||
+ IsIdeographic (ch);
+ }
+
+ private static bool IsBaseChar (int ch)
+ {
+ return
+ (ch >= 0x0041 && ch <= 0x005A) ||
+ (ch >= 0x0061 && ch <= 0x007A) ||
+ (ch >= 0x00C0 && ch <= 0x00D6) ||
+ (ch >= 0x00D8 && ch <= 0x00F6) ||
+ (ch >= 0x00F8 && ch <= 0x00FF) ||
+ (ch >= 0x0100 && ch <= 0x0131) ||
+ (ch >= 0x0134 && ch <= 0x013E) ||
+ (ch >= 0x0141 && ch <= 0x0148) ||
+ (ch >= 0x014A && ch <= 0x017E) ||
+ (ch >= 0x0180 && ch <= 0x01C3) ||
+ (ch >= 0x01CD && ch <= 0x01F0) ||
+ (ch >= 0x01F4 && ch <= 0x01F5) ||
+ (ch >= 0x01FA && ch <= 0x0217) ||
+ (ch >= 0x0250 && ch <= 0x02A8) ||
+ (ch >= 0x02BB && ch <= 0x02C1) ||
+ (ch == 0x0386) ||
+ (ch >= 0x0388 && ch <= 0x038A) ||
+ (ch == 0x038C) ||
+ (ch >= 0x038E && ch <= 0x03A1) ||
+ (ch >= 0x03A3 && ch <= 0x03CE) ||
+ (ch >= 0x03D0 && ch <= 0x03D6) ||
+ (ch == 0x03DA) ||
+ (ch == 0x03DC) ||
+ (ch == 0x03DE) ||
+ (ch == 0x03E0) ||
+ (ch >= 0x03E2 && ch <= 0x03F3) ||
+ (ch >= 0x0401 && ch <= 0x040C) ||
+ (ch >= 0x040E && ch <= 0x044F) ||
+ (ch >= 0x0451 && ch <= 0x045C) ||
+ (ch >= 0x045E && ch <= 0x0481) ||
+ (ch >= 0x0490 && ch <= 0x04C4) ||
+ (ch >= 0x04C7 && ch <= 0x04C8) ||
+ (ch >= 0x04CB && ch <= 0x04CC) ||
+ (ch >= 0x04D0 && ch <= 0x04EB) ||
+ (ch >= 0x04EE && ch <= 0x04F5) ||
+ (ch >= 0x04F8 && ch <= 0x04F9) ||
+ (ch >= 0x0531 && ch <= 0x0556) ||
+ (ch == 0x0559) ||
+ (ch >= 0x0561 && ch <= 0x0586) ||
+ (ch >= 0x05D0 && ch <= 0x05EA) ||
+ (ch >= 0x05F0 && ch <= 0x05F2) ||
+ (ch >= 0x0621 && ch <= 0x063A) ||
+ (ch >= 0x0641 && ch <= 0x064A) ||
+ (ch >= 0x0671 && ch <= 0x06B7) ||
+ (ch >= 0x06BA && ch <= 0x06BE) ||
+ (ch >= 0x06C0 && ch <= 0x06CE) ||
+ (ch >= 0x06D0 && ch <= 0x06D3) ||
+ (ch == 0x06D5) ||
+ (ch >= 0x06E5 && ch <= 0x06E6) ||
+ (ch >= 0x0905 && ch <= 0x0939) ||
+ (ch == 0x093D) ||
+ (ch >= 0x0958 && ch <= 0x0961) ||
+ (ch >= 0x0985 && ch <= 0x098C) ||
+ (ch >= 0x098F && ch <= 0x0990) ||
+ (ch >= 0x0993 && ch <= 0x09A8) ||
+ (ch >= 0x09AA && ch <= 0x09B0) ||
+ (ch == 0x09B2) ||
+ (ch >= 0x09B6 && ch <= 0x09B9) ||
+ (ch >= 0x09DC && ch <= 0x09DD) ||
+ (ch >= 0x09DF && ch <= 0x09E1) ||
+ (ch >= 0x09F0 && ch <= 0x09F1) ||
+ (ch >= 0x0A05 && ch <= 0x0A0A) ||
+ (ch >= 0x0A0F && ch <= 0x0A10) ||
+ (ch >= 0x0A13 && ch <= 0x0A28) ||
+ (ch >= 0x0A2A && ch <= 0x0A30) ||
+ (ch >= 0x0A32 && ch <= 0x0A33) ||
+ (ch >= 0x0A35 && ch <= 0x0A36) ||
+ (ch >= 0x0A38 && ch <= 0x0A39) ||
+ (ch >= 0x0A59 && ch <= 0x0A5C) ||
+ (ch == 0x0A5E) ||
+ (ch >= 0x0A72 && ch <= 0x0A74) ||
+ (ch >= 0x0A85 && ch <= 0x0A8B) ||
+ (ch == 0x0A8D) ||
+ (ch >= 0x0A8F && ch <= 0x0A91) ||
+ (ch >= 0x0A93 && ch <= 0x0AA8) ||
+ (ch >= 0x0AAA && ch <= 0x0AB0) ||
+ (ch >= 0x0AB2 && ch <= 0x0AB3) ||
+ (ch >= 0x0AB5 && ch <= 0x0AB9) ||
+ (ch == 0x0ABD) ||
+ (ch == 0x0AE0) ||
+ (ch >= 0x0B05 && ch <= 0x0B0C) ||
+ (ch >= 0x0B0F && ch <= 0x0B10) ||
+ (ch >= 0x0B13 && ch <= 0x0B28) ||
+ (ch >= 0x0B2A && ch <= 0x0B30) ||
+ (ch >= 0x0B32 && ch <= 0x0B33) ||
+ (ch >= 0x0B36 && ch <= 0x0B39) ||
+ (ch == 0x0B3D) ||
+ (ch >= 0x0B5C && ch <= 0x0B5D) ||
+ (ch >= 0x0B5F && ch <= 0x0B61) ||
+ (ch >= 0x0B85 && ch <= 0x0B8A) ||
+ (ch >= 0x0B8E && ch <= 0x0B90) ||
+ (ch >= 0x0B92 && ch <= 0x0B95) ||
+ (ch >= 0x0B99 && ch <= 0x0B9A) ||
+ (ch == 0x0B9C) ||
+ (ch >= 0x0B9E && ch <= 0x0B9F) ||
+ (ch >= 0x0BA3 && ch <= 0x0BA4) ||
+ (ch >= 0x0BA8 && ch <= 0x0BAA) ||
+ (ch >= 0x0BAE && ch <= 0x0BB5) ||
+ (ch >= 0x0BB7 && ch <= 0x0BB9) ||
+ (ch >= 0x0C05 && ch <= 0x0C0C) ||
+ (ch >= 0x0C0E && ch <= 0x0C10) ||
+ (ch >= 0x0C12 && ch <= 0x0C28) ||
+ (ch >= 0x0C2A && ch <= 0x0C33) ||
+ (ch >= 0x0C35 && ch <= 0x0C39) ||
+ (ch >= 0x0C60 && ch <= 0x0C61) ||
+ (ch >= 0x0C85 && ch <= 0x0C8C) ||
+ (ch >= 0x0C8E && ch <= 0x0C90) ||
+ (ch >= 0x0C92 && ch <= 0x0CA8) ||
+ (ch >= 0x0CAA && ch <= 0x0CB3) ||
+ (ch >= 0x0CB5 && ch <= 0x0CB9) ||
+ (ch == 0x0CDE) ||
+ (ch >= 0x0CE0 && ch <= 0x0CE1) ||
+ (ch >= 0x0D05 && ch <= 0x0D0C) ||
+ (ch >= 0x0D0E && ch <= 0x0D10) ||
+ (ch >= 0x0D12 && ch <= 0x0D28) ||
+ (ch >= 0x0D2A && ch <= 0x0D39) ||
+ (ch >= 0x0D60 && ch <= 0x0D61) ||
+ (ch >= 0x0E01 && ch <= 0x0E2E) ||
+ (ch == 0x0E30) ||
+ (ch >= 0x0E32 && ch <= 0x0E33) ||
+ (ch >= 0x0E40 && ch <= 0x0E45) ||
+ (ch >= 0x0E81 && ch <= 0x0E82) ||
+ (ch == 0x0E84) ||
+ (ch >= 0x0E87 && ch <= 0x0E88) ||
+ (ch == 0x0E8A) ||
+ (ch == 0x0E8D) ||
+ (ch >= 0x0E94 && ch <= 0x0E97) ||
+ (ch >= 0x0E99 && ch <= 0x0E9F) ||
+ (ch >= 0x0EA1 && ch <= 0x0EA3) ||
+ (ch == 0x0EA5) ||
+ (ch == 0x0EA7) ||
+ (ch >= 0x0EAA && ch <= 0x0EAB) ||
+ (ch >= 0x0EAD && ch <= 0x0EAE) ||
+ (ch == 0x0EB0) ||
+ (ch >= 0x0EB2 && ch <= 0x0EB3) ||
+ (ch == 0x0EBD) ||
+ (ch >= 0x0EC0 && ch <= 0x0EC4) ||
+ (ch >= 0x0F40 && ch <= 0x0F47) ||
+ (ch >= 0x0F49 && ch <= 0x0F69) ||
+ (ch >= 0x10A0 && ch <= 0x10C5) ||
+ (ch >= 0x10D0 && ch <= 0x10F6) ||
+ (ch == 0x1100) ||
+ (ch >= 0x1102 && ch <= 0x1103) ||
+ (ch >= 0x1105 && ch <= 0x1107) ||
+ (ch == 0x1109) ||
+ (ch >= 0x110B && ch <= 0x110C) ||
+ (ch >= 0x110E && ch <= 0x1112) ||
+ (ch == 0x113C) ||
+ (ch == 0x113E) ||
+ (ch == 0x1140) ||
+ (ch == 0x114C) ||
+ (ch == 0x114E) ||
+ (ch == 0x1150) ||
+ (ch >= 0x1154 && ch <= 0x1155) ||
+ (ch == 0x1159) ||
+ (ch >= 0x115F && ch <= 0x1161) ||
+ (ch == 0x1163) ||
+ (ch == 0x1165) ||
+ (ch == 0x1167) ||
+ (ch == 0x1169) ||
+ (ch >= 0x116D && ch <= 0x116E) ||
+ (ch >= 0x1172 && ch <= 0x1173) ||
+ (ch == 0x1175) ||
+ (ch == 0x119E) ||
+ (ch == 0x11A8) ||
+ (ch == 0x11AB) ||
+ (ch >= 0x11AE && ch <= 0x11AF) ||
+ (ch >= 0x11B7 && ch <= 0x11B8) ||
+ (ch == 0x11BA) ||
+ (ch >= 0x11BC && ch <= 0x11C2) ||
+ (ch == 0x11EB) ||
+ (ch == 0x11F0) ||
+ (ch == 0x11F9) ||
+ (ch >= 0x1E00 && ch <= 0x1E9B) ||
+ (ch >= 0x1EA0 && ch <= 0x1EF9) ||
+ (ch >= 0x1F00 && ch <= 0x1F15) ||
+ (ch >= 0x1F18 && ch <= 0x1F1D) ||
+ (ch >= 0x1F20 && ch <= 0x1F45) ||
+ (ch >= 0x1F48 && ch <= 0x1F4D) ||
+ (ch >= 0x1F50 && ch <= 0x1F57) ||
+ (ch == 0x1F59) ||
+ (ch == 0x1F5B) ||
+ (ch == 0x1F5D) ||
+ (ch >= 0x1F5F && ch <= 0x1F7D) ||
+ (ch >= 0x1F80 && ch <= 0x1FB4) ||
+ (ch >= 0x1FB6 && ch <= 0x1FBC) ||
+ (ch == 0x1FBE) ||
+ (ch >= 0x1FC2 && ch <= 0x1FC4) ||
+ (ch >= 0x1FC6 && ch <= 0x1FCC) ||
+ (ch >= 0x1FD0 && ch <= 0x1FD3) ||
+ (ch >= 0x1FD6 && ch <= 0x1FDB) ||
+ (ch >= 0x1FE0 && ch <= 0x1FEC) ||
+ (ch >= 0x1FF2 && ch <= 0x1FF4) ||
+ (ch >= 0x1FF6 && ch <= 0x1FFC) ||
+ (ch == 0x2126) ||
+ (ch >= 0x212A && ch <= 0x212B) ||
+ (ch == 0x212E) ||
+ (ch >= 0x2180 && ch <= 0x2182) ||
+ (ch >= 0x3041 && ch <= 0x3094) ||
+ (ch >= 0x30A1 && ch <= 0x30FA) ||
+ (ch >= 0x3105 && ch <= 0x312C) ||
+ (ch >= 0xAC00 && ch <= 0xD7A3);
+ }
+
+ private static bool IsIdeographic (int ch)
+ {
+ return
+ (ch >= 0x4E00 && ch <= 0x9FA5) ||
+ (ch == 0x3007) ||
+ (ch >= 0x3021 && ch <= 0x3029);
+ }
+
+ private static bool IsDigit (int ch)
+ {
+ return
+ (ch >= 0x0030 && ch <= 0x0039) ||
+ (ch >= 0x0660 && ch <= 0x0669) ||
+ (ch >= 0x06F0 && ch <= 0x06F9) ||
+ (ch >= 0x0966 && ch <= 0x096F) ||
+ (ch >= 0x09E6 && ch <= 0x09EF) ||
+ (ch >= 0x0A66 && ch <= 0x0A6F) ||
+ (ch >= 0x0AE6 && ch <= 0x0AEF) ||
+ (ch >= 0x0B66 && ch <= 0x0B6F) ||
+ (ch >= 0x0BE7 && ch <= 0x0BEF) ||
+ (ch >= 0x0C66 && ch <= 0x0C6F) ||
+ (ch >= 0x0CE6 && ch <= 0x0CEF) ||
+ (ch >= 0x0D66 && ch <= 0x0D6F) ||
+ (ch >= 0x0E50 && ch <= 0x0E59) ||
+ (ch >= 0x0ED0 && ch <= 0x0ED9) ||
+ (ch >= 0x0F20 && ch <= 0x0F29);
+ }
+
+ private static bool IsCombiningChar (int ch)
+ {
+ return
+ (ch >= 0x0300 && ch <= 0x0345) ||
+ (ch >= 0x0360 && ch <= 0x0361) ||
+ (ch >= 0x0483 && ch <= 0x0486) ||
+ (ch >= 0x0591 && ch <= 0x05A1) ||
+ (ch >= 0x05A3 && ch <= 0x05B9) ||
+ (ch >= 0x05BB && ch <= 0x05BD) ||
+ (ch == 0x05BF) ||
+ (ch >= 0x05C1 && ch <= 0x05C2) ||
+ (ch == 0x05C4) ||
+ (ch >= 0x064B && ch <= 0x0652) ||
+ (ch == 0x0670) ||
+ (ch >= 0x06D6 && ch <= 0x06DC) ||
+ (ch >= 0x06DD && ch <= 0x06DF) ||
+ (ch >= 0x06E0 && ch <= 0x06E4) ||
+ (ch >= 0x06E7 && ch <= 0x06E8) ||
+ (ch >= 0x06EA && ch <= 0x06ED) ||
+ (ch >= 0x0901 && ch <= 0x0903) ||
+ (ch == 0x093C) ||
+ (ch >= 0x093E && ch <= 0x094C) ||
+ (ch == 0x094D) ||
+ (ch >= 0x0951 && ch <= 0x0954) ||
+ (ch >= 0x0962 && ch <= 0x0963) ||
+ (ch >= 0x0981 && ch <= 0x0983) ||
+ (ch == 0x09BC) ||
+ (ch == 0x09BE) ||
+ (ch == 0x09BF) ||
+ (ch >= 0x09C0 && ch <= 0x09C4) ||
+ (ch >= 0x09C7 && ch <= 0x09C8) ||
+ (ch >= 0x09CB && ch <= 0x09CD) ||
+ (ch == 0x09D7) ||
+ (ch >= 0x09E2 && ch <= 0x09E3) ||
+ (ch == 0x0A02) ||
+ (ch == 0x0A3C) ||
+ (ch == 0x0A3E) ||
+ (ch == 0x0A3F) ||
+ (ch >= 0x0A40 && ch <= 0x0A42) ||
+ (ch >= 0x0A47 && ch <= 0x0A48) ||
+ (ch >= 0x0A4B && ch <= 0x0A4D) ||
+ (ch >= 0x0A70 && ch <= 0x0A71) ||
+ (ch >= 0x0A81 && ch <= 0x0A83) ||
+ (ch == 0x0ABC) ||
+ (ch >= 0x0ABE && ch <= 0x0AC5) ||
+ (ch >= 0x0AC7 && ch <= 0x0AC9) ||
+ (ch >= 0x0ACB && ch <= 0x0ACD) ||
+ (ch >= 0x0B01 && ch <= 0x0B03) ||
+ (ch == 0x0B3C) ||
+ (ch >= 0x0B3E && ch <= 0x0B43) ||
+ (ch >= 0x0B47 && ch <= 0x0B48) ||
+ (ch >= 0x0B4B && ch <= 0x0B4D) ||
+ (ch >= 0x0B56 && ch <= 0x0B57) ||
+ (ch >= 0x0B82 && ch <= 0x0B83) ||
+ (ch >= 0x0BBE && ch <= 0x0BC2) ||
+ (ch >= 0x0BC6 && ch <= 0x0BC8) ||
+ (ch >= 0x0BCA && ch <= 0x0BCD) ||
+ (ch == 0x0BD7) ||
+ (ch >= 0x0C01 && ch <= 0x0C03) ||
+ (ch >= 0x0C3E && ch <= 0x0C44) ||
+ (ch >= 0x0C46 && ch <= 0x0C48) ||
+ (ch >= 0x0C4A && ch <= 0x0C4D) ||
+ (ch >= 0x0C55 && ch <= 0x0C56) ||
+ (ch >= 0x0C82 && ch <= 0x0C83) ||
+ (ch >= 0x0CBE && ch <= 0x0CC4) ||
+ (ch >= 0x0CC6 && ch <= 0x0CC8) ||
+ (ch >= 0x0CCA && ch <= 0x0CCD) ||
+ (ch >= 0x0CD5 && ch <= 0x0CD6) ||
+ (ch >= 0x0D02 && ch <= 0x0D03) ||
+ (ch >= 0x0D3E && ch <= 0x0D43) ||
+ (ch >= 0x0D46 && ch <= 0x0D48) ||
+ (ch >= 0x0D4A && ch <= 0x0D4D) ||
+ (ch == 0x0D57) ||
+ (ch == 0x0E31) ||
+ (ch >= 0x0E34 && ch <= 0x0E3A) ||
+ (ch >= 0x0E47 && ch <= 0x0E4E) ||
+ (ch == 0x0EB1) ||
+ (ch >= 0x0EB4 && ch <= 0x0EB9) ||
+ (ch >= 0x0EBB && ch <= 0x0EBC) ||
+ (ch >= 0x0EC8 && ch <= 0x0ECD) ||
+ (ch >= 0x0F18 && ch <= 0x0F19) ||
+ (ch == 0x0F35) ||
+ (ch == 0x0F37) ||
+ (ch == 0x0F39) ||
+ (ch == 0x0F3E) ||
+ (ch == 0x0F3F) ||
+ (ch >= 0x0F71 && ch <= 0x0F84) ||
+ (ch >= 0x0F86 && ch <= 0x0F8B) ||
+ (ch >= 0x0F90 && ch <= 0x0F95) ||
+ (ch == 0x0F97) ||
+ (ch >= 0x0F99 && ch <= 0x0FAD) ||
+ (ch >= 0x0FB1 && ch <= 0x0FB7) ||
+ (ch == 0x0FB9) ||
+ (ch >= 0x20D0 && ch <= 0x20DC) ||
+ (ch == 0x20E1) ||
+ (ch >= 0x302A && ch <= 0x302F) ||
+ (ch == 0x3099) ||
+ (ch == 0x309A);
+ }
+
+ private static bool IsExtender (int ch)
+ {
+ return
+ (ch == 0x00B7) ||
+ (ch == 0x02D0) ||
+ (ch == 0x02D1) ||
+ (ch == 0x0387) ||
+ (ch == 0x0640) ||
+ (ch == 0x0E46) ||
+ (ch == 0x0EC6) ||
+ (ch == 0x3005) ||
+ (ch >= 0x3031 && ch <= 0x3035) ||
+ (ch >= 0x309D && ch <= 0x309E) ||
+ (ch >= 0x30FC && ch <= 0x30FE);
+ }
+
+#endif
+
+ public void TestIsName ()
+ {
+ Assert (XmlReader.IsName ("foo"));
+ Assert (!XmlReader.IsName ("1foo"));
+ Assert (!XmlReader.IsName (" foo"));
+ }
+
+ public void TestIsNameToken ()
+ {
+ Assert (XmlReader.IsNameToken ("foo"));
+ Assert (XmlReader.IsNameToken ("1foo"));
+ Assert (!XmlReader.IsNameToken (" foo"));
+ }
+
+ public void TestMoveToElementFromAttribute ()
+ {
+ string xml = @"<foo bar=""baz"" />";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ Assert (xmlReader.Read ());
+ AssertEquals (XmlNodeType.Element, xmlReader.NodeType);
+ Assert (xmlReader.MoveToFirstAttribute ());
+ AssertEquals (XmlNodeType.Attribute, xmlReader.NodeType);
+ Assert (xmlReader.MoveToElement ());
+ AssertEquals (XmlNodeType.Element, xmlReader.NodeType);
+ }
+
+ public void TestMoveToElementFromElement ()
+ {
+ string xml = @"<foo bar=""baz"" />";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ Assert (xmlReader.Read ());
+ AssertEquals (XmlNodeType.Element, xmlReader.NodeType);
+ Assert (!xmlReader.MoveToElement ());
+ AssertEquals (XmlNodeType.Element, xmlReader.NodeType);
+ }
+
+ public void TestMoveToFirstAttributeWithNoAttributes ()
+ {
+ string xml = @"<foo />";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ Assert (xmlReader.Read ());
+ AssertEquals (XmlNodeType.Element, xmlReader.NodeType);
+ Assert (!xmlReader.MoveToFirstAttribute ());
+ AssertEquals (XmlNodeType.Element, xmlReader.NodeType);
+ }
+
+ public void TestMoveToNextAttributeWithNoAttributes ()
+ {
+ string xml = @"<foo />";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ Assert (xmlReader.Read ());
+ AssertEquals (XmlNodeType.Element, xmlReader.NodeType);
+ Assert (!xmlReader.MoveToNextAttribute ());
+ AssertEquals (XmlNodeType.Element, xmlReader.NodeType);
+ }
+
+ public void TestMoveToNextAttribute()
+ {
+ string xml = @"<foo bar=""baz"" quux='quuux'/>";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ AssertStartDocument (xmlReader);
+
+ AssertNode (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 0, //depth
+ true, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 2 // attributeCount
+ );
+
+ AssertAttribute (
+ xmlReader, // xmlReader
+ "bar", // name
+ String.Empty, // prefix
+ "bar", // localName
+ String.Empty, // namespaceURI
+ "baz" // value
+ );
+
+ AssertAttribute (
+ xmlReader, // xmlReader
+ "quux", // name
+ String.Empty, // prefix
+ "quux", // localName
+ String.Empty, // namespaceURI
+ "quuux" // value
+ );
+
+ Assert (xmlReader.MoveToNextAttribute ());
+ Assert ("bar" == xmlReader.Name || "quux" == xmlReader.Name);
+ Assert ("baz" == xmlReader.Value || "quuux" == xmlReader.Value);
+
+ Assert (xmlReader.MoveToNextAttribute ());
+ Assert ("bar" == xmlReader.Name || "quux" == xmlReader.Name);
+ Assert ("baz" == xmlReader.Value || "quuux" == xmlReader.Value);
+
+ Assert (!xmlReader.MoveToNextAttribute ());
+
+ Assert (xmlReader.MoveToElement ());
+
+ AssertNodeValues (
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ 0, //depth
+ true, // isEmptyElement
+ "foo", // name
+ String.Empty, // prefix
+ "foo", // localName
+ String.Empty, // namespaceURI
+ String.Empty, // value
+ 2 // attributeCount
+ );
+
+ AssertEndDocument (xmlReader);
+ }
+
+ public void TestAttributeOrder ()
+ {
+ string xml = @"<foo _1='1' _2='2' _3='3' />";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+
+ Assert (xmlReader.Read ());
+ AssertEquals (XmlNodeType.Element, xmlReader.NodeType);
+
+ Assert (xmlReader.MoveToFirstAttribute ());
+ AssertEquals ("_1", xmlReader.Name);
+ Assert (xmlReader.MoveToNextAttribute ());
+ AssertEquals ("_2", xmlReader.Name);
+ Assert (xmlReader.MoveToNextAttribute ());
+ AssertEquals ("_3", xmlReader.Name);
+
+ Assert (!xmlReader.MoveToNextAttribute ());
+ }
+
+ public void TestFragmentConstructor()
+ {
+ XmlDocument doc = new XmlDocument();
+// doc.LoadXml("<root/>");
+
+ string xml = @"<foo><bar xmlns=""NSURI"">TEXT NODE</bar></foo>";
+ MemoryStream ms = new MemoryStream(Encoding.Default.GetBytes(xml));
+
+ XmlParserContext ctx = new XmlParserContext(doc.NameTable, new XmlNamespaceManager(doc.NameTable), "", "", "", "",
+ doc.BaseURI, "", XmlSpace.Default, Encoding.Default);
+
+ XmlTextReader xmlReader = new XmlTextReader(ms, XmlNodeType.Element, ctx);
+ AssertNode(xmlReader, XmlNodeType.Element, 0, false, "foo", "", "foo", "", "", 0);
+
+ AssertNode(xmlReader, XmlNodeType.Element, 1, false, "bar", "", "bar", "NSURI", "", 1);
+
+ AssertNode(xmlReader, XmlNodeType.Text, 2, false, "", "", "", "NSURI", "TEXT NODE", 0);
+
+ AssertNode(xmlReader, XmlNodeType.EndElement, 1, false, "bar", "", "bar", "NSURI", "", 0);
+
+ AssertNode(xmlReader, XmlNodeType.EndElement, 0, false, "foo", "", "foo", "", "", 0);
+
+ AssertEndDocument (xmlReader);
+ }
+
+ public void TestAttributeWithEntityReference ()
+ {
+ string xml = @"<a value='hello &amp; world' />";
+ XmlReader xmlReader =
+ new XmlTextReader (new StringReader (xml));
+ xmlReader.Read ();
+ AssertEquals ("hello & world", xmlReader ["value"]);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/Test/XmlTextTests.cs b/mcs/class/System.XML/Test/XmlTextTests.cs
new file mode 100644
index 00000000000..a885402e354
--- /dev/null
+++ b/mcs/class/System.XML/Test/XmlTextTests.cs
@@ -0,0 +1,36 @@
+//
+// System.Xml.XmlTextWriterTests
+//
+// Author:
+// Kral Ferch <kral_ferch@hotmail.com>
+//
+// (C) 2002 Kral Ferch
+//
+
+using System;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+ public class XmlTextTests : TestCase
+ {
+ public XmlTextTests () : base ("MonoTests.System.Xml.XmlTextTests testsuite") {}
+ public XmlTextTests (string name) : base (name) {}
+
+ XmlDocument document;
+ XmlText text;
+
+ protected override void SetUp ()
+ {
+ document = new XmlDocument ();
+ }
+
+ public void TestInnerAndOuterXml ()
+ {
+ text = document.CreateTextNode ("&<>\"'");
+ AssertEquals (String.Empty, text.InnerXml);
+ AssertEquals ("&amp;&lt;&gt;\"'", text.OuterXml);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/Test/XmlTextWriterTests.cs b/mcs/class/System.XML/Test/XmlTextWriterTests.cs
new file mode 100644
index 00000000000..4643fdcbe6c
--- /dev/null
+++ b/mcs/class/System.XML/Test/XmlTextWriterTests.cs
@@ -0,0 +1,943 @@
+//
+// System.Xml.XmlTextWriterTests
+//
+// Author:
+// Kral Ferch <kral_ferch@hotmail.com>
+//
+// (C) 2002 Kral Ferch
+//
+
+using System;
+using System.IO;
+using System.Text;
+using System.Xml;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+ public class XmlTextWriterTests : TestCase
+ {
+ public XmlTextWriterTests () : base ("MonoTests.System.Xml.XmlTextWriterTests testsuite") {}
+ public XmlTextWriterTests (string name) : base (name) {}
+
+ StringWriter sw;
+ XmlTextWriter xtw;
+
+ protected override void SetUp ()
+ {
+ sw = new StringWriter ();
+ xtw = new XmlTextWriter (sw);
+ xtw.QuoteChar = '\'';
+ }
+
+ private string StringWriterText
+ {
+ get { return sw.GetStringBuilder ().ToString (); }
+ }
+
+ public void TestAttributeNamespacesNonNamespaceAttributeBefore ()
+ {
+ xtw.WriteStartElement ("foo");
+ xtw.WriteAttributeString("bar", "baz");
+ xtw.WriteAttributeString ("xmlns", "abc", null, "http://abc.def");
+ AssertEquals ("<foo bar='baz' xmlns:abc='http://abc.def'", StringWriterText);
+ }
+
+ public void TestAttributeNamespacesNonNamespaceAttributeAfter ()
+ {
+ xtw.WriteStartElement ("foo");
+
+ xtw.WriteAttributeString ("xmlns", "abc", null, "http://abc.def");
+ xtw.WriteAttributeString("bar", "baz");
+ AssertEquals ("<foo xmlns:abc='http://abc.def' bar='baz'", StringWriterText);
+ }
+
+ public void TestAttributeNamespacesThreeParamWithNullInNamespaceParam ()
+ {
+ xtw.WriteAttributeString ("xmlns", null, "http://abc.def");
+ AssertEquals ("xmlns='http://abc.def'", StringWriterText);
+ }
+
+ public void TestAttributeNamespacesThreeParamWithTextInNamespaceParam ()
+ {
+ try
+ {
+ xtw.WriteAttributeString ("xmlns", "http://somenamespace.com", "http://abc.def");
+ }
+ catch (ArgumentException) {}
+ }
+
+ public void TestAttributeNamespacesWithNullInNamespaceParam ()
+ {
+ xtw.WriteAttributeString ("xmlns", "abc", null, "http://abc.def");
+ AssertEquals ("xmlns:abc='http://abc.def'", StringWriterText);
+ }
+
+ public void TestAttributeNamespacesWithTextInNamespaceParam ()
+ {
+ try {
+ xtw.WriteAttributeString ("xmlns", "abc", "http://somenamespace.com", "http://abc.def");
+ } catch (ArgumentException) {}
+ }
+
+ public void TestAttributeNamespacesXmlnsXmlns ()
+ {
+ xtw.WriteStartElement ("foo");
+ try
+ {
+ xtw.WriteAttributeString ("xmlns", "xmlns", null, "http://abc.def");
+ Fail ("any prefix which name starts from \"xml\" must not be allowed.");
+ }
+ catch (ArgumentException e) {}
+ }
+
+ public void TestAttributeWriteAttributeString ()
+ {
+ xtw.WriteStartElement ("foo");
+
+ xtw.WriteAttributeString ("foo", "bar");
+ AssertEquals ("<foo foo='bar'", StringWriterText);
+
+ xtw.WriteAttributeString ("bar", "");
+ AssertEquals ("<foo foo='bar' bar=''", StringWriterText);
+
+ xtw.WriteAttributeString ("baz", null);
+ AssertEquals ("<foo foo='bar' bar='' baz=''", StringWriterText);
+
+ // TODO: Why does this pass Microsoft?
+ xtw.WriteAttributeString ("", "quux");
+ AssertEquals ("<foo foo='bar' bar='' baz='' ='quux'", StringWriterText);
+
+ // TODO: Why does this pass Microsoft?
+ xtw.WriteAttributeString (null, "quuux");
+ AssertEquals ("<foo foo='bar' bar='' baz='' ='quux' ='quuux'", StringWriterText);
+ }
+
+ public void TestAttributeWriteAttributeStringNotInsideOpenStartElement ()
+ {
+ xtw.WriteStartElement ("foo");
+ xtw.WriteString ("bar");
+
+ try
+ {
+ xtw.WriteAttributeString ("baz", "quux");
+ Fail ("Expected an InvalidOperationException to be thrown.");
+ }
+ catch (InvalidOperationException) {}
+ }
+
+ public void TestAttributeWriteAttributeStringWithoutParentElement ()
+ {
+ xtw.WriteAttributeString ("foo", "bar");
+ AssertEquals ("foo='bar'", StringWriterText);
+
+ xtw.WriteAttributeString ("baz", "quux");
+ AssertEquals ("foo='bar' baz='quux'", StringWriterText);
+ }
+
+ public void TestCDataValid ()
+ {
+ xtw.WriteCData ("foo");
+ AssertEquals ("WriteCData had incorrect output.", "<![CDATA[foo]]>", StringWriterText);
+ }
+
+ public void TestCDataInvalid ()
+ {
+ try {
+ xtw.WriteCData("foo]]>bar");
+ Fail("Should have thrown an ArgumentException.");
+ }
+ catch (ArgumentException) { }
+ }
+
+ public void TestCloseOpenElements ()
+ {
+ xtw.WriteStartElement("foo");
+ xtw.WriteStartElement("bar");
+ xtw.WriteStartElement("baz");
+ xtw.Close();
+ AssertEquals ("Close didn't write out end elements properly.", "<foo><bar><baz /></bar></foo>", StringWriterText);
+ }
+
+ public void TestCloseWriteAfter ()
+ {
+ xtw.WriteElementString ("foo", "bar");
+ xtw.Close ();
+
+ // WriteEndElement and WriteStartDocument aren't tested here because
+ // they will always throw different exceptions besides 'The Writer is closed.'
+ // and there are already tests for those exceptions.
+
+ try {
+ xtw.WriteCData ("foo");
+ Fail ("WriteCData after Close Should have thrown an InvalidOperationException.");
+ }
+ catch (InvalidOperationException e) {
+ AssertEquals ("Exception message is incorrect.", "The Writer is closed.", e.Message);
+ }
+
+ try {
+ xtw.WriteComment ("foo");
+ Fail ("WriteComment after Close Should have thrown an InvalidOperationException.");
+ }
+ catch (InvalidOperationException e) {
+ AssertEquals ("Exception message is incorrect.", "The Writer is closed.", e.Message);
+ }
+
+ try {
+ xtw.WriteProcessingInstruction ("foo", "bar");
+ Fail ("WriteProcessingInstruction after Close Should have thrown an InvalidOperationException.");
+ }
+ catch (InvalidOperationException e) {
+ AssertEquals ("Exception message is incorrect.", "The Writer is closed.", e.Message);
+ }
+
+ try {
+ xtw.WriteStartElement ("foo", "bar", "baz");
+ Fail ("WriteStartElement after Close Should have thrown an InvalidOperationException.");
+ }
+ catch (InvalidOperationException e) {
+ AssertEquals ("Exception message is incorrect.", "The Writer is closed.", e.Message);
+ }
+
+ try
+ {
+ xtw.WriteAttributeString ("foo", "bar");
+ Fail ("WriteAttributeString after Close Should have thrown an InvalidOperationException.");
+ }
+ catch (InvalidOperationException e)
+ {
+ AssertEquals ("Exception message is incorrect.", "The Writer is closed.", e.Message);
+ }
+
+ try {
+ xtw.WriteString ("foo");
+ Fail ("WriteString after Close Should have thrown an InvalidOperationException.");
+ }
+ catch (InvalidOperationException e) {
+ AssertEquals ("Exception message is incorrect.", "The Writer is closed.", e.Message);
+ }
+ }
+
+ public void TestCommentValid ()
+ {
+ xtw.WriteComment ("foo");
+ AssertEquals ("WriteComment had incorrect output.", "<!--foo-->", StringWriterText);
+ }
+
+ public void TestCommentInvalid ()
+ {
+ try {
+ xtw.WriteComment("foo-");
+ Fail("Should have thrown an ArgumentException.");
+ }
+ catch (ArgumentException) { }
+
+ try {
+ xtw.WriteComment("foo-->bar");
+ Fail("Should have thrown an ArgumentException.");
+ }
+ catch (ArgumentException) { }
+ }
+
+ public void TestConstructorsAndBaseStream ()
+ {
+ Assert ("BaseStream property returned wrong value.", Object.ReferenceEquals (null, this.xtw.BaseStream));
+
+ MemoryStream ms;
+ StreamReader sr;
+ XmlTextWriter xtw;
+
+ ms = new MemoryStream ();
+ xtw = new XmlTextWriter (ms, new UnicodeEncoding ());
+ xtw.WriteStartDocument ();
+ xtw.Flush ();
+ ms.Seek (0, SeekOrigin.Begin);
+ sr = new StreamReader (ms, Encoding.Unicode);
+ string expectedXmlDeclaration = "<?xml version=\"1.0\" encoding=\"utf-16\"?>";
+ string actualXmlDeclaration = sr.ReadToEnd();
+ AssertEquals (expectedXmlDeclaration, actualXmlDeclaration);
+ Assert ("BaseStream property returned wrong value.", Object.ReferenceEquals (ms, xtw.BaseStream));
+
+ ms = new MemoryStream ();
+ xtw = new XmlTextWriter (ms, new UnicodeEncoding ());
+ xtw.WriteStartDocument (true);
+ xtw.Flush ();
+ ms.Seek (0, SeekOrigin.Begin);
+ sr = new StreamReader (ms, Encoding.Unicode);
+ AssertEquals ("<?xml version=\"1.0\" encoding=\"utf-16\" standalone=\"yes\"?>", sr.ReadToEnd ());
+
+ ms = new MemoryStream ();
+ xtw = new XmlTextWriter (ms, new UTF8Encoding ());
+ xtw.WriteStartDocument ();
+ xtw.Flush ();
+ ms.Seek (0, SeekOrigin.Begin);
+ sr = new StreamReader (ms, Encoding.UTF8);
+ AssertEquals ("<?xml version=\"1.0\" encoding=\"utf-8\"?>", sr.ReadToEnd ());
+
+ ms = new MemoryStream ();
+ xtw = new XmlTextWriter (ms, null);
+ xtw.WriteStartDocument ();
+ xtw.Flush ();
+ ms.Seek (0, SeekOrigin.Begin);
+ sr = new StreamReader (ms, Encoding.UTF8);
+ AssertEquals ("<?xml version=\"1.0\"?>", sr.ReadToEnd ());
+
+ ms = new MemoryStream ();
+ xtw = new XmlTextWriter (ms, null);
+ xtw.WriteStartDocument (true);
+ xtw.Flush ();
+ ms.Seek (0, SeekOrigin.Begin);
+ sr = new StreamReader (ms, Encoding.UTF8);
+ AssertEquals ("<?xml version=\"1.0\" standalone=\"yes\"?>", sr.ReadToEnd ());
+ Assert ("BaseStream property returned wrong value.", Object.ReferenceEquals (ms, xtw.BaseStream));
+ }
+
+ public void TestDocumentStart ()
+ {
+ xtw.WriteStartDocument ();
+ AssertEquals ("XmlDeclaration is incorrect.", "<?xml version='1.0' encoding='utf-16'?>", StringWriterText);
+
+ try
+ {
+ xtw.WriteStartDocument ();
+ Fail("Should have thrown an InvalidOperationException.");
+ }
+ catch (InvalidOperationException e) {
+ AssertEquals ("Exception message is incorrect.",
+ "WriteStartDocument should be the first call.", e.Message);
+ }
+
+ xtw = new XmlTextWriter (sw = new StringWriter ());
+ xtw.QuoteChar = '\'';
+ xtw.WriteStartDocument (true);
+ AssertEquals ("<?xml version='1.0' encoding='utf-16' standalone='yes'?>", StringWriterText);
+
+ xtw = new XmlTextWriter (sw = new StringWriter ());
+ xtw.QuoteChar = '\'';
+ xtw.WriteStartDocument (false);
+ AssertEquals ("<?xml version='1.0' encoding='utf-16' standalone='no'?>", StringWriterText);
+ }
+
+ public void TestElementEmpty ()
+ {
+ xtw.WriteStartElement ("foo");
+ xtw.WriteEndElement ();
+ AssertEquals ("Incorrect output.", "<foo />", StringWriterText);
+ }
+
+ public void TestElementWriteElementString ()
+ {
+ xtw.WriteElementString ("foo", "bar");
+ AssertEquals ("WriteElementString has incorrect output.", "<foo>bar</foo>", StringWriterText);
+
+ xtw.WriteElementString ("baz", "");
+ AssertEquals ("<foo>bar</foo><baz />", StringWriterText);
+
+ xtw.WriteElementString ("quux", null);
+ AssertEquals ("<foo>bar</foo><baz /><quux />", StringWriterText);
+
+ xtw.WriteElementString ("", "quuux");
+ AssertEquals ("<foo>bar</foo><baz /><quux /><>quuux</>", StringWriterText);
+
+ xtw.WriteElementString (null, "quuuux");
+ AssertEquals ("<foo>bar</foo><baz /><quux /><>quuux</><>quuuux</>", StringWriterText);
+ }
+
+ public void TestFormatting ()
+ {
+ xtw.Formatting = Formatting.Indented;
+ xtw.WriteStartDocument ();
+ xtw.WriteStartElement ("foo");
+ xtw.WriteElementString ("bar", "");
+ xtw.Close ();
+ AssertEquals ("<?xml version='1.0' encoding='utf-16'?>\r\n<foo>\r\n <bar />\r\n</foo>", StringWriterText);
+ }
+
+ public void TestFormattingInvalidXmlForFun ()
+ {
+ xtw.Formatting = Formatting.Indented;
+ xtw.IndentChar = 'x';
+ xtw.WriteStartDocument ();
+ xtw.WriteStartElement ("foo");
+ xtw.WriteStartElement ("bar");
+ xtw.WriteElementString ("baz", "");
+ xtw.Close ();
+ AssertEquals ("<?xml version='1.0' encoding='utf-16'?>\r\n<foo>\r\nxx<bar>\r\nxxxx<baz />\r\nxx</bar>\r\n</foo>", StringWriterText);
+ }
+
+ public void TestFormattingFromRemarks ()
+ {
+ // Remarks section of on-line help for XmlTextWriter.Formatting suggests this test.
+ xtw.Formatting = Formatting.Indented;
+ xtw.WriteStartElement ("ol");
+ xtw.WriteStartElement ("li");
+ xtw.WriteString ("The big "); // This means "li" now has a mixed content model.
+ xtw.WriteElementString ("b", "E");
+ xtw.WriteElementString ("i", "lephant");
+ xtw.WriteString (" walks slowly.");
+ xtw.WriteEndElement ();
+ xtw.WriteEndElement ();
+ AssertEquals ("<ol>\r\n <li>The big <b>E</b><i>lephant</i> walks slowly.</li>\r\n</ol>", StringWriterText);
+ }
+
+ public void TestLookupPrefix ()
+ {
+ xtw.WriteStartElement ("root");
+
+ xtw.WriteStartElement ("one");
+ xtw.WriteAttributeString ("xmlns", "foo", null, "http://abc.def");
+ xtw.WriteAttributeString ("xmlns", "bar", null, "http://ghi.jkl");
+ AssertEquals ("foo", xtw.LookupPrefix ("http://abc.def"));
+ AssertEquals ("bar", xtw.LookupPrefix ("http://ghi.jkl"));
+ xtw.WriteEndElement ();
+
+ xtw.WriteStartElement ("two");
+ xtw.WriteAttributeString ("xmlns", "baz", null, "http://mno.pqr");
+ xtw.WriteString("quux");
+ AssertEquals ("baz", xtw.LookupPrefix ("http://mno.pqr"));
+ AssertNull (xtw.LookupPrefix ("http://abc.def"));
+ AssertNull (xtw.LookupPrefix ("http://ghi.jkl"));
+
+ AssertNull (xtw.LookupPrefix ("http://bogus"));
+ }
+
+ public void TestNamespacesAttributesPassingInNamespaces ()
+ {
+ xtw.Namespaces = false;
+ xtw.WriteStartElement ("foo");
+
+ // These shouldn't throw any exceptions since they don't pass in
+ // a namespace.
+ xtw.WriteAttributeString ("bar", "baz");
+ xtw.WriteAttributeString ("", "a", "", "b");
+ xtw.WriteAttributeString (null, "c", "", "d");
+ xtw.WriteAttributeString ("", "e", null, "f");
+ xtw.WriteAttributeString (null, "g", null, "h");
+
+ AssertEquals ("<foo bar='baz' a='b' c='d' e='f' g='h'", StringWriterText);
+
+ // These should throw ArgumentException because they pass in a
+ // namespace when Namespaces = false.
+ }
+
+ public void TestNamespacesElementsPassingInNamespaces ()
+ {
+ xtw.Namespaces = false;
+
+ // These shouldn't throw any exceptions since they don't pass in
+ // a namespace.
+ xtw.WriteElementString ("foo", "bar");
+ xtw.WriteStartElement ("baz");
+ xtw.WriteStartElement ("quux", "");
+ xtw.WriteStartElement ("quuux", null);
+ xtw.WriteStartElement (null, "a", null);
+ xtw.WriteStartElement (null, "b", "");
+ xtw.WriteStartElement ("", "c", null);
+ xtw.WriteStartElement ("", "d", "");
+
+ AssertEquals ("<foo>bar</foo><baz><quux><quuux><a><b><c><d", StringWriterText);
+
+ // These should throw ArgumentException because they pass in a
+ // namespace when Namespaces = false.
+ try {
+ xtw.WriteElementString ("qux", "http://netsack.com/", String.Empty);
+ Fail ("Expected an ArgumentException.");
+ } catch (ArgumentException) {}
+
+ try {
+ xtw.WriteStartElement ("foo", "http://netsack.com/");
+ Fail ("Expected an ArgumentException.");
+ } catch (ArgumentException) {}
+
+ try {
+ xtw.WriteStartElement ("foo", "bar", "http://netsack.com/");
+ Fail ("Expected an ArgumentException.");
+ } catch (ArgumentException) {}
+
+ try {
+ xtw.WriteStartElement ("foo", "bar", null);
+ Fail ("Expected an ArgumentException.");
+ } catch (ArgumentException) {}
+
+ try {
+ xtw.WriteStartElement ("foo", "bar", "");
+ Fail ("Expected an ArgumentException.");
+ } catch (ArgumentException) {}
+
+ try {
+ xtw.WriteStartElement ("foo", "", "");
+ Fail ("Expected an ArgumentException.");
+ } catch (ArgumentException) {}
+ }
+
+ public void TestNamespacesNoNamespaceClearsDefaultNamespace ()
+ {
+ xtw.WriteStartElement(String.Empty, "foo", "http://netsack.com/");
+ xtw.WriteStartElement(String.Empty, "bar", String.Empty);
+ xtw.WriteElementString("baz", String.Empty, String.Empty);
+ xtw.WriteEndElement();
+ xtw.WriteEndElement();
+ AssertEquals ("XmlTextWriter is incorrectly outputting namespaces.",
+ "<foo xmlns='http://netsack.com/'><bar xmlns=''><baz /></bar></foo>", StringWriterText);
+ }
+
+ public void TestNamespacesPrefix ()
+ {
+ xtw.WriteStartElement ("foo", "bar", "http://netsack.com/");
+ xtw.WriteStartElement ("foo", "baz", "http://netsack.com/");
+ xtw.WriteElementString ("qux", "http://netsack.com/", String.Empty);
+ xtw.WriteEndElement ();
+ xtw.WriteEndElement ();
+ AssertEquals ("XmlTextWriter is incorrectly outputting prefixes.",
+ "<foo:bar xmlns:foo='http://netsack.com/'><foo:baz><foo:qux /></foo:baz></foo:bar>", StringWriterText);
+ }
+
+ public void TestNamespacesPrefixWithEmptyAndNullNamespace ()
+ {
+ try {
+ xtw.WriteStartElement ("foo", "bar", "");
+ Fail ("Should have thrown an ArgumentException.");
+ } catch (ArgumentException) {}
+
+ try
+ {
+ xtw.WriteStartElement ("foo", "bar", null);
+ Fail ("Should have thrown an ArgumentException.");
+ }
+ catch (ArgumentException) {}
+ }
+
+ public void TestNamespacesSettingWhenWriteStateNotStart ()
+ {
+ xtw.WriteStartElement ("foo");
+ try
+ {
+ xtw.Namespaces = false;
+ Fail ("Expected an InvalidOperationException.");
+ }
+ catch (InvalidOperationException) {}
+ AssertEquals (true, xtw.Namespaces);
+ }
+
+ public void TestProcessingInstructionValid ()
+ {
+ xtw.WriteProcessingInstruction("foo", "bar");
+ AssertEquals ("WriteProcessingInstruction had incorrect output.", "<?foo bar?>", StringWriterText);
+ }
+
+ public void TestProcessingInstructionInvalid ()
+ {
+ try
+ {
+ xtw.WriteProcessingInstruction("fo?>o", "bar");
+ Fail("Should have thrown an ArgumentException.");
+ }
+ catch (ArgumentException) { }
+
+ try
+ {
+ xtw.WriteProcessingInstruction("foo", "ba?>r");
+ Fail("Should have thrown an ArgumentException.");
+ }
+ catch (ArgumentException) { }
+
+ try
+ {
+ xtw.WriteProcessingInstruction("", "bar");
+ Fail("Should have thrown an ArgumentException.");
+ }
+ catch (ArgumentException) { }
+
+ try
+ {
+ xtw.WriteProcessingInstruction(null, "bar");
+ Fail("Should have thrown an ArgumentException.");
+ }
+ catch (ArgumentException) { }
+ }
+
+ public void TestQuoteCharDoubleQuote ()
+ {
+ xtw.QuoteChar = '"';
+
+ // version, encoding, standalone
+ xtw.WriteStartDocument (true);
+
+ // namespace declaration
+ xtw.WriteElementString ("foo", "http://netsack.com", "bar");
+
+ AssertEquals ("<?xml version=\"1.0\" encoding=\"utf-16\" standalone=\"yes\"?><foo xmlns=\"http://netsack.com\">bar</foo>", StringWriterText);
+
+
+ }
+
+ public void TestQuoteCharInvalid ()
+ {
+ try {
+ xtw.QuoteChar = 'x';
+ Fail ("Should have thrown an ArgumentException.");
+ } catch (ArgumentException) {}
+ }
+
+ public void TestWriteBase64 ()
+ {
+ UTF8Encoding encoding = new UTF8Encoding();
+ byte[] fooBar = encoding.GetBytes("foobar");
+ xtw.WriteBase64 (fooBar, 0, 6);
+ AssertEquals("Zm9vYmFy", StringWriterText);
+
+ try {
+ xtw.WriteBase64 (fooBar, 3, 6);
+ Fail ("Expected an Argument Exception to be thrown.");
+ } catch (ArgumentException) {}
+
+ try {
+ xtw.WriteBase64 (fooBar, -1, 6);
+ Fail ("Expected an Argument Exception to be thrown.");
+ } catch (ArgumentOutOfRangeException) {}
+
+ try {
+ xtw.WriteBase64 (fooBar, 3, -1);
+ Fail ("Expected an Argument Exception to be thrown.");
+ } catch (ArgumentOutOfRangeException) {}
+
+ try {
+ xtw.WriteBase64 (null, 0, 6);
+ Fail ("Expected an Argument Exception to be thrown.");
+ } catch (ArgumentNullException) {}
+ }
+
+ public void TestWriteCharEntity ()
+ {
+ xtw.WriteCharEntity ('a');
+ AssertEquals ("&#x61;", StringWriterText);
+
+ xtw.WriteCharEntity ('A');
+ AssertEquals ("&#x61;&#x41;", StringWriterText);
+
+ xtw.WriteCharEntity ('1');
+ AssertEquals ("&#x61;&#x41;&#x31;", StringWriterText);
+
+ xtw.WriteCharEntity ('K');
+ AssertEquals ("&#x61;&#x41;&#x31;&#x4B;", StringWriterText);
+
+ try {
+ xtw.WriteCharEntity ((char)0xd800);
+ } catch (ArgumentException) {}
+ }
+
+ public void TestWriteEndAttribute ()
+ {
+ try
+ {
+ xtw.WriteEndAttribute ();
+ Fail ("Should have thrown an InvalidOperationException.");
+ }
+ catch (InvalidOperationException) {}
+ }
+
+ public void TestWriteEndDocument ()
+ {
+ try {
+ xtw.WriteEndDocument ();
+ Fail ("Expected an ArgumentException.");
+ } catch (ArgumentException) {}
+
+ xtw.WriteStartDocument ();
+
+ try
+ {
+ xtw.WriteEndDocument ();
+ Fail ("Expected an ArgumentException.");
+ }
+ catch (ArgumentException) {}
+
+ xtw.WriteStartElement ("foo");
+ xtw.WriteStartAttribute ("bar", null);
+ AssertEquals ("<?xml version='1.0' encoding='utf-16'?><foo bar='", StringWriterText);
+
+ xtw.WriteEndDocument ();
+ AssertEquals ("<?xml version='1.0' encoding='utf-16'?><foo bar='' />", StringWriterText);
+ AssertEquals (WriteState.Start, xtw.WriteState);
+ }
+
+ public void TestWriteEndElement ()
+ {
+ try {
+ xtw.WriteEndElement ();
+ Fail ("Should have thrown an InvalidOperationException.");
+ } catch (InvalidOperationException e) {
+ AssertEquals ("Exception message is incorrect.", "There was no XML start tag open.", e.Message);
+ }
+
+ xtw.WriteStartElement ("foo");
+ xtw.WriteEndElement ();
+ AssertEquals ("<foo />", StringWriterText);
+
+ xtw.WriteStartElement ("bar");
+ xtw.WriteStartAttribute ("baz", null);
+ xtw.WriteEndElement ();
+ AssertEquals ("<foo /><bar baz='' />", StringWriterText);
+ }
+
+ public void TestFullEndElement ()
+ {
+ xtw.WriteStartElement ("foo");
+ xtw.WriteFullEndElement ();
+ AssertEquals ("<foo></foo>", StringWriterText);
+
+ xtw.WriteStartElement ("bar");
+ xtw.WriteAttributeString ("foo", "bar");
+ xtw.WriteFullEndElement ();
+ AssertEquals ("<foo></foo><bar foo='bar'></bar>", StringWriterText);
+
+ xtw.WriteStartElement ("baz");
+ xtw.WriteStartAttribute ("bar", null);
+ xtw.WriteFullEndElement ();
+ AssertEquals ("<foo></foo><bar foo='bar'></bar><baz bar=''></baz>", StringWriterText);
+ }
+
+ public void TestWriteRaw ()
+ {
+ xtw.WriteRaw("&<>\"'");
+ AssertEquals ("&<>\"'", StringWriterText);
+
+ xtw.WriteRaw(null);
+ AssertEquals ("&<>\"'", StringWriterText);
+
+ xtw.WriteRaw("");
+ AssertEquals ("&<>\"'", StringWriterText);
+ }
+
+ public void TestWriteRawInvalidInAttribute ()
+ {
+ xtw.WriteStartElement ("foo");
+ xtw.WriteStartAttribute ("bar", null);
+ xtw.WriteRaw ("&<>\"'");
+ xtw.WriteEndAttribute ();
+ xtw.WriteEndElement ();
+ AssertEquals ("<foo bar='&<>\"'' />", StringWriterText);
+ }
+
+ public void TestWriteState ()
+ {
+ AssertEquals (WriteState.Start, xtw.WriteState);
+ xtw.WriteStartDocument ();
+ AssertEquals (WriteState.Prolog, xtw.WriteState);
+ xtw.WriteStartElement ("root");
+ AssertEquals (WriteState.Element, xtw.WriteState);
+ xtw.WriteElementString ("foo", "bar");
+ AssertEquals (WriteState.Content, xtw.WriteState);
+ xtw.Close ();
+ AssertEquals (WriteState.Closed, xtw.WriteState);
+ }
+
+ public void TestWriteString ()
+ {
+ xtw.WriteStartDocument ();
+ try {
+ xtw.WriteString("foo");
+ } catch (InvalidOperationException) {}
+
+ // Testing attribute values
+
+ xtw.WriteStartElement ("foo");
+ xtw.WriteAttributeString ("bar", "&<>");
+ AssertEquals ("<?xml version='1.0' encoding='utf-16'?><foo bar='&amp;&lt;&gt;'", StringWriterText);
+ }
+
+ public void TestWriteAttributeStringSingleQuoteChar()
+ {
+ // When QuoteChar is single quote then replaces single quotes within attributes
+ // but not double quotes.
+ xtw.WriteStartElement ("foo");
+ xtw.WriteAttributeString ("bar", "\"baz\"");
+ xtw.WriteAttributeString ("quux", "'baz'");
+ AssertEquals ("<foo bar='\"baz\"' quux='&apos;baz&apos;'", StringWriterText);
+ }
+
+ public void TestWriteAttributeStringDoubleQuoteChar()
+ {
+ // When QuoteChar is double quote then replaces double quotes within attributes
+ // but not single quotes.
+ xtw.QuoteChar = '"';
+ xtw.WriteStartElement ("foo");
+ xtw.WriteAttributeString ("bar", "\"baz\"");
+ xtw.WriteAttributeString ("quux", "'baz'");
+ AssertEquals ("<foo bar=\"&quot;baz&quot;\" quux=\"'baz'\"", StringWriterText);
+ }
+
+ public void TestWriteStringWithEntities()
+ {
+ // Testing element values
+ xtw.QuoteChar = '\'';
+ xtw.WriteElementString ("foo", "&<>\"'");
+ AssertEquals ("<foo>&amp;&lt;&gt;\"'</foo>", StringWriterText);
+ }
+
+ public void TestXmlLang ()
+ {
+ AssertNull (xtw.XmlLang);
+
+ xtw.WriteStartElement ("foo");
+ xtw.WriteAttributeString ("xml", "lang", null, "langfoo");
+ AssertEquals ("langfoo", xtw.XmlLang);
+ AssertEquals ("<foo xml:lang='langfoo'", StringWriterText);
+
+ xtw.WriteAttributeString ("boo", "yah");
+ AssertEquals ("langfoo", xtw.XmlLang);
+ AssertEquals ("<foo xml:lang='langfoo' boo='yah'", StringWriterText);
+
+ xtw.WriteElementString("bar", "baz");
+ AssertEquals ("langfoo", xtw.XmlLang);
+ AssertEquals ("<foo xml:lang='langfoo' boo='yah'><bar>baz</bar>", StringWriterText);
+
+ xtw.WriteString("baz");
+ AssertEquals ("langfoo", xtw.XmlLang);
+ AssertEquals ("<foo xml:lang='langfoo' boo='yah'><bar>baz</bar>baz", StringWriterText);
+
+ xtw.WriteStartElement ("quux");
+ xtw.WriteStartAttribute ("xml", "lang", null);
+ AssertEquals ("langfoo", xtw.XmlLang);
+ AssertEquals ("<foo xml:lang='langfoo' boo='yah'><bar>baz</bar>baz<quux xml:lang='", StringWriterText);
+
+ xtw.WriteString("langbar");
+ AssertEquals ("langfoo", xtw.XmlLang);
+ AssertEquals ("<foo xml:lang='langfoo' boo='yah'><bar>baz</bar>baz<quux xml:lang='", StringWriterText);
+
+ xtw.WriteEndAttribute ();
+ AssertEquals ("langbar", xtw.XmlLang);
+ AssertEquals ("<foo xml:lang='langfoo' boo='yah'><bar>baz</bar>baz<quux xml:lang='langbar'", StringWriterText);
+
+ // check if xml:lang repeats output even if same as current scope.
+ xtw.WriteStartElement ("joe");
+ xtw.WriteAttributeString ("xml", "lang", null, "langbar");
+ AssertEquals ("<foo xml:lang='langfoo' boo='yah'><bar>baz</bar>baz<quux xml:lang='langbar'><joe xml:lang='langbar'", StringWriterText);
+
+
+ xtw.WriteElementString ("quuux", "squonk");
+ AssertEquals ("langbar", xtw.XmlLang);
+ AssertEquals ("<foo xml:lang='langfoo' boo='yah'><bar>baz</bar>baz<quux xml:lang='langbar'><joe xml:lang='langbar'><quuux>squonk</quuux>", StringWriterText);
+
+ xtw.WriteEndElement ();
+ xtw.WriteEndElement ();
+ AssertEquals ("langfoo", xtw.XmlLang);
+ AssertEquals ("<foo xml:lang='langfoo' boo='yah'><bar>baz</bar>baz<quux xml:lang='langbar'><joe xml:lang='langbar'><quuux>squonk</quuux></joe></quux>", StringWriterText);
+
+ xtw.WriteEndElement ();
+ AssertNull (xtw.XmlLang);
+ AssertEquals ("<foo xml:lang='langfoo' boo='yah'><bar>baz</bar>baz<quux xml:lang='langbar'><joe xml:lang='langbar'><quuux>squonk</quuux></joe></quux></foo>", StringWriterText);
+
+ xtw.Close ();
+ AssertNull (xtw.XmlLang);
+ }
+
+ // TODO: test operational aspects
+ public void TestXmlSpace ()
+ {
+ xtw.WriteStartElement ("foo");
+ AssertEquals (XmlSpace.None, xtw.XmlSpace);
+
+ xtw.WriteStartElement ("bar");
+ xtw.WriteAttributeString ("xml", "space", null, "preserve");
+ AssertEquals (XmlSpace.Preserve, xtw.XmlSpace);
+ AssertEquals ("<foo><bar xml:space='preserve'", StringWriterText);
+
+ xtw.WriteStartElement ("baz");
+ xtw.WriteAttributeString ("xml", "space", null, "preserve");
+ AssertEquals (XmlSpace.Preserve, xtw.XmlSpace);
+ AssertEquals ("<foo><bar xml:space='preserve'><baz xml:space='preserve'", StringWriterText);
+
+ xtw.WriteStartElement ("quux");
+ xtw.WriteStartAttribute ("xml", "space", null);
+ AssertEquals (XmlSpace.Preserve, xtw.XmlSpace);
+ AssertEquals ("<foo><bar xml:space='preserve'><baz xml:space='preserve'><quux xml:space='", StringWriterText);
+
+ xtw.WriteString ("default");
+ AssertEquals (XmlSpace.Preserve, xtw.XmlSpace);
+ AssertEquals ("<foo><bar xml:space='preserve'><baz xml:space='preserve'><quux xml:space='", StringWriterText);
+
+ xtw.WriteEndAttribute ();
+ AssertEquals (XmlSpace.Default, xtw.XmlSpace);
+ AssertEquals ("<foo><bar xml:space='preserve'><baz xml:space='preserve'><quux xml:space='default'", StringWriterText);
+
+ xtw.WriteEndElement ();
+ AssertEquals (XmlSpace.Preserve, xtw.XmlSpace);
+ xtw.WriteEndElement ();
+ AssertEquals (XmlSpace.Preserve, xtw.XmlSpace);
+ xtw.WriteEndElement ();
+ AssertEquals (XmlSpace.None, xtw.XmlSpace);
+
+ xtw.WriteStartElement ("quux");
+ try {
+ xtw.WriteAttributeString ("xml", "space", null, "bubba");
+ } catch (ArgumentException) {}
+
+ try {
+ xtw.WriteAttributeString ("xml", "space", null, "PRESERVE");
+ } catch (ArgumentException) {}
+
+ try {
+ xtw.WriteAttributeString ("xml", "space", null, "Preserve");
+ } catch (ArgumentException) {}
+
+ try {
+ xtw.WriteAttributeString ("xml", "space", null, "Default");
+ } catch (ArgumentException) {}
+
+ try {
+ xtw.WriteWhitespace ("x");
+ } catch (ArgumentException) { }
+ }
+
+ public void TestXmlSpaceRaw ()
+ {
+ xtw.WriteStartElement ("foo");
+ xtw.WriteStartAttribute ("xml", "space", null);
+ AssertEquals (XmlSpace.None, xtw.XmlSpace);
+ AssertEquals ("<foo xml:space='", StringWriterText);
+
+ xtw.WriteString ("default");
+ AssertEquals (XmlSpace.None, xtw.XmlSpace);
+ AssertEquals ("<foo xml:space='", StringWriterText);
+
+ xtw.WriteEndAttribute ();
+ AssertEquals (XmlSpace.Default, xtw.XmlSpace);
+ AssertEquals ("<foo xml:space='default'", StringWriterText);
+ }
+
+ public void TestWriteAttributes ()
+ {
+ XmlDocument doc = new XmlDocument();
+ StringWriter sw = new StringWriter();
+ XmlWriter wr = new XmlTextWriter(sw);
+ StringBuilder sb = sw.GetStringBuilder();
+ XmlParserContext ctx = new XmlParserContext(doc.NameTable, new XmlNamespaceManager(doc.NameTable), "", XmlSpace.Default);
+ XmlTextReader xtr = new XmlTextReader("<?xml version='1.0' encoding='utf-8' standalone='no'?><root a1='A' b2='B' c3='C'><foo><bar /></foo></root>", XmlNodeType.Document, ctx);
+
+ xtr.Read(); // read XMLDecl
+ wr.WriteAttributes(xtr, false);
+ // This method don't always have to take this double-quoted style...
+ AssertEquals("#WriteAttributes.XmlDecl.1", "version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"", sw.ToString().Trim());
+
+ sb.Remove(0, sb.Length); // init
+ ctx = new XmlParserContext(doc.NameTable, new XmlNamespaceManager(doc.NameTable), "", XmlSpace.Default);
+ xtr = new XmlTextReader("<?xml version='1.0' standalone='no'?><root a1='A' b2='B' c3='C'><foo><bar /></foo></root>", XmlNodeType.Document, ctx);
+ xtr.Read(); // read XMLDecl
+ wr.WriteAttributes(xtr, false);
+ // This method don't always have to take this double-quoted style...
+ AssertEquals("#WriteAttributes.XmlDecl.2", "version=\"1.0\" standalone=\"no\"", sw.ToString().Trim());
+
+ sb.Remove(0, sb.Length); // init
+ xtr.Read(); // read root
+ wr.WriteStartElement(xtr.LocalName, xtr.Value);
+ wr.WriteAttributes(xtr, false);
+ wr.WriteEndElement();
+ wr.Close();
+ // This method don't always have to take this double-quoted style...
+ AssertEquals("#WriteAttributes.Element", "<root a1=\"A\" b2=\"B\" c3=\"C\" />", sw.ToString().Trim());
+ }
+ }
+}
diff --git a/mcs/class/System.XML/Test/XmlWhiteSpaceTests.cs b/mcs/class/System.XML/Test/XmlWhiteSpaceTests.cs
new file mode 100755
index 00000000000..f114356b372
--- /dev/null
+++ b/mcs/class/System.XML/Test/XmlWhiteSpaceTests.cs
@@ -0,0 +1,118 @@
+//
+// System.Xml.XmlWhitespaceTests.cs
+//
+// Author:
+// Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+//
+
+using System;
+using System.Xml;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+ public class XmlWhitespaceTests : TestCase
+ {
+ XmlDocument document;
+ XmlDocument doc2;
+ XmlWhitespace whitespace;
+ XmlWhitespace broken;
+ XmlNode original;
+ XmlNode deep;
+ XmlNode shallow;
+
+ public XmlWhitespaceTests () : base ("MonoTests.System.Xml.XmlWhitespaceTests testsuite") {}
+ public XmlWhitespaceTests (string name) : base (name) {}
+
+ protected override void SetUp ()
+ {
+ document = new XmlDocument ();
+ document.LoadXml ("<root><foo></foo></root>");
+ XmlElement element = document.CreateElement ("foo");
+ whitespace = document.CreateWhitespace ("\r\n");
+ element.AppendChild (whitespace);
+
+ doc2 = new XmlDocument ();
+ doc2.PreserveWhitespace = true;
+ }
+
+ public void TestInnerAndOuterXml ()
+ {
+ whitespace = doc2.CreateWhitespace ("\r\n\t ");
+ AssertEquals (String.Empty, whitespace.InnerXml);
+ AssertEquals ("\r\n\t ", whitespace.OuterXml);
+ }
+
+ internal void TestXmlNodeBaseProperties (XmlNode original, XmlNode cloned)
+ {
+// assertequals (original.nodetype + " was incorrectly cloned.",
+// original.baseuri, cloned.baseuri);
+ AssertNull (cloned.ParentNode);
+ AssertEquals ("Value incorrectly cloned",
+ cloned.Value, original.Value);
+
+ Assert ("Copies, not pointers", !Object.ReferenceEquals (original,cloned));
+ }
+
+ public void TestXmlWhitespaceBadConstructor ()
+ {
+ try {
+ broken = document.CreateWhitespace ("black");
+
+ } catch (ArgumentException) {
+ return;
+
+ } catch (Exception) {
+ Fail ("Incorrect Exception thrown.");
+ }
+ }
+
+ public void TestXmlWhitespaceConstructor ()
+ {
+ AssertEquals ("whitespace char didn't get copied right",
+ "\r\n", whitespace.Data);
+ }
+
+
+ public void TestXmlWhitespaceName ()
+ {
+ AssertEquals (whitespace.NodeType + " Name property broken",
+ whitespace.Name, "#whitespace");
+ }
+
+ public void TestXmlWhitespaceLocalName ()
+ {
+ AssertEquals (whitespace.NodeType + " LocalName property broken",
+ whitespace.LocalName, "#whitespace");
+ }
+
+ public void TestXmlWhitespaceNodeType ()
+ {
+ AssertEquals ("XmlWhitespace NodeType property broken",
+ whitespace.NodeType.ToString (), "Whitespace");
+ }
+
+ public void TestXmlWhitespaceIsReadOnly ()
+ {
+ AssertEquals ("XmlWhitespace IsReadOnly property broken",
+ whitespace.IsReadOnly, false);
+ }
+
+ public void TestXmlWhitespaceCloneNode ()
+ {
+ original = whitespace;
+
+ shallow = whitespace.CloneNode (false); // shallow
+ TestXmlNodeBaseProperties (original, shallow);
+
+ deep = whitespace.CloneNode (true); // deep
+ TestXmlNodeBaseProperties (original, deep);
+
+ AssertEquals ("deep cloning differs from shallow cloning",
+ deep.OuterXml, shallow.OuterXml);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/Test/XmlWriterTests.cs b/mcs/class/System.XML/Test/XmlWriterTests.cs
new file mode 100644
index 00000000000..f2fc1cbf2dd
--- /dev/null
+++ b/mcs/class/System.XML/Test/XmlWriterTests.cs
@@ -0,0 +1,206 @@
+//
+// System.Xml.XmlTextWriterTests
+//
+// Author:
+// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//
+// (C) 2003 Atsushi Enomoto
+//
+//
+// This class mainly checks inheritance and behaviors of XmlWriter.
+//
+
+
+
+using System;
+using System.IO;
+using System.Text;
+using System.Xml;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Xml
+{
+ public class XmlWriterTests : TestCase
+ {
+ public XmlWriterTests () : base ("MonoTests.System.Xml.XmlWriterTests testsuite") {}
+ public XmlWriterTests (string name) : base (name) {}
+
+ protected override void SetUp ()
+ {
+ }
+
+ // MS.NET's not-overriden XmlWriter.WriteStartElement(name)
+ // invokes WriteStartElement(null, name, null).
+ // WriteStartElement(name, ns) invokes (null, name, ns), too.
+ public void TestStartElement ()
+ {
+ StartElementTestWriter xw = new StartElementTestWriter ();
+ xw.WriteStartDocument ();
+ xw.WriteStartElement ("test");
+ AssertEquals ("StartElementOverride.NS", null, xw.NS);
+ AssertEquals ("StartElementOverride.Prefix", null, xw.Prefix);
+ xw.NS = String.Empty;
+ xw.Prefix = String.Empty;
+ xw.WriteStartElement ("test", "urn:hoge");
+ AssertEquals ("StartElementOverride.NS", "urn:hoge", xw.NS);
+ AssertEquals ("StartElementOverride.Prefix", null, xw.Prefix);
+ }
+
+ class StartElementTestWriter : DefaultXmlWriter
+ {
+ public StartElementTestWriter () : base () {}
+ public string NS = String.Empty;
+ public string Prefix = String.Empty;
+
+ public override void WriteStartElement (string prefix, string localName, string ns)
+ {
+ this.NS = ns;
+ this.Prefix = prefix;
+ }
+ }
+ }
+
+ internal class DefaultXmlWriter : XmlWriter
+ {
+ public DefaultXmlWriter () : base ()
+ {
+ }
+
+ public override void Close ()
+ {
+ }
+
+ public override void Flush ()
+ {
+ }
+
+ public override string LookupPrefix (string ns)
+ {
+ return null;
+ }
+
+ public override void WriteBase64 (byte [] buffer, int index, int count)
+ {
+ }
+
+ public override void WriteBinHex (byte [] buffer, int index, int count)
+ {
+ }
+
+ public override void WriteCData (string text)
+ {
+ }
+
+ public override void WriteCharEntity (char ch)
+ {
+ }
+
+ public override void WriteChars (char [] buffer, int index, int count)
+ {
+ }
+
+ public override void WriteComment (string text)
+ {
+ }
+
+ public override void WriteDocType (string name, string pubid, string sysid, string subset)
+ {
+ }
+
+ public override void WriteEndAttribute ()
+ {
+ }
+
+ public override void WriteEndDocument ()
+ {
+ }
+
+ public override void WriteEndElement ()
+ {
+ }
+
+ public override void WriteEntityRef (string name)
+ {
+ }
+
+ public override void WriteFullEndElement ()
+ {
+ }
+
+ public override void WriteName (string name)
+ {
+ }
+
+ public override void WriteNmToken (string name)
+ {
+ }
+
+ public override void WriteNode (XmlReader reader, bool defattr)
+ {
+ }
+
+ public override void WriteProcessingInstruction (string name, string text)
+ {
+ }
+
+ public override void WriteQualifiedName (string localName, string ns)
+ {
+ }
+
+ public override void WriteRaw (string data)
+ {
+ }
+
+ public override void WriteRaw (char [] buffer, int index, int count)
+ {
+ }
+
+ public override void WriteStartAttribute (string prefix, string localName, string ns)
+ {
+ }
+
+ public override void WriteStartDocument (bool standalone)
+ {
+ }
+
+ public override void WriteStartDocument ()
+ {
+ }
+
+ public override void WriteStartElement (string prefix, string localName, string ns)
+ {
+ }
+
+ public override void WriteString (string text)
+ {
+ }
+
+ public override void WriteSurrogateCharEntity (char lowChar, char highChar)
+ {
+ }
+
+ public override void WriteWhitespace (string ws)
+ {
+ }
+
+ public override WriteState WriteState {
+ get {
+ return WriteState.Start;
+ }
+ }
+
+ public override string XmlLang {
+ get {
+ return null;
+ }
+ }
+
+ public override XmlSpace XmlSpace {
+ get {
+ return XmlSpace.None;
+ }
+ }
+
+ }
+}
diff --git a/mcs/class/System.XML/Test/makefile.gnu b/mcs/class/System.XML/Test/makefile.gnu
new file mode 100644
index 00000000000..814499ffe70
--- /dev/null
+++ b/mcs/class/System.XML/Test/makefile.gnu
@@ -0,0 +1,22 @@
+topdir = ../../..
+
+LIBRARY = System.XML_linux_test.dll
+
+LIB_LIST = System.XML_linux_test.args
+LIB_FLAGS = \
+ -r $(topdir)/class/lib/corlib.dll \
+ -r $(topdir)/class/lib/System.Xml.dll \
+ -r $(topdir)/class/lib/NUnitCore_mono.dll
+
+SOURCES_INCLUDE = *.cs
+SOURCES_EXCLUDE = ./TheTests.cs
+
+include $(topdir)/class/library.make
+
+MCS_FLAGS = --target library --noconfig
+
+TEST_SUITE_PREFIX = MonoTests.System.Xml.
+TEST_SUITE = AllTests
+
+test: $(LIBRARY)
+ -MONO_PATH=$(MONO_PATH) mono $(topdir)/class/lib/NUnitConsole_mono.exe $(TEST_SUITE_PREFIX)$(TEST_SUITE),System.XML_linux_test.dll
diff --git a/mcs/class/System.XML/list b/mcs/class/System.XML/list
new file mode 100755
index 00000000000..647bf6063fa
--- /dev/null
+++ b/mcs/class/System.XML/list
@@ -0,0 +1,192 @@
+System.Xml\\EntityHandling.cs
+System.Xml\\XmlConvert.cs
+System.Xml\\Formatting.cs
+System.Xml\\IHasXmlNode.cs
+System.Xml\\IXmlLineInfo.cs
+System.Xml\\NameTable.cs
+System.Xml\\ReadState.cs
+System.Xml\\TODOAttribute.cs
+System.Xml\\ValidationType.cs
+System.Xml\\WhitespaceHandling.cs
+System.Xml\\WriteState.cs
+System.Xml\\XmlAttribute.cs
+System.Xml\\XmlAttributeCollection.cs
+System.Xml\\XmlCDataSection.cs
+System.Xml\\XmlChar.cs
+System.Xml\\XmlCharacterData.cs
+System.Xml\\XmlComment.cs
+System.Xml\\XmlDeclaration.cs
+System.Xml\\XmlDocument.cs
+System.Xml\\XmlDocumentFragment.cs
+System.Xml\\XmlDocumentType.cs
+System.Xml\\XmlElement.cs
+System.Xml\\XmlEntity.cs
+System.Xml\\XmlEntityReference.cs
+System.Xml\\XmlException.cs
+System.Xml\\XmlImplementation.cs
+System.Xml\\XmlLinkedNode.cs
+System.Xml\\XmlNamedNodeMap.cs
+System.Xml\\XmlNamespaceManager.cs
+System.Xml\\XmlNameTable.cs
+System.Xml\\XmlNode.cs
+System.Xml\\XmlNodeChangedAction.cs
+System.Xml\\XmlNodeChangedEventArgs.cs
+System.Xml\\XmlNodeChangedEventHandler.cs
+System.Xml\\XmlNodeList.cs
+System.Xml\\XmlNodeListChildren.cs
+System.Xml\\XmlNodeOrder.cs
+System.Xml\\XmlNodeReader.cs
+System.Xml\\XmlNodeType.cs
+System.Xml\\XmlNotation.cs
+System.Xml\\XmlParserContext.cs
+System.Xml\\XmlProcessingInstruction.cs
+System.Xml\\XmlQualifiedName.cs
+System.Xml\\XmlReader.cs
+System.Xml\\XmlResolver.cs
+System.Xml\\XmlSignificantWhitespace.cs
+System.Xml\\XmlSpace.cs
+System.Xml\\XmlText.cs
+System.Xml\\XmlTextReader.cs
+System.Xml\\XmlTextWriter.cs
+System.Xml\\XmlTextWriterOpenElement.cs
+System.Xml\\XmlTokenizedType.cs
+System.Xml\\XmlUrlResolver.cs
+System.Xml\\XmlValidatingReader.cs
+System.Xml\\XmlWhitespace.cs
+System.Xml\\XmlWriter.cs
+System.Xml.Schema\\Parser.cs
+System.Xml.Schema\\ValidationEventArgs.cs
+System.Xml.Schema\\ValidationHandler.cs
+System.Xml.Schema\\XmlSchema.cs
+System.Xml.Schema\\XmlSchemaAll.cs
+System.Xml.Schema\\XmlSchemaAnnotated.cs
+System.Xml.Schema\\XmlSchemaAnnotation.cs
+System.Xml.Schema\\XmlSchemaAny.cs
+System.Xml.Schema\\XmlSchemaAnyAttribute.cs
+System.Xml.Schema\\XmlSchemaAppInfo.cs
+System.Xml.Schema\\XmlSchemaAttribute.cs
+System.Xml.Schema\\XmlSchemaAttributeGroup.cs
+System.Xml.Schema\\XmlSchemaAttributeGroupRef.cs
+System.Xml.Schema\\XmlSchemaChoice.cs
+System.Xml.Schema\\XmlSchemaCollection.cs
+System.Xml.Schema\\XmlSchemaCollectionEnumerator.cs
+System.Xml.Schema\\XmlSchemaComplexContent.cs
+System.Xml.Schema\\XmlSchemaComplexContentExtension.cs
+System.Xml.Schema\\XmlSchemaComplexContentRestriction.cs
+System.Xml.Schema\\XmlSchemaComplexType.cs
+System.Xml.Schema\\XmlSchemaContent.cs
+System.Xml.Schema\\XmlSchemaContentModel.cs
+System.Xml.Schema\\XmlSchemaContentProcessing.cs
+System.Xml.Schema\\XmlSchemaContentType.cs
+System.Xml.Schema\\XmlSchemaDatatype.cs
+System.Xml.Schema\\XmlSchemaDerivationMethod.cs
+System.Xml.Schema\\XmlSchemaDocumentation.cs
+System.Xml.Schema\\XmlSchemaElement.cs
+System.Xml.Schema\\XmlSchemaEnumerationFacet.cs
+System.Xml.Schema\\XmlSchemaException.cs
+System.Xml.Schema\\XmlSchemaExternal.cs
+System.Xml.Schema\\XmlSchemaFacet.cs
+System.Xml.Schema\\XmlSchemaForm.cs
+System.Xml.Schema\\XmlSchemaFractionDigitsFacet.cs
+System.Xml.Schema\\XmlSchemaGroup.cs
+System.Xml.Schema\\XmlSchemaGroupBase.cs
+System.Xml.Schema\\XmlSchemaGroupRef.cs
+System.Xml.Schema\\XmlSchemaIdentityConstraint.cs
+System.Xml.Schema\\XmlSchemaImport.cs
+System.Xml.Schema\\XmlSchemaInclude.cs
+System.Xml.Schema\\XmlSchemaInfo.cs
+System.Xml.Schema\\XmlSchemaKey.cs
+System.Xml.Schema\\XmlSchemaKeyref.cs
+System.Xml.Schema\\XmlSchemaLengthFacet.cs
+System.Xml.Schema\\XmlSchemaMaxExclusiveFacet.cs
+System.Xml.Schema\\XmlSchemaMaxInclusiveFacet.cs
+System.Xml.Schema\\XmlSchemaMaxLengthFacet.cs
+System.Xml.Schema\\XmlSchemaMinExclusiveFacet.cs
+System.Xml.Schema\\XmlSchemaMinInclusiveFacet.cs
+System.Xml.Schema\\XmlSchemaMinLengthFacet.cs
+System.Xml.Schema\\XmlSchemaNotation.cs
+System.Xml.Schema\\XmlSchemaNumericFacet.cs
+System.Xml.Schema\\XmlSchemaObject.cs
+System.Xml.Schema\\XmlSchemaObjectCollection.cs
+System.Xml.Schema\\XmlSchemaObjectEnumerator.cs
+System.Xml.Schema\\XmlSchemaObjectTable.cs
+System.Xml.Schema\\XmlSchemaParticle.cs
+System.Xml.Schema\\XmlSchemaPatternFacet.cs
+System.Xml.Schema\\XmlSchemaRedefine.cs
+System.Xml.Schema\\XmlSchemaSequence.cs
+System.Xml.Schema\\XmlSchemaSimpleContent.cs
+System.Xml.Schema\\XmlSchemaSimpleContentExtension.cs
+System.Xml.Schema\\XmlSchemaSimpleContentRestriction.cs
+System.Xml.Schema\\XmlSchemaSimpleType.cs
+System.Xml.Schema\\XmlSchemaSimpleTypeContent.cs
+System.Xml.Schema\\XmlSchemaSimpleTypeList.cs
+System.Xml.Schema\\XmlSchemaSimpleTypeRestriction.cs
+System.Xml.Schema\\XmlSchemaSimpleTypeUnion.cs
+System.Xml.Schema\\XmlSchemaTotalDigitsFacet.cs
+System.Xml.Schema\\XmlSchemaType.cs
+System.Xml.Schema\\XmlSchemaUnique.cs
+System.Xml.Schema\\XmlSchemaUse.cs
+System.Xml.Schema\\XmlSchemaUtil.cs
+System.Xml.Schema\\XmlSchemaWhiteSpaceFacet.cs
+System.Xml.Schema\\XmlSchemaXPath.cs
+System.Xml.Schema\\XmlSeverityType.cs
+System.Xml.XPath\\IXPathNavigable.cs
+System.Xml.XPath\\XmlCaseOrder.cs
+System.Xml.XPath\\XmlDataType.cs
+System.Xml.XPath\\XmlSortOrder.cs
+System.Xml.XPath\\XPathDocument.cs
+System.Xml.XPath\\XPathException.cs
+System.Xml.XPath\\XPathExpression.cs
+System.Xml.XPath\\XPathNamespaceScope.cs
+System.Xml.XPath\\XPathNavigator.cs
+System.Xml.XPath\\XPathNodeIterator.cs
+System.Xml.XPath\\XPathNodeType.cs
+System.Xml.XPath\\XPathResultType.cs
+System.Xml.XPath\\XPathScanner.cs
+System.Xml.Xsl\\IXsltContextFunction.cs
+System.Xml.Xsl\\IXsltContextVariable.cs
+System.Xml.Xsl\\XsltArgumentList.cs
+System.Xml.Xsl\\XsltCompileException.cs
+System.Xml.Xsl\\XsltContext.cs
+System.Xml.Xsl\\XsltException.cs
+System.Xml.Xsl\\XslTransform.cs
+System.Xml.Serialization\\SoapAttributeAttribute.cs
+System.Xml.Serialization\\SoapAttributeOverrides.cs
+System.Xml.Serialization\\SoapAttributes.cs
+System.Xml.Serialization\\SoapElementAttribute.cs
+System.Xml.Serialization\\SoapEnumAttribute.cs
+System.Xml.Serialization\\SoapIgnoreAttribute.cs
+System.Xml.Serialization\\SoapIncludeAttribute.cs
+System.Xml.Serialization\\SoapSchemaExporter.cs
+System.Xml.Serialization\\SoapTypeAttribute.cs
+System.Xml.Serialization\\UnreferencedObjectEventArgs.cs
+System.Xml.Serialization\\XmlAnyAttributeAttribute.cs
+System.Xml.Serialization\\XmlAnyElementAttribute.cs
+System.Xml.Serialization\\XmlAnyElementAttributes.cs
+System.Xml.Serialization\\XmlArrayAttribute.cs
+System.Xml.Serialization\\XmlArrayItemAttribute.cs
+System.Xml.Serialization\\XmlArrayItemAttributes.cs
+System.Xml.Serialization\\XmlAttributeAttribute.cs
+System.Xml.Serialization\\XmlAttributeEventArgs.cs
+System.Xml.Serialization\\XmlAttributeOverrides.cs
+System.Xml.Serialization\\XmlAttributes.cs
+System.Xml.Serialization\\XmlChoiceIdentifierAttribute.cs
+System.Xml.Serialization\\XmlElementAttribute.cs
+System.Xml.Serialization\\XmlElementAttributes.cs
+System.Xml.Serialization\\XmlElementEventArgs.cs
+System.Xml.Serialization\\XmlEnumAttribute.cs
+System.Xml.Serialization\\XmlIgnoreAttribute.cs
+System.Xml.Serialization\\XmlIncludeAttribute.cs
+System.Xml.Serialization\\XmlMapping.cs
+System.Xml.Serialization\\XmlNamespaceDeclarationsAttribute.cs
+System.Xml.Serialization\\XmlNodeEventArgs.cs
+System.Xml.Serialization\\XmlRootAttribute.cs
+System.Xml.Serialization\\XmlSerializer.cs
+System.Xml.Serialization\\XmlSerializerNamespaces.cs
+System.Xml.Serialization\\XmlTextAttribute.cs
+System.Xml.Serialization\\XmlTypeAttribute.cs
+System.Xml.Serialization\\XmlTypeMapping.cs
+System.Xml.Serialization\\XmlAttributeEventHandler.cs
+System.Xml.Serialization\\XmlElementEventHandler.cs
+System.Xml.Serialization\\XmlNodeEventHandler.cs
+System.Xml.Serialization\\UnreferencedObjectEventHandler.cs
diff --git a/mcs/class/System.XML/list.unix b/mcs/class/System.XML/list.unix
new file mode 100755
index 00000000000..50b757eea79
--- /dev/null
+++ b/mcs/class/System.XML/list.unix
@@ -0,0 +1,226 @@
+System.Xml/IHasXmlNode.cs
+System.Xml/EntityHandling.cs
+System.Xml/Formatting.cs
+System.Xml/IXmlLineInfo.cs
+System.Xml/NameTable.cs
+System.Xml/ReadState.cs
+System.Xml/TODOAttribute.cs
+System.Xml/ValidationType.cs
+System.Xml/XmlEntity.cs
+System.Xml/WhitespaceHandling.cs
+System.Xml/WriteState.cs
+System.Xml/XmlTextWriter.cs
+System.Xml/XmlAttribute.cs
+System.Xml/XmlAttributeCollection.cs
+System.Xml/XmlCDataSection.cs
+System.Xml/XmlConstructs.cs
+System.Xml/XmlChar.cs
+System.Xml/XmlCharacterData.cs
+System.Xml/XmlComment.cs
+System.Xml/XmlNotation.cs
+System.Xml/XmlDeclaration.cs
+System.Xml/XmlDocument.cs
+System.Xml/XmlDocumentFragment.cs
+System.Xml/XmlDocumentType.cs
+System.Xml/XmlElement.cs
+System.Xml/XmlEntityReference.cs
+System.Xml/XmlException.cs
+System.Xml/XmlNodeReader.cs
+System.Xml/XmlImplementation.cs
+System.Xml/XmlConvert.cs
+System.Xml/XmlLinkedNode.cs
+System.Xml/XmlNameTable.cs
+System.Xml/XmlNamedNodeMap.cs
+System.Xml/XmlNamespaceManager.cs
+System.Xml/XmlNode.cs
+System.Xml/XmlNodeChangedAction.cs
+System.Xml/XmlNodeChangedEventArgs.cs
+System.Xml/XmlNodeList.cs
+System.Xml/XmlNodeListChildren.cs
+System.Xml/XmlNodeOrder.cs
+System.Xml/XmlNodeType.cs
+System.Xml/XmlParserContext.cs
+System.Xml/XmlProcessingInstruction.cs
+System.Xml/XmlQualifiedName.cs
+System.Xml/XmlReader.cs
+System.Xml/XmlResolver.cs
+System.Xml/XmlSignificantWhitespace.cs
+System.Xml/XmlSpace.cs
+System.Xml/XmlText.cs
+System.Xml/XmlTextReader.cs
+System.Xml/XmlTokenizedType.cs
+System.Xml/XmlUrlResolver.cs
+System.Xml/XmlValidatingReader.cs
+System.Xml/XmlWhitespace.cs
+System.Xml/XmlWriter.cs
+System.Xml/XmlNodeChangedEventHandler.cs
+System.Xml/XmlTextWriterOpenElement.cs
+System.Xml/XmlDocumentNavigator.cs
+System.Xml/XmlNodeArrayList.cs
+System.Xml.XPath/IXPathNavigable.cs
+System.Xml.XPath/XPathNavigator.cs
+System.Xml.XPath/XPathExpression.cs
+System.Xml.XPath/XPathNamespaceScope.cs
+System.Xml.XPath/XPathNodeIterator.cs
+System.Xml.XPath/XPathResultType.cs
+System.Xml.XPath/XPathNodeType.cs
+System.Xml.XPath/XmlDataType.cs
+System.Xml.XPath/XmlSortOrder.cs
+System.Xml.XPath/XmlCaseOrder.cs
+System.Xml.XPath/XPathDocument.cs
+System.Xml.XPath/XPathException.cs
+System.Xml.XPath/DefaultContext.cs
+System.Xml.XPath/Expression.cs
+System.Xml.XPath/Iterator.cs
+System.Xml.XPath/Parser.cs
+System.Xml.XPath/Tokenizer.cs
+System.Xml.Xsl/IXsltContextFunction.cs
+System.Xml.Xsl/IXsltContextVariable.cs
+System.Xml.Xsl/XslTransform.cs
+System.Xml.Xsl/XsltArgumentList.cs
+System.Xml.Xsl/XsltCompileException.cs
+System.Xml.Xsl/XsltContext.cs
+System.Xml.Xsl/XsltException.cs
+System.Xml.Schema/ValidationEventArgs.cs
+System.Xml.Schema/XmlSchema.cs
+System.Xml.Schema/XmlSchemaAll.cs
+System.Xml.Schema/XmlSchemaAnnotated.cs
+System.Xml.Schema/XmlSchemaAnnotation.cs
+System.Xml.Schema/XmlSchemaAny.cs
+System.Xml.Schema/XmlSchemaAnyAttribute.cs
+System.Xml.Schema/XmlSchemaAppInfo.cs
+System.Xml.Schema/XmlSchemaAttribute.cs
+System.Xml.Schema/XmlSchemaAttributeGroup.cs
+System.Xml.Schema/XmlSchemaAttributeGroupRef.cs
+System.Xml.Schema/XmlSchemaChoice.cs
+System.Xml.Schema/XmlSchemaCollection.cs
+System.Xml.Schema/XmlSchemaCollectionEnumerator.cs
+System.Xml.Schema/XmlSchemaComplexContent.cs
+System.Xml.Schema/XmlSchemaComplexContentExtension.cs
+System.Xml.Schema/XmlSchemaComplexContentRestriction.cs
+System.Xml.Schema/XmlSchemaComplexType.cs
+System.Xml.Schema/XmlSchemaContent.cs
+System.Xml.Schema/XmlSchemaContentModel.cs
+System.Xml.Schema/XmlSchemaContentProcessing.cs
+System.Xml.Schema/XmlSchemaContentType.cs
+System.Xml.Schema/XmlSchemaDatatype.cs
+System.Xml.Schema/XmlSchemaDerivationMethod.cs
+System.Xml.Schema/XmlSchemaDocumentation.cs
+System.Xml.Schema/XmlSchemaElement.cs
+System.Xml.Schema/XmlSchemaEnumerationFacet.cs
+System.Xml.Schema/XmlSchemaException.cs
+System.Xml.Schema/XmlSchemaExternal.cs
+System.Xml.Schema/XmlSchemaFacet.cs
+System.Xml.Schema/XmlSchemaForm.cs
+System.Xml.Schema/XmlSchemaFractionDigitsFacet.cs
+System.Xml.Schema/XmlSchemaGroup.cs
+System.Xml.Schema/XmlSchemaGroupBase.cs
+System.Xml.Schema/XmlSchemaGroupRef.cs
+System.Xml.Schema/XmlSchemaIdentityConstraint.cs
+System.Xml.Schema/XmlSchemaImport.cs
+System.Xml.Schema/XmlSchemaInclude.cs
+System.Xml.Schema/XmlSchemaKey.cs
+System.Xml.Schema/XmlSchemaKeyref.cs
+System.Xml.Schema/XmlSchemaLengthFacet.cs
+System.Xml.Schema/XmlSchemaMaxExclusiveFacet.cs
+System.Xml.Schema/XmlSchemaMaxInclusiveFacet.cs
+System.Xml.Schema/XmlSchemaMaxLengthFacet.cs
+System.Xml.Schema/XmlSchemaMinExclusiveFacet.cs
+System.Xml.Schema/XmlSchemaMinInclusiveFacet.cs
+System.Xml.Schema/XmlSchemaMinLengthFacet.cs
+System.Xml.Schema/XmlSchemaNotation.cs
+System.Xml.Schema/XmlSchemaNumericFacet.cs
+System.Xml.Schema/XmlSchemaObject.cs
+System.Xml.Schema/XmlSchemaObjectCollection.cs
+System.Xml.Schema/XmlSchemaObjectEnumerator.cs
+System.Xml.Schema/XmlSchemaObjectTable.cs
+System.Xml.Schema/XmlSchemaParticle.cs
+System.Xml.Schema/XmlSchemaPatternFacet.cs
+System.Xml.Schema/XmlSchemaRedefine.cs
+System.Xml.Schema/XmlSchemaSequence.cs
+System.Xml.Schema/XmlSchemaSimpleContent.cs
+System.Xml.Schema/XmlSchemaSimpleContentExtension.cs
+System.Xml.Schema/XmlSchemaSimpleContentRestriction.cs
+System.Xml.Schema/XmlSchemaSimpleType.cs
+System.Xml.Schema/XmlSchemaSimpleTypeContent.cs
+System.Xml.Schema/XmlSchemaSimpleTypeList.cs
+System.Xml.Schema/XmlSchemaSimpleTypeRestriction.cs
+System.Xml.Schema/XmlSchemaSimpleTypeUnion.cs
+System.Xml.Schema/XmlSchemaTotalDigitsFacet.cs
+System.Xml.Schema/XmlSchemaType.cs
+System.Xml.Schema/XmlSchemaUnique.cs
+System.Xml.Schema/XmlSchemaUse.cs
+System.Xml.Schema/XmlSchemaWhiteSpaceFacet.cs
+System.Xml.Schema/XmlSchemaXPath.cs
+System.Xml.Schema/XmlSeverityType.cs
+System.Xml.Schema/ValidationHandler.cs
+System.Xml.Schema/XmlSchemaInfo.cs
+System.Xml.Schema/XmlSchemaUtil.cs
+System.Xml.Schema/XmlSchemaReader.cs
+System.Xml.Serialization/AssemblyInfo.cs
+System.Xml.Serialization/CodeIdentifier.cs
+System.Xml.Serialization/CodeIdentifiers.cs
+System.Xml.Serialization/IXmlSerializable.cs
+System.Xml.Serialization/SchemaTypes.cs
+System.Xml.Serialization/SoapAttributeAttribute.cs
+System.Xml.Serialization/SoapAttributeOverrides.cs
+System.Xml.Serialization/SoapAttributes.cs
+System.Xml.Serialization/SoapCodeExporter.cs
+System.Xml.Serialization/SoapElementAttribute.cs
+System.Xml.Serialization/SoapEnumAttribute.cs
+System.Xml.Serialization/SoapIgnoreAttribute.cs
+System.Xml.Serialization/SoapIncludeAttribute.cs
+System.Xml.Serialization/SoapSchemaImporter.cs
+System.Xml.Serialization/SoapSchemaExporter.cs
+System.Xml.Serialization/SoapSchemaMember.cs
+System.Xml.Serialization/SoapReflectionImporter.cs
+System.Xml.Serialization/SoapTypeAttribute.cs
+System.Xml.Serialization/TypeData.cs
+System.Xml.Serialization/TypeMember.cs
+System.Xml.Serialization/TypeTranslator.cs
+System.Xml.Serialization/UnreferencedObjectEventArgs.cs
+System.Xml.Serialization/UnreferencedObjectEventHandler.cs
+System.Xml.Serialization/XmlAnyAttributeAttribute.cs
+System.Xml.Serialization/XmlAnyElementAttribute.cs
+System.Xml.Serialization/XmlAnyElementAttributes.cs
+System.Xml.Serialization/XmlArrayAttribute.cs
+System.Xml.Serialization/XmlArrayItemAttribute.cs
+System.Xml.Serialization/XmlArrayItemAttributes.cs
+System.Xml.Serialization/XmlAttributeAttribute.cs
+System.Xml.Serialization/XmlAttributeEventArgs.cs
+System.Xml.Serialization/XmlAttributeEventHandler.cs
+System.Xml.Serialization/XmlAttributeOverrides.cs
+System.Xml.Serialization/XmlAttributes.cs
+System.Xml.Serialization/XmlCodeExporter.cs
+System.Xml.Serialization/XmlChoiceIdentifierAttribute.cs
+System.Xml.Serialization/XmlCustomFormatter.cs
+System.Xml.Serialization/XmlElementAttribute.cs
+System.Xml.Serialization/XmlElementAttributes.cs
+System.Xml.Serialization/XmlElementEventArgs.cs
+System.Xml.Serialization/XmlEnumAttribute.cs
+System.Xml.Serialization/XmlIgnoreAttribute.cs
+System.Xml.Serialization/XmlIncludeAttribute.cs
+System.Xml.Serialization/XmlMemberMapping.cs
+System.Xml.Serialization/XmlMembersMapping.cs
+System.Xml.Serialization/XmlMapping.cs
+System.Xml.Serialization/XmlNamespaceDeclarationsAttribute.cs
+System.Xml.Serialization/XmlNodeEventArgs.cs
+System.Xml.Serialization/XmlReflectionImporter.cs
+System.Xml.Serialization/XmlReflectionMember.cs
+System.Xml.Serialization/XmlRootAttribute.cs
+System.Xml.Serialization/XmlSchemaExporter.cs
+System.Xml.Serialization/XmlSchemaImporter.cs
+System.Xml.Serialization/XmlSchemas.cs
+System.Xml.Serialization/XmlSerializationCollectionFixupCallback.cs
+System.Xml.Serialization/XmlSerializationFixupCallback.cs
+System.Xml.Serialization/XmlSerializationReadCallback.cs
+System.Xml.Serialization/XmlSerializationReader.cs
+System.Xml.Serialization/XmlSerializationWriteCallback.cs
+System.Xml.Serialization/XmlSerializationWriter.cs
+System.Xml.Serialization/XmlSerializer.cs
+System.Xml.Serialization/XmlSerializerNamespaces.cs
+System.Xml.Serialization/XmlTextAttribute.cs
+System.Xml.Serialization/XmlTypeAttribute.cs
+System.Xml.Serialization/XmlTypeMapping.cs
+System.Xml.Serialization/XmlElementEventHandler.cs
+System.Xml.Serialization/XmlNodeEventHandler.cs
diff --git a/mcs/class/System.XML/makefile.gnu b/mcs/class/System.XML/makefile.gnu
new file mode 100644
index 00000000000..c18c93c190e
--- /dev/null
+++ b/mcs/class/System.XML/makefile.gnu
@@ -0,0 +1,16 @@
+topdir = ../..
+
+TEST_DIR = Test
+LIBRARY = $(topdir)/class/lib/System.Xml.dll
+
+LIB_LIST = list.unix
+LIB_FLAGS = -r corlib -r System
+
+SOURCES_INCLUDE=*.cs
+SOURCES_EXCLUDE=\
+ ./Test* \
+ ./System.Xml/Driver.cs
+
+export MONO_PATH_PREFIX = $(topdir)/class/lib:
+
+include $(topdir)/class/library.make