// Dwivedi, Ajay kumar Adwiv@Yahoo.com\r
// Enomoto, Atsushi ginga@kit.hi-ho.ne.jp\r
//\r
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
using System;\r
using System.Collections;\r
using System.Xml;\r
public class XmlSchemaElement : XmlSchemaParticle\r
{\r
private XmlSchemaDerivationMethod block;\r
- private XmlSchemaDerivationMethod blockResolved;\r
private XmlSchemaObjectCollection constraints;\r
private string defaultValue;\r
private object elementType;\r
+#if NET_2_0\r
+ private XmlSchemaType elementSchemaType;\r
+#endif\r
private XmlSchemaDerivationMethod final;\r
- private XmlSchemaDerivationMethod finalResolved;\r
private string fixedValue;\r
private XmlSchemaForm form;\r
private bool isAbstract;\r
private bool isNillable;\r
private string name;\r
- private XmlQualifiedName qName;\r
private XmlQualifiedName refName;\r
private XmlSchemaType schemaType;\r
private XmlQualifiedName schemaTypeName;\r
private XmlQualifiedName substitutionGroup;\r
+\r
+ // Post compilation items.\r
+ XmlSchema schema;\r
internal bool parentIsSchema = false;\r
- private string validatedDefaultValue;\r
- private string validatedFixedValue;\r
+ private XmlQualifiedName qName;\r
+ private XmlSchemaDerivationMethod blockResolved;\r
+ private XmlSchemaDerivationMethod finalResolved;\r
+// private XmlSchemaParticle substChoice;\r
+ private XmlSchemaElement referencedElement;\r
+ private ArrayList substitutingElements = new ArrayList ();\r
+ private XmlSchemaElement substitutionGroupElement;\r
private bool actualIsAbstract;\r
private bool actualIsNillable;\r
- private XmlSchemaElement substitutionGroupElement;\r
- private ArrayList substitutingElements = new ArrayList ();\r
- private XmlSchemaElement referencedElement;\r
-\r
- // Post compilation items. It should be added on all schema components.\r
- XmlSchema schema;\r
+ private string validatedDefaultValue;\r
+ private string validatedFixedValue;\r
\r
const string xmlname = "element";\r
\r
block = XmlSchemaDerivationMethod.None;\r
final = XmlSchemaDerivationMethod.None;\r
constraints = new XmlSchemaObjectCollection();\r
- qName = XmlQualifiedName.Empty;\r
refName = XmlQualifiedName.Empty;\r
schemaTypeName = XmlQualifiedName.Empty;\r
substitutionGroup = XmlQualifiedName.Empty;\r
+ InitPostCompileInformations ();\r
+ }\r
+\r
+ private void InitPostCompileInformations ()\r
+ {\r
+ qName = XmlQualifiedName.Empty;\r
+ schema = null;\r
+// parentIsSchema = false; ... it is set in Schema's Compile()\r
+ blockResolved = XmlSchemaDerivationMethod.None;\r
+ finalResolved = XmlSchemaDerivationMethod.None;\r
+// substChoice = null;\r
+ referencedElement = null;\r
+ substitutingElements.Clear ();\r
+ substitutionGroupElement = null;\r
+ actualIsAbstract = false;\r
+ actualIsNillable = false;\r
+ validatedDefaultValue = null;\r
+ validatedFixedValue = null;\r
}\r
\r
#region Attributes\r
set{ form = value; }\r
}\r
\r
- [DefaultValue(null)]\r
+ [DefaultValue("")]\r
[System.Xml.Serialization.XmlAttribute("name")]\r
public string Name \r
{\r
\r
#region Elements\r
\r
- [XmlElement("simpleType",typeof(XmlSchemaSimpleType),Namespace="http://www.w3.org/2001/XMLSchema")]\r
- [XmlElement("complexType",typeof(XmlSchemaComplexType),Namespace="http://www.w3.org/2001/XMLSchema")]\r
+ [XmlElement("simpleType",typeof(XmlSchemaSimpleType))]\r
+ [XmlElement("complexType",typeof(XmlSchemaComplexType))]\r
public XmlSchemaType SchemaType \r
{\r
get{ return schemaType; }\r
set{ schemaType = value; }\r
}\r
\r
- [XmlElement("unique",typeof(XmlSchemaUnique),Namespace="http://www.w3.org/2001/XMLSchema")]\r
- [XmlElement("key",typeof(XmlSchemaKey),Namespace="http://www.w3.org/2001/XMLSchema")]\r
- [XmlElement("keyref",typeof(XmlSchemaKeyref),Namespace="http://www.w3.org/2001/XMLSchema")]\r
+ [XmlElement("unique",typeof(XmlSchemaUnique))]\r
+ [XmlElement("key",typeof(XmlSchemaKey))]\r
+ [XmlElement("keyref",typeof(XmlSchemaKeyref))]\r
public XmlSchemaObjectCollection Constraints \r
{\r
get{ return constraints; }\r
}\r
\r
[XmlIgnore]\r
+#if NET_2_0\r
+ [Obsolete]\r
+#endif\r
public object ElementType \r
{\r
get {\r
}\r
}\r
\r
+#if NET_2_0\r
+ [XmlIgnore]\r
+ public XmlSchemaType ElementSchemaType\r
+ {\r
+ get {\r
+ if (referencedElement != null)\r
+ return referencedElement.ElementSchemaType;\r
+ else\r
+ return elementSchemaType;\r
+ }\r
+ }\r
+#endif\r
+\r
[XmlIgnore]\r
public XmlSchemaDerivationMethod BlockResolved \r
{\r
\r
#endregion\r
\r
- private XmlSchemaParticle substChoice;\r
-\r
/// <remarks>\r
/// a) If Element has parent as schema:\r
/// 1. name must be present and of type NCName.\r
internal override int Compile(ValidationEventHandler h, XmlSchema schema)\r
{\r
// If this is already compiled this time, simply skip.\r
- if (this.IsComplied (schema.CompilationId))\r
+ if (CompilationId == schema.CompilationId)\r
return 0;\r
+ InitPostCompileInformations ();\r
this.schema = schema;\r
+#if NET_2_0\r
+ if (SchemaType != null)\r
+ SchemaType.Parent = this;\r
+ foreach (XmlSchemaObject obj in Constraints)\r
+ obj.Parent = this;\r
+#endif\r
\r
if(this.defaultValue != null && this.fixedValue != null)\r
error(h,"both default and fixed can't be present");\r
XmlSchemaChoice choice = new XmlSchemaChoice ();\r
choice.MinOccurs = MinOccurs;\r
choice.MaxOccurs = MaxOccurs;\r
- substChoice = choice;\r
+// substChoice = choice;\r
choice.Compile (null, schema); // compute Validated Min/Max Occurs.\r
XmlSchemaElement item = this.MemberwiseClone () as XmlSchemaElement;\r
item.MinOccurs = 1;\r
if (schemaType != null)\r
elementType = schemaType;\r
else if (SchemaTypeName != XmlQualifiedName.Empty) {\r
- XmlSchemaType type = schema.SchemaTypes [SchemaTypeName] as XmlSchemaType;\r
- // If el is null, then it is missing sub components .\r
+ XmlSchemaType type = schema.FindSchemaType (SchemaTypeName);\r
if (type != null) {\r
type.Validate (h, schema);\r
elementType = type;\r
foreach (XmlSchemaIdentityConstraint ident in Constraints)\r
ident.Validate (h, schema);\r
\r
+#if NET_2_0\r
+ if (elementType != null) {\r
+ elementSchemaType = elementType as XmlSchemaType;\r
+ if (elementType == XmlSchemaSimpleType.AnySimpleType)\r
+ elementSchemaType = XmlSchemaSimpleType.XsAnySimpleType;\r
+ if (elementSchemaType == null)\r
+ elementSchemaType = XmlSchemaType.GetBuiltInSimpleType (SchemaTypeName);\r
+ }\r
+#endif\r
+\r
ValidationId = schema.ValidationId;\r
return errorCount;\r
}\r
break;\r
}\r
} else {\r
- if (any.TargetNamespace.Length == 0 ||\r
- any.TargetNamespace != this.QualifiedName.Namespace)\r
+ if (any.TargetNamespace != this.QualifiedName.Namespace)\r
error (h, "Ambiguous element label which is contained by -any- particle with ##other value was detected: " + this.QualifiedName);\r
}\r
}\r