diff --git a/LinqToXsd.Schemas/XsdFeatureTests/Attributes/ListType.xsd b/LinqToXsd.Schemas/XsdFeatureTests/Attributes/ListType.xsd
new file mode 100644
index 00000000..e5629c28
--- /dev/null
+++ b/LinqToXsd.Schemas/XsdFeatureTests/Attributes/ListType.xsd
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LinqToXsd.Schemas/XsdFeatureTests/Attributes/ListType.xsd.cs b/LinqToXsd.Schemas/XsdFeatureTests/Attributes/ListType.xsd.cs
new file mode 100644
index 00000000..190ae320
--- /dev/null
+++ b/LinqToXsd.Schemas/XsdFeatureTests/Attributes/ListType.xsd.cs
@@ -0,0 +1,625 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace urn.LinqToXsdCore.ListType {
+ using System;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.ComponentModel;
+ using System.IO;
+ using System.Linq;
+ using System.Diagnostics;
+ using System.Xml;
+ using System.Xml.Schema;
+ using System.Xml.Linq;
+ using Xml.Schema.Linq;
+
+
+ public partial class person : XTypedElement, IXMetaData {
+
+ public void Save(string xmlFile) {
+ XTypedServices.Save(xmlFile, Untyped);
+ }
+
+ public void Save(System.IO.TextWriter tw) {
+ XTypedServices.Save(tw, Untyped);
+ }
+
+ public void Save(System.Xml.XmlWriter xmlWriter) {
+ XTypedServices.Save(xmlWriter, Untyped);
+ }
+
+ public static person Load(string xmlFile) {
+ return XTypedServices.Load(xmlFile);
+ }
+
+ public static person Load(System.IO.TextReader xmlFile) {
+ return XTypedServices.Load(xmlFile);
+ }
+
+ public static person Parse(string xml) {
+ return XTypedServices.Parse(xml);
+ }
+
+ public static explicit operator person(XElement xe) { return XTypedServices.ToXTypedElement(xe,LinqToXsdTypeManager.Instance as ILinqToXsdTypeManager); }
+
+ public override XTypedElement Clone() {
+ return XTypedServices.CloneXTypedElement(this);
+ }
+
+ public person() {
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected internal static readonly System.Xml.Linq.XName otherNamesXName = System.Xml.Linq.XName.Get("otherNames", "");
+
+ ///
+ ///
+ /// Occurrence: optional
+ ///
+ ///
+ public virtual IList otherNames {
+ get {
+ XAttribute x = this.Attribute(otherNamesXName);
+ if ((x == null)) {
+ return null;
+ }
+ return XTypedServices.ParseListValue(x, XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String).Datatype);
+ }
+ set {
+ this.SetListAttribute(otherNamesXName, value, XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String).Datatype);
+ }
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected internal static readonly System.Xml.Linq.XName surnameXName = System.Xml.Linq.XName.Get("surname", "");
+
+ ///
+ ///
+ /// Occurrence: optional
+ ///
+ ///
+ public virtual string surname {
+ get {
+ XAttribute x = this.Attribute(surnameXName);
+ if ((x == null)) {
+ return null;
+ }
+ return XTypedServices.ParseValue(x, XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String).Datatype);
+ }
+ set {
+ this.SetAttribute(surnameXName, value, XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String).Datatype);
+ }
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected internal static readonly System.Xml.Linq.XName milestoneYearsXName = System.Xml.Linq.XName.Get("milestoneYears", "");
+
+ ///
+ ///
+ /// Occurrence: optional
+ ///
+ ///
+ public virtual IList milestoneYears {
+ get {
+ XAttribute x = this.Attribute(milestoneYearsXName);
+ if ((x == null)) {
+ return null;
+ }
+ return XTypedServices.ParseListValue(x, XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Int).Datatype);
+ }
+ set {
+ this.SetListAttribute(milestoneYearsXName, value, XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Int).Datatype);
+ }
+ }
+
+ private static readonly System.Xml.Linq.XName xName = System.Xml.Linq.XName.Get("person", "urn:LinqToXsdCore:ListType");
+
+ ContentModelEntity IXMetaData.GetContentModel() {
+ return ContentModelEntity.Default;
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ System.Xml.Linq.XName IXMetaData.SchemaName {
+ get {
+ return xName;
+ }
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ SchemaOrigin IXMetaData.TypeOrigin {
+ get {
+ return SchemaOrigin.Element;
+ }
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ ILinqToXsdTypeManager IXMetaData.TypeManager {
+ get {
+ return LinqToXsdTypeManager.Instance;
+ }
+ }
+ }
+
+ ///
+ ///
+ /// Regular expression: (person*)
+ ///
+ ///
+ public partial class persons : XTypedElement, IXMetaData {
+
+ public void Save(string xmlFile) {
+ XTypedServices.Save(xmlFile, Untyped);
+ }
+
+ public void Save(System.IO.TextWriter tw) {
+ XTypedServices.Save(tw, Untyped);
+ }
+
+ public void Save(System.Xml.XmlWriter xmlWriter) {
+ XTypedServices.Save(xmlWriter, Untyped);
+ }
+
+ public static persons Load(string xmlFile) {
+ return XTypedServices.Load(xmlFile);
+ }
+
+ public static persons Load(System.IO.TextReader xmlFile) {
+ return XTypedServices.Load(xmlFile);
+ }
+
+ public static persons Parse(string xml) {
+ return XTypedServices.Parse(xml);
+ }
+
+ public static explicit operator persons(XElement xe) { return XTypedServices.ToXTypedElement(xe,LinqToXsdTypeManager.Instance as ILinqToXsdTypeManager); }
+
+ public override XTypedElement Clone() {
+ return XTypedServices.CloneXTypedElement(this);
+ }
+
+ ///
+ ///
+ /// Regular expression: (person*)
+ ///
+ ///
+ public persons() {
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected internal static readonly System.Xml.Linq.XName personXName = System.Xml.Linq.XName.Get("person", "urn:LinqToXsdCore:ListType");
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private XTypedList personField;
+
+ ///
+ ///
+ /// Occurrence: optional, repeating
+ ///
+ ///
+ /// Regular expression: (person*)
+ ///
+ ///
+ public virtual IList person {
+ get {
+ if ((this.personField == null)) {
+ this.personField = new XTypedList(this, LinqToXsdTypeManager.Instance, personXName);
+ }
+ return this.personField;
+ }
+ set {
+ if ((value == null)) {
+ this.personField = null;
+ }
+ else {
+ if ((this.personField == null)) {
+ this.personField = XTypedList.Initialize(this, LinqToXsdTypeManager.Instance, value, personXName);
+ }
+ else {
+ XTypedServices.SetList(this.personField, value);
+ }
+ }
+ }
+ }
+
+ private static readonly System.Xml.Linq.XName xName = System.Xml.Linq.XName.Get("persons", "urn:LinqToXsdCore:ListType");
+
+ static persons() {
+ BuildElementDictionary();
+ contentModel = new SequenceContentModelEntity(new NamedContentModelEntity(personXName));
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private static Dictionary localElementDictionary = new Dictionary();
+
+ private static void BuildElementDictionary() {
+ localElementDictionary.Add(personXName, typeof(person));
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ Dictionary IXMetaData.LocalElementsDictionary {
+ get {
+ return localElementDictionary;
+ }
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private static ContentModelEntity contentModel;
+
+ ContentModelEntity IXMetaData.GetContentModel() {
+ return contentModel;
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ System.Xml.Linq.XName IXMetaData.SchemaName {
+ get {
+ return xName;
+ }
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ SchemaOrigin IXMetaData.TypeOrigin {
+ get {
+ return SchemaOrigin.Element;
+ }
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ ILinqToXsdTypeManager IXMetaData.TypeManager {
+ get {
+ return LinqToXsdTypeManager.Instance;
+ }
+ }
+ }
+
+ public class LinqToXsdTypeManager : ILinqToXsdTypeManager {
+
+ private LinqToXsdTypeManager() {
+ }
+
+ private static Dictionary elementDictionary = new Dictionary();
+
+ private static void BuildElementDictionary() {
+ elementDictionary.Add(System.Xml.Linq.XName.Get("person", "urn:LinqToXsdCore:ListType"), typeof(global::urn.LinqToXsdCore.ListType.person));
+ elementDictionary.Add(System.Xml.Linq.XName.Get("persons", "urn:LinqToXsdCore:ListType"), typeof(global::urn.LinqToXsdCore.ListType.persons));
+ }
+
+ private static XmlSchemaSet schemaSet;
+
+ XmlSchemaSet ILinqToXsdTypeManager.Schemas {
+ get {
+ if ((schemaSet == null)) {
+ XmlSchemaSet tempSet = new XmlSchemaSet();
+ System.Threading.Interlocked.CompareExchange(ref schemaSet, tempSet, null);
+ }
+ return schemaSet;
+ }
+ set {
+ schemaSet = value;
+ }
+ }
+
+ protected internal static void AddSchemas(XmlSchemaSet schemas) {
+ schemas.Add(schemaSet);
+ }
+
+ Dictionary ILinqToXsdTypeManager.GlobalTypeDictionary {
+ get {
+ return XTypedServices.EmptyDictionary;
+ }
+ }
+
+ Dictionary ILinqToXsdTypeManager.GlobalElementDictionary {
+ get {
+ return elementDictionary;
+ }
+ }
+
+ Dictionary ILinqToXsdTypeManager.RootContentTypeMapping {
+ get {
+ return XTypedServices.EmptyTypeMappingDictionary;
+ }
+ }
+
+ static LinqToXsdTypeManager() {
+ BuildElementDictionary();
+ }
+
+ public static System.Type GetRootType() {
+ return elementDictionary[System.Xml.Linq.XName.Get("person", "urn:LinqToXsdCore:ListType")];
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private static LinqToXsdTypeManager typeManagerSingleton = new LinqToXsdTypeManager();
+
+ public static LinqToXsdTypeManager Instance {
+ get {
+ return typeManagerSingleton;
+ }
+ }
+ }
+
+ public partial class XRootNamespace {
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private XDocument doc;
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private XTypedElement rootObject;
+
+ private XRootNamespace() {
+ }
+
+ public static XRootNamespace Load(string xmlFile) {
+ XRootNamespace root = new XRootNamespace();
+ root.doc = XDocument.Load(xmlFile);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRootNamespace Load(string xmlFile, LoadOptions options) {
+ XRootNamespace root = new XRootNamespace();
+ root.doc = XDocument.Load(xmlFile, options);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRootNamespace Load(TextReader textReader) {
+ XRootNamespace root = new XRootNamespace();
+ root.doc = XDocument.Load(textReader);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRootNamespace Load(TextReader textReader, LoadOptions options) {
+ XRootNamespace root = new XRootNamespace();
+ root.doc = XDocument.Load(textReader, options);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRootNamespace Load(XmlReader xmlReader) {
+ XRootNamespace root = new XRootNamespace();
+ root.doc = XDocument.Load(xmlReader);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRootNamespace Parse(string text) {
+ XRootNamespace root = new XRootNamespace();
+ root.doc = XDocument.Parse(text);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRootNamespace Parse(string text, LoadOptions options) {
+ XRootNamespace root = new XRootNamespace();
+ root.doc = XDocument.Parse(text, options);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public virtual void Save(string fileName) {
+ doc.Save(fileName);
+ }
+
+ public virtual void Save(TextWriter textWriter) {
+ doc.Save(textWriter);
+ }
+
+ public virtual void Save(XmlWriter writer) {
+ doc.Save(writer);
+ }
+
+ public virtual void Save(TextWriter textWriter, SaveOptions options) {
+ doc.Save(textWriter, options);
+ }
+
+ public virtual void Save(string fileName, SaveOptions options) {
+ doc.Save(fileName, options);
+ }
+
+ public virtual XDocument XDocument {
+ get {
+ return doc;
+ }
+ }
+
+ public virtual XTypedElement Root {
+ get {
+ return rootObject;
+ }
+ }
+
+ public XRootNamespace(person root) {
+ this.doc = new XDocument(root.Untyped);
+ this.rootObject = root;
+ }
+
+
+ public person person { get {return rootObject as person; } }
+
+ public XRootNamespace(persons root) {
+ this.doc = new XDocument(root.Untyped);
+ this.rootObject = root;
+ }
+
+
+ public persons persons { get {return rootObject as persons; } }
+ }
+
+ public partial class XRoot {
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private XDocument doc;
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private XTypedElement rootObject;
+
+ private XRoot() {
+ }
+
+ public static XRoot Load(string xmlFile) {
+ XRoot root = new XRoot();
+ root.doc = XDocument.Load(xmlFile);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRoot Load(string xmlFile, LoadOptions options) {
+ XRoot root = new XRoot();
+ root.doc = XDocument.Load(xmlFile, options);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRoot Load(TextReader textReader) {
+ XRoot root = new XRoot();
+ root.doc = XDocument.Load(textReader);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRoot Load(TextReader textReader, LoadOptions options) {
+ XRoot root = new XRoot();
+ root.doc = XDocument.Load(textReader, options);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRoot Load(XmlReader xmlReader) {
+ XRoot root = new XRoot();
+ root.doc = XDocument.Load(xmlReader);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRoot Parse(string text) {
+ XRoot root = new XRoot();
+ root.doc = XDocument.Parse(text);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRoot Parse(string text, LoadOptions options) {
+ XRoot root = new XRoot();
+ root.doc = XDocument.Parse(text, options);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public virtual void Save(string fileName) {
+ doc.Save(fileName);
+ }
+
+ public virtual void Save(TextWriter textWriter) {
+ doc.Save(textWriter);
+ }
+
+ public virtual void Save(XmlWriter writer) {
+ doc.Save(writer);
+ }
+
+ public virtual void Save(TextWriter textWriter, SaveOptions options) {
+ doc.Save(textWriter, options);
+ }
+
+ public virtual void Save(string fileName, SaveOptions options) {
+ doc.Save(fileName, options);
+ }
+
+ public virtual XDocument XDocument {
+ get {
+ return doc;
+ }
+ }
+
+ public virtual XTypedElement Root {
+ get {
+ return rootObject;
+ }
+ }
+
+ public XRoot(global::urn.LinqToXsdCore.ListType.person root) {
+ this.doc = new XDocument(root.Untyped);
+ this.rootObject = root;
+ }
+
+
+ public global::urn.LinqToXsdCore.ListType.person person { get {return rootObject as global::urn.LinqToXsdCore.ListType.person; } }
+
+ public XRoot(global::urn.LinqToXsdCore.ListType.persons root) {
+ this.doc = new XDocument(root.Untyped);
+ this.rootObject = root;
+ }
+
+
+ public global::urn.LinqToXsdCore.ListType.persons persons { get {return rootObject as global::urn.LinqToXsdCore.ListType.persons; } }
+ }
+}
diff --git a/LinqToXsd.Schemas/XsdFeatureTests/Attributes/ListTypeWithDefaults.xsd b/LinqToXsd.Schemas/XsdFeatureTests/Attributes/ListTypeWithDefaults.xsd
new file mode 100644
index 00000000..23ab0a82
--- /dev/null
+++ b/LinqToXsd.Schemas/XsdFeatureTests/Attributes/ListTypeWithDefaults.xsd
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LinqToXsd.Schemas/XsdFeatureTests/Attributes/ListTypeWithDefaults.xsd.cs b/LinqToXsd.Schemas/XsdFeatureTests/Attributes/ListTypeWithDefaults.xsd.cs
new file mode 100644
index 00000000..aba565b9
--- /dev/null
+++ b/LinqToXsd.Schemas/XsdFeatureTests/Attributes/ListTypeWithDefaults.xsd.cs
@@ -0,0 +1,660 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace urn.LinqToXsdCore.ListTypeWithDefaults {
+ using System;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.ComponentModel;
+ using System.IO;
+ using System.Linq;
+ using System.Diagnostics;
+ using System.Xml;
+ using System.Xml.Schema;
+ using System.Xml.Linq;
+ using Xml.Schema.Linq;
+
+
+ public partial class person : XTypedElement, IXMetaData {
+
+ public void Save(string xmlFile) {
+ XTypedServices.Save(xmlFile, Untyped);
+ }
+
+ public void Save(System.IO.TextWriter tw) {
+ XTypedServices.Save(tw, Untyped);
+ }
+
+ public void Save(System.Xml.XmlWriter xmlWriter) {
+ XTypedServices.Save(xmlWriter, Untyped);
+ }
+
+ public static person Load(string xmlFile) {
+ return XTypedServices.Load(xmlFile);
+ }
+
+ public static person Load(System.IO.TextReader xmlFile) {
+ return XTypedServices.Load(xmlFile);
+ }
+
+ public static person Parse(string xml) {
+ return XTypedServices.Parse(xml);
+ }
+
+ public static explicit operator person(XElement xe) { return XTypedServices.ToXTypedElement(xe,LinqToXsdTypeManager.Instance as ILinqToXsdTypeManager); }
+
+ public override XTypedElement Clone() {
+ return XTypedServices.CloneXTypedElement(this);
+ }
+
+ public person() {
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected internal static readonly System.Xml.Linq.XName otherNamesXName = System.Xml.Linq.XName.Get("otherNames", "");
+
+ ///
+ ///
+ /// Occurrence: optional
+ ///
+ ///
+ public virtual IList otherNames {
+ get {
+ XAttribute x = this.Attribute(otherNamesXName);
+ if ((x == null)) {
+ return null;
+ }
+ return XTypedServices.ParseListValue(x, XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String).Datatype);
+ }
+ set {
+ this.SetListAttribute(otherNamesXName, value, XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String).Datatype);
+ }
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected internal static readonly System.Xml.Linq.XName surnameXName = System.Xml.Linq.XName.Get("surname", "");
+
+ ///
+ ///
+ /// Occurrence: optional
+ ///
+ ///
+ public virtual string surname {
+ get {
+ XAttribute x = this.Attribute(surnameXName);
+ if ((x == null)) {
+ return null;
+ }
+ return XTypedServices.ParseValue(x, XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String).Datatype);
+ }
+ set {
+ this.SetAttribute(surnameXName, value, XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String).Datatype);
+ }
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected internal static readonly System.Xml.Linq.XName milestoneYearsXName = System.Xml.Linq.XName.Get("milestoneYears", "");
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ internal static IList milestoneYearsDefaultValue = new int[] {
+ System.Xml.XmlConvert.ToInt32("1"),
+ System.Xml.XmlConvert.ToInt32("2"),
+ System.Xml.XmlConvert.ToInt32("3"),
+ System.Xml.XmlConvert.ToInt32("4"),
+ System.Xml.XmlConvert.ToInt32("5")};
+
+ ///
+ ///
+ /// Occurrence: optional
+ ///
+ ///
+ public virtual IList milestoneYears {
+ get {
+ XAttribute x = this.Attribute(milestoneYearsXName);
+ if ((x == null)) {
+ return milestoneYearsDefaultValue;
+ }
+ return XTypedServices.ParseListValue(x, XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Int).Datatype);
+ }
+ set {
+ this.SetListAttribute(milestoneYearsXName, value, XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Int).Datatype);
+ }
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected internal static readonly System.Xml.Linq.XName tagsXName = System.Xml.Linq.XName.Get("tags", "");
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ internal static IList tagsDefaultValue = new string[] {
+ "human",
+ "bipedal"};
+
+ ///
+ ///
+ /// Occurrence: optional
+ ///
+ ///
+ public virtual IList tags {
+ get {
+ XAttribute x = this.Attribute(tagsXName);
+ if ((x == null)) {
+ return tagsDefaultValue;
+ }
+ return XTypedServices.ParseListValue(x, XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.NCName).Datatype);
+ }
+ set {
+ this.SetListAttribute(tagsXName, value, XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.NCName).Datatype);
+ }
+ }
+
+ private static readonly System.Xml.Linq.XName xName = System.Xml.Linq.XName.Get("person", "urn:LinqToXsdCore:ListTypeWithDefaults");
+
+ ContentModelEntity IXMetaData.GetContentModel() {
+ return ContentModelEntity.Default;
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ System.Xml.Linq.XName IXMetaData.SchemaName {
+ get {
+ return xName;
+ }
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ SchemaOrigin IXMetaData.TypeOrigin {
+ get {
+ return SchemaOrigin.Element;
+ }
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ ILinqToXsdTypeManager IXMetaData.TypeManager {
+ get {
+ return LinqToXsdTypeManager.Instance;
+ }
+ }
+ }
+
+ ///
+ ///
+ /// Regular expression: (person*)
+ ///
+ ///
+ public partial class persons : XTypedElement, IXMetaData {
+
+ public void Save(string xmlFile) {
+ XTypedServices.Save(xmlFile, Untyped);
+ }
+
+ public void Save(System.IO.TextWriter tw) {
+ XTypedServices.Save(tw, Untyped);
+ }
+
+ public void Save(System.Xml.XmlWriter xmlWriter) {
+ XTypedServices.Save(xmlWriter, Untyped);
+ }
+
+ public static persons Load(string xmlFile) {
+ return XTypedServices.Load(xmlFile);
+ }
+
+ public static persons Load(System.IO.TextReader xmlFile) {
+ return XTypedServices.Load(xmlFile);
+ }
+
+ public static persons Parse(string xml) {
+ return XTypedServices.Parse(xml);
+ }
+
+ public static explicit operator persons(XElement xe) { return XTypedServices.ToXTypedElement(xe,LinqToXsdTypeManager.Instance as ILinqToXsdTypeManager); }
+
+ public override XTypedElement Clone() {
+ return XTypedServices.CloneXTypedElement(this);
+ }
+
+ ///
+ ///
+ /// Regular expression: (person*)
+ ///
+ ///
+ public persons() {
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected internal static readonly System.Xml.Linq.XName personXName = System.Xml.Linq.XName.Get("person", "urn:LinqToXsdCore:ListTypeWithDefaults");
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private XTypedList personField;
+
+ ///
+ ///
+ /// Occurrence: optional, repeating
+ ///
+ ///
+ /// Regular expression: (person*)
+ ///
+ ///
+ public virtual IList person {
+ get {
+ if ((this.personField == null)) {
+ this.personField = new XTypedList(this, LinqToXsdTypeManager.Instance, personXName);
+ }
+ return this.personField;
+ }
+ set {
+ if ((value == null)) {
+ this.personField = null;
+ }
+ else {
+ if ((this.personField == null)) {
+ this.personField = XTypedList.Initialize(this, LinqToXsdTypeManager.Instance, value, personXName);
+ }
+ else {
+ XTypedServices.SetList(this.personField, value);
+ }
+ }
+ }
+ }
+
+ private static readonly System.Xml.Linq.XName xName = System.Xml.Linq.XName.Get("persons", "urn:LinqToXsdCore:ListTypeWithDefaults");
+
+ static persons() {
+ BuildElementDictionary();
+ contentModel = new SequenceContentModelEntity(new NamedContentModelEntity(personXName));
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private static Dictionary localElementDictionary = new Dictionary();
+
+ private static void BuildElementDictionary() {
+ localElementDictionary.Add(personXName, typeof(person));
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ Dictionary IXMetaData.LocalElementsDictionary {
+ get {
+ return localElementDictionary;
+ }
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private static ContentModelEntity contentModel;
+
+ ContentModelEntity IXMetaData.GetContentModel() {
+ return contentModel;
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ System.Xml.Linq.XName IXMetaData.SchemaName {
+ get {
+ return xName;
+ }
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ SchemaOrigin IXMetaData.TypeOrigin {
+ get {
+ return SchemaOrigin.Element;
+ }
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ ILinqToXsdTypeManager IXMetaData.TypeManager {
+ get {
+ return LinqToXsdTypeManager.Instance;
+ }
+ }
+ }
+
+ public class LinqToXsdTypeManager : ILinqToXsdTypeManager {
+
+ private LinqToXsdTypeManager() {
+ }
+
+ private static Dictionary elementDictionary = new Dictionary();
+
+ private static void BuildElementDictionary() {
+ elementDictionary.Add(System.Xml.Linq.XName.Get("person", "urn:LinqToXsdCore:ListTypeWithDefaults"), typeof(global::urn.LinqToXsdCore.ListTypeWithDefaults.person));
+ elementDictionary.Add(System.Xml.Linq.XName.Get("persons", "urn:LinqToXsdCore:ListTypeWithDefaults"), typeof(global::urn.LinqToXsdCore.ListTypeWithDefaults.persons));
+ }
+
+ private static XmlSchemaSet schemaSet;
+
+ XmlSchemaSet ILinqToXsdTypeManager.Schemas {
+ get {
+ if ((schemaSet == null)) {
+ XmlSchemaSet tempSet = new XmlSchemaSet();
+ System.Threading.Interlocked.CompareExchange(ref schemaSet, tempSet, null);
+ }
+ return schemaSet;
+ }
+ set {
+ schemaSet = value;
+ }
+ }
+
+ protected internal static void AddSchemas(XmlSchemaSet schemas) {
+ schemas.Add(schemaSet);
+ }
+
+ Dictionary ILinqToXsdTypeManager.GlobalTypeDictionary {
+ get {
+ return XTypedServices.EmptyDictionary;
+ }
+ }
+
+ Dictionary ILinqToXsdTypeManager.GlobalElementDictionary {
+ get {
+ return elementDictionary;
+ }
+ }
+
+ Dictionary ILinqToXsdTypeManager.RootContentTypeMapping {
+ get {
+ return XTypedServices.EmptyTypeMappingDictionary;
+ }
+ }
+
+ static LinqToXsdTypeManager() {
+ BuildElementDictionary();
+ }
+
+ public static System.Type GetRootType() {
+ return elementDictionary[System.Xml.Linq.XName.Get("person", "urn:LinqToXsdCore:ListTypeWithDefaults")];
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private static LinqToXsdTypeManager typeManagerSingleton = new LinqToXsdTypeManager();
+
+ public static LinqToXsdTypeManager Instance {
+ get {
+ return typeManagerSingleton;
+ }
+ }
+ }
+
+ public partial class XRootNamespace {
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private XDocument doc;
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private XTypedElement rootObject;
+
+ private XRootNamespace() {
+ }
+
+ public static XRootNamespace Load(string xmlFile) {
+ XRootNamespace root = new XRootNamespace();
+ root.doc = XDocument.Load(xmlFile);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRootNamespace Load(string xmlFile, LoadOptions options) {
+ XRootNamespace root = new XRootNamespace();
+ root.doc = XDocument.Load(xmlFile, options);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRootNamespace Load(TextReader textReader) {
+ XRootNamespace root = new XRootNamespace();
+ root.doc = XDocument.Load(textReader);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRootNamespace Load(TextReader textReader, LoadOptions options) {
+ XRootNamespace root = new XRootNamespace();
+ root.doc = XDocument.Load(textReader, options);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRootNamespace Load(XmlReader xmlReader) {
+ XRootNamespace root = new XRootNamespace();
+ root.doc = XDocument.Load(xmlReader);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRootNamespace Parse(string text) {
+ XRootNamespace root = new XRootNamespace();
+ root.doc = XDocument.Parse(text);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRootNamespace Parse(string text, LoadOptions options) {
+ XRootNamespace root = new XRootNamespace();
+ root.doc = XDocument.Parse(text, options);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public virtual void Save(string fileName) {
+ doc.Save(fileName);
+ }
+
+ public virtual void Save(TextWriter textWriter) {
+ doc.Save(textWriter);
+ }
+
+ public virtual void Save(XmlWriter writer) {
+ doc.Save(writer);
+ }
+
+ public virtual void Save(TextWriter textWriter, SaveOptions options) {
+ doc.Save(textWriter, options);
+ }
+
+ public virtual void Save(string fileName, SaveOptions options) {
+ doc.Save(fileName, options);
+ }
+
+ public virtual XDocument XDocument {
+ get {
+ return doc;
+ }
+ }
+
+ public virtual XTypedElement Root {
+ get {
+ return rootObject;
+ }
+ }
+
+ public XRootNamespace(person root) {
+ this.doc = new XDocument(root.Untyped);
+ this.rootObject = root;
+ }
+
+
+ public person person { get {return rootObject as person; } }
+
+ public XRootNamespace(persons root) {
+ this.doc = new XDocument(root.Untyped);
+ this.rootObject = root;
+ }
+
+
+ public persons persons { get {return rootObject as persons; } }
+ }
+
+ public partial class XRoot {
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private XDocument doc;
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private XTypedElement rootObject;
+
+ private XRoot() {
+ }
+
+ public static XRoot Load(string xmlFile) {
+ XRoot root = new XRoot();
+ root.doc = XDocument.Load(xmlFile);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRoot Load(string xmlFile, LoadOptions options) {
+ XRoot root = new XRoot();
+ root.doc = XDocument.Load(xmlFile, options);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRoot Load(TextReader textReader) {
+ XRoot root = new XRoot();
+ root.doc = XDocument.Load(textReader);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRoot Load(TextReader textReader, LoadOptions options) {
+ XRoot root = new XRoot();
+ root.doc = XDocument.Load(textReader, options);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRoot Load(XmlReader xmlReader) {
+ XRoot root = new XRoot();
+ root.doc = XDocument.Load(xmlReader);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRoot Parse(string text) {
+ XRoot root = new XRoot();
+ root.doc = XDocument.Parse(text);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRoot Parse(string text, LoadOptions options) {
+ XRoot root = new XRoot();
+ root.doc = XDocument.Parse(text, options);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public virtual void Save(string fileName) {
+ doc.Save(fileName);
+ }
+
+ public virtual void Save(TextWriter textWriter) {
+ doc.Save(textWriter);
+ }
+
+ public virtual void Save(XmlWriter writer) {
+ doc.Save(writer);
+ }
+
+ public virtual void Save(TextWriter textWriter, SaveOptions options) {
+ doc.Save(textWriter, options);
+ }
+
+ public virtual void Save(string fileName, SaveOptions options) {
+ doc.Save(fileName, options);
+ }
+
+ public virtual XDocument XDocument {
+ get {
+ return doc;
+ }
+ }
+
+ public virtual XTypedElement Root {
+ get {
+ return rootObject;
+ }
+ }
+
+ public XRoot(global::urn.LinqToXsdCore.ListTypeWithDefaults.person root) {
+ this.doc = new XDocument(root.Untyped);
+ this.rootObject = root;
+ }
+
+
+ public global::urn.LinqToXsdCore.ListTypeWithDefaults.person person { get {return rootObject as global::urn.LinqToXsdCore.ListTypeWithDefaults.person; } }
+
+ public XRoot(global::urn.LinqToXsdCore.ListTypeWithDefaults.persons root) {
+ this.doc = new XDocument(root.Untyped);
+ this.rootObject = root;
+ }
+
+
+ public global::urn.LinqToXsdCore.ListTypeWithDefaults.persons persons { get {return rootObject as global::urn.LinqToXsdCore.ListTypeWithDefaults.persons; } }
+ }
+}
diff --git a/LinqToXsd.Schemas/XsdFeatureTests/Elements/ElementsListType.xsd b/LinqToXsd.Schemas/XsdFeatureTests/Elements/ElementsListType.xsd
new file mode 100644
index 00000000..e07fa260
--- /dev/null
+++ b/LinqToXsd.Schemas/XsdFeatureTests/Elements/ElementsListType.xsd
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/LinqToXsd.Schemas/XsdFeatureTests/Elements/ElementsListType.xsd.cs b/LinqToXsd.Schemas/XsdFeatureTests/Elements/ElementsListType.xsd.cs
new file mode 100644
index 00000000..d1b3a840
--- /dev/null
+++ b/LinqToXsd.Schemas/XsdFeatureTests/Elements/ElementsListType.xsd.cs
@@ -0,0 +1,479 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace urn.LinqToXsdCore.Elements.ListType {
+ using System;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.ComponentModel;
+ using System.IO;
+ using System.Linq;
+ using System.Diagnostics;
+ using System.Xml;
+ using System.Xml.Schema;
+ using System.Xml.Linq;
+ using Xml.Schema.Linq;
+
+
+ ///
+ ///
+ /// Regular expression: (names*)
+ ///
+ ///
+ public partial class name : XTypedElement, IXMetaData {
+
+ public void Save(string xmlFile) {
+ XTypedServices.Save(xmlFile, Untyped);
+ }
+
+ public void Save(System.IO.TextWriter tw) {
+ XTypedServices.Save(tw, Untyped);
+ }
+
+ public void Save(System.Xml.XmlWriter xmlWriter) {
+ XTypedServices.Save(xmlWriter, Untyped);
+ }
+
+ public static name Load(string xmlFile) {
+ return XTypedServices.Load(xmlFile);
+ }
+
+ public static name Load(System.IO.TextReader xmlFile) {
+ return XTypedServices.Load(xmlFile);
+ }
+
+ public static name Parse(string xml) {
+ return XTypedServices.Parse(xml);
+ }
+
+ public static explicit operator name(XElement xe) { return XTypedServices.ToXTypedElement(xe,LinqToXsdTypeManager.Instance as ILinqToXsdTypeManager); }
+
+ public override XTypedElement Clone() {
+ return XTypedServices.CloneXTypedElement(this);
+ }
+
+ ///
+ ///
+ /// Regular expression: (names*)
+ ///
+ ///
+ public name() {
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected internal static readonly System.Xml.Linq.XName namesXName = System.Xml.Linq.XName.Get("names", "urn:LinqToXsdCore:Elements:ListType");
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private XSimpleList namesField;
+
+ ///
+ ///
+ /// Occurrence: optional, repeating
+ ///
+ ///
+ /// Regular expression: (names*)
+ ///
+ ///
+ public virtual IList names {
+ get {
+ if ((this.namesField == null)) {
+ this.namesField = new XSimpleList(this, XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String).Datatype, namesXName);
+ }
+ return this.namesField;
+ }
+ set {
+ if ((value == null)) {
+ this.namesField = null;
+ }
+ else {
+ if ((this.namesField == null)) {
+ this.namesField = XSimpleList.Initialize(this, XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String).Datatype, value, namesXName);
+ }
+ else {
+ XTypedServices.SetList(this.namesField, value);
+ }
+ }
+ }
+ }
+
+ private static readonly System.Xml.Linq.XName xName = System.Xml.Linq.XName.Get("name", "urn:LinqToXsdCore:Elements:ListType");
+
+ static name() {
+ BuildElementDictionary();
+ contentModel = new SequenceContentModelEntity(new NamedContentModelEntity(namesXName));
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private static Dictionary localElementDictionary = new Dictionary();
+
+ private static void BuildElementDictionary() {
+ localElementDictionary.Add(namesXName, typeof(string));
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ Dictionary IXMetaData.LocalElementsDictionary {
+ get {
+ return localElementDictionary;
+ }
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private static ContentModelEntity contentModel;
+
+ ContentModelEntity IXMetaData.GetContentModel() {
+ return contentModel;
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ System.Xml.Linq.XName IXMetaData.SchemaName {
+ get {
+ return xName;
+ }
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ SchemaOrigin IXMetaData.TypeOrigin {
+ get {
+ return SchemaOrigin.Element;
+ }
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ ILinqToXsdTypeManager IXMetaData.TypeManager {
+ get {
+ return LinqToXsdTypeManager.Instance;
+ }
+ }
+ }
+
+ public class LinqToXsdTypeManager : ILinqToXsdTypeManager {
+
+ private LinqToXsdTypeManager() {
+ }
+
+ private static Dictionary elementDictionary = new Dictionary();
+
+ private static void BuildElementDictionary() {
+ elementDictionary.Add(System.Xml.Linq.XName.Get("name", "urn:LinqToXsdCore:Elements:ListType"), typeof(global::urn.LinqToXsdCore.Elements.ListType.name));
+ }
+
+ private static XmlSchemaSet schemaSet;
+
+ XmlSchemaSet ILinqToXsdTypeManager.Schemas {
+ get {
+ if ((schemaSet == null)) {
+ XmlSchemaSet tempSet = new XmlSchemaSet();
+ System.Threading.Interlocked.CompareExchange(ref schemaSet, tempSet, null);
+ }
+ return schemaSet;
+ }
+ set {
+ schemaSet = value;
+ }
+ }
+
+ protected internal static void AddSchemas(XmlSchemaSet schemas) {
+ schemas.Add(schemaSet);
+ }
+
+ Dictionary ILinqToXsdTypeManager.GlobalTypeDictionary {
+ get {
+ return XTypedServices.EmptyDictionary;
+ }
+ }
+
+ Dictionary ILinqToXsdTypeManager.GlobalElementDictionary {
+ get {
+ return elementDictionary;
+ }
+ }
+
+ Dictionary ILinqToXsdTypeManager.RootContentTypeMapping {
+ get {
+ return XTypedServices.EmptyTypeMappingDictionary;
+ }
+ }
+
+ static LinqToXsdTypeManager() {
+ BuildElementDictionary();
+ }
+
+ public static System.Type GetRootType() {
+ return elementDictionary[System.Xml.Linq.XName.Get("name", "urn:LinqToXsdCore:Elements:ListType")];
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private static LinqToXsdTypeManager typeManagerSingleton = new LinqToXsdTypeManager();
+
+ public static LinqToXsdTypeManager Instance {
+ get {
+ return typeManagerSingleton;
+ }
+ }
+ }
+
+ public partial class XRootNamespace {
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private XDocument doc;
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private XTypedElement rootObject;
+
+ private XRootNamespace() {
+ }
+
+ public static XRootNamespace Load(string xmlFile) {
+ XRootNamespace root = new XRootNamespace();
+ root.doc = XDocument.Load(xmlFile);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRootNamespace Load(string xmlFile, LoadOptions options) {
+ XRootNamespace root = new XRootNamespace();
+ root.doc = XDocument.Load(xmlFile, options);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRootNamespace Load(TextReader textReader) {
+ XRootNamespace root = new XRootNamespace();
+ root.doc = XDocument.Load(textReader);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRootNamespace Load(TextReader textReader, LoadOptions options) {
+ XRootNamespace root = new XRootNamespace();
+ root.doc = XDocument.Load(textReader, options);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRootNamespace Load(XmlReader xmlReader) {
+ XRootNamespace root = new XRootNamespace();
+ root.doc = XDocument.Load(xmlReader);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRootNamespace Parse(string text) {
+ XRootNamespace root = new XRootNamespace();
+ root.doc = XDocument.Parse(text);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRootNamespace Parse(string text, LoadOptions options) {
+ XRootNamespace root = new XRootNamespace();
+ root.doc = XDocument.Parse(text, options);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public virtual void Save(string fileName) {
+ doc.Save(fileName);
+ }
+
+ public virtual void Save(TextWriter textWriter) {
+ doc.Save(textWriter);
+ }
+
+ public virtual void Save(XmlWriter writer) {
+ doc.Save(writer);
+ }
+
+ public virtual void Save(TextWriter textWriter, SaveOptions options) {
+ doc.Save(textWriter, options);
+ }
+
+ public virtual void Save(string fileName, SaveOptions options) {
+ doc.Save(fileName, options);
+ }
+
+ public virtual XDocument XDocument {
+ get {
+ return doc;
+ }
+ }
+
+ public virtual XTypedElement Root {
+ get {
+ return rootObject;
+ }
+ }
+
+ public XRootNamespace(name root) {
+ this.doc = new XDocument(root.Untyped);
+ this.rootObject = root;
+ }
+
+
+ public name name { get {return rootObject as name; } }
+ }
+
+ public partial class XRoot {
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private XDocument doc;
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private XTypedElement rootObject;
+
+ private XRoot() {
+ }
+
+ public static XRoot Load(string xmlFile) {
+ XRoot root = new XRoot();
+ root.doc = XDocument.Load(xmlFile);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRoot Load(string xmlFile, LoadOptions options) {
+ XRoot root = new XRoot();
+ root.doc = XDocument.Load(xmlFile, options);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRoot Load(TextReader textReader) {
+ XRoot root = new XRoot();
+ root.doc = XDocument.Load(textReader);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRoot Load(TextReader textReader, LoadOptions options) {
+ XRoot root = new XRoot();
+ root.doc = XDocument.Load(textReader, options);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRoot Load(XmlReader xmlReader) {
+ XRoot root = new XRoot();
+ root.doc = XDocument.Load(xmlReader);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRoot Parse(string text) {
+ XRoot root = new XRoot();
+ root.doc = XDocument.Parse(text);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRoot Parse(string text, LoadOptions options) {
+ XRoot root = new XRoot();
+ root.doc = XDocument.Parse(text, options);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public virtual void Save(string fileName) {
+ doc.Save(fileName);
+ }
+
+ public virtual void Save(TextWriter textWriter) {
+ doc.Save(textWriter);
+ }
+
+ public virtual void Save(XmlWriter writer) {
+ doc.Save(writer);
+ }
+
+ public virtual void Save(TextWriter textWriter, SaveOptions options) {
+ doc.Save(textWriter, options);
+ }
+
+ public virtual void Save(string fileName, SaveOptions options) {
+ doc.Save(fileName, options);
+ }
+
+ public virtual XDocument XDocument {
+ get {
+ return doc;
+ }
+ }
+
+ public virtual XTypedElement Root {
+ get {
+ return rootObject;
+ }
+ }
+
+ public XRoot(global::urn.LinqToXsdCore.Elements.ListType.name root) {
+ this.doc = new XDocument(root.Untyped);
+ this.rootObject = root;
+ }
+
+
+ public global::urn.LinqToXsdCore.Elements.ListType.name name { get {return rootObject as global::urn.LinqToXsdCore.Elements.ListType.name; } }
+ }
+}
diff --git a/LinqToXsd.Schemas/XsdFeatureTests/Elements/ElementsListTypeWithDefaults.xsd b/LinqToXsd.Schemas/XsdFeatureTests/Elements/ElementsListTypeWithDefaults.xsd
new file mode 100644
index 00000000..65f9ff5d
--- /dev/null
+++ b/LinqToXsd.Schemas/XsdFeatureTests/Elements/ElementsListTypeWithDefaults.xsd
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/LinqToXsd.Schemas/XsdFeatureTests/Elements/ElementsListTypeWithDefaults.xsd.cs b/LinqToXsd.Schemas/XsdFeatureTests/Elements/ElementsListTypeWithDefaults.xsd.cs
new file mode 100644
index 00000000..95b7e87b
--- /dev/null
+++ b/LinqToXsd.Schemas/XsdFeatureTests/Elements/ElementsListTypeWithDefaults.xsd.cs
@@ -0,0 +1,485 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace urn.LinqToXsdCore.Elements.ListTypeWithDefaults {
+ using System;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.ComponentModel;
+ using System.IO;
+ using System.Linq;
+ using System.Diagnostics;
+ using System.Xml;
+ using System.Xml.Schema;
+ using System.Xml.Linq;
+ using Xml.Schema.Linq;
+
+
+ ///
+ ///
+ /// Regular expression: (names*)
+ ///
+ ///
+ public partial class name : XTypedElement, IXMetaData {
+
+ public void Save(string xmlFile) {
+ XTypedServices.Save(xmlFile, Untyped);
+ }
+
+ public void Save(System.IO.TextWriter tw) {
+ XTypedServices.Save(tw, Untyped);
+ }
+
+ public void Save(System.Xml.XmlWriter xmlWriter) {
+ XTypedServices.Save(xmlWriter, Untyped);
+ }
+
+ public static name Load(string xmlFile) {
+ return XTypedServices.Load(xmlFile);
+ }
+
+ public static name Load(System.IO.TextReader xmlFile) {
+ return XTypedServices.Load(xmlFile);
+ }
+
+ public static name Parse(string xml) {
+ return XTypedServices.Parse(xml);
+ }
+
+ public static explicit operator name(XElement xe) { return XTypedServices.ToXTypedElement(xe,LinqToXsdTypeManager.Instance as ILinqToXsdTypeManager); }
+
+ public override XTypedElement Clone() {
+ return XTypedServices.CloneXTypedElement(this);
+ }
+
+ ///
+ ///
+ /// Regular expression: (names*)
+ ///
+ ///
+ public name() {
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected internal static readonly System.Xml.Linq.XName namesXName = System.Xml.Linq.XName.Get("names", "");
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ internal static IList namesDefaultValue = new string[] {
+ "firstName",
+ "middleName",
+ "lastName"};
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private XSimpleList namesField;
+
+ ///
+ ///
+ /// Occurrence: optional, repeating
+ ///
+ ///
+ /// Regular expression: (names*)
+ ///
+ ///
+ public virtual IList names {
+ get {
+ if ((this.namesField == null)) {
+ this.namesField = new XSimpleList(this, XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String).Datatype, namesXName, namesDefaultValue);
+ }
+ return this.namesField;
+ }
+ set {
+ if ((value == null)) {
+ this.namesField = null;
+ }
+ else {
+ if ((this.namesField == null)) {
+ this.namesField = XSimpleList.Initialize(this, XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String).Datatype, value, namesXName, namesDefaultValue);
+ }
+ else {
+ XTypedServices.SetList(this.namesField, value);
+ }
+ }
+ }
+ }
+
+ private static readonly System.Xml.Linq.XName xName = System.Xml.Linq.XName.Get("name", "urn:LinqToXsdCore:Elements:ListTypeWithDefaults");
+
+ static name() {
+ BuildElementDictionary();
+ contentModel = new SequenceContentModelEntity(new NamedContentModelEntity(namesXName));
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private static Dictionary localElementDictionary = new Dictionary();
+
+ private static void BuildElementDictionary() {
+ localElementDictionary.Add(namesXName, typeof(string));
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ Dictionary IXMetaData.LocalElementsDictionary {
+ get {
+ return localElementDictionary;
+ }
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private static ContentModelEntity contentModel;
+
+ ContentModelEntity IXMetaData.GetContentModel() {
+ return contentModel;
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ System.Xml.Linq.XName IXMetaData.SchemaName {
+ get {
+ return xName;
+ }
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ SchemaOrigin IXMetaData.TypeOrigin {
+ get {
+ return SchemaOrigin.Element;
+ }
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ ILinqToXsdTypeManager IXMetaData.TypeManager {
+ get {
+ return LinqToXsdTypeManager.Instance;
+ }
+ }
+ }
+
+ public class LinqToXsdTypeManager : ILinqToXsdTypeManager {
+
+ private LinqToXsdTypeManager() {
+ }
+
+ private static Dictionary elementDictionary = new Dictionary();
+
+ private static void BuildElementDictionary() {
+ elementDictionary.Add(System.Xml.Linq.XName.Get("name", "urn:LinqToXsdCore:Elements:ListTypeWithDefaults"), typeof(global::urn.LinqToXsdCore.Elements.ListTypeWithDefaults.name));
+ }
+
+ private static XmlSchemaSet schemaSet;
+
+ XmlSchemaSet ILinqToXsdTypeManager.Schemas {
+ get {
+ if ((schemaSet == null)) {
+ XmlSchemaSet tempSet = new XmlSchemaSet();
+ System.Threading.Interlocked.CompareExchange(ref schemaSet, tempSet, null);
+ }
+ return schemaSet;
+ }
+ set {
+ schemaSet = value;
+ }
+ }
+
+ protected internal static void AddSchemas(XmlSchemaSet schemas) {
+ schemas.Add(schemaSet);
+ }
+
+ Dictionary ILinqToXsdTypeManager.GlobalTypeDictionary {
+ get {
+ return XTypedServices.EmptyDictionary;
+ }
+ }
+
+ Dictionary ILinqToXsdTypeManager.GlobalElementDictionary {
+ get {
+ return elementDictionary;
+ }
+ }
+
+ Dictionary ILinqToXsdTypeManager.RootContentTypeMapping {
+ get {
+ return XTypedServices.EmptyTypeMappingDictionary;
+ }
+ }
+
+ static LinqToXsdTypeManager() {
+ BuildElementDictionary();
+ }
+
+ public static System.Type GetRootType() {
+ return elementDictionary[System.Xml.Linq.XName.Get("name", "urn:LinqToXsdCore:Elements:ListTypeWithDefaults")];
+ }
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private static LinqToXsdTypeManager typeManagerSingleton = new LinqToXsdTypeManager();
+
+ public static LinqToXsdTypeManager Instance {
+ get {
+ return typeManagerSingleton;
+ }
+ }
+ }
+
+ public partial class XRootNamespace {
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private XDocument doc;
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private XTypedElement rootObject;
+
+ private XRootNamespace() {
+ }
+
+ public static XRootNamespace Load(string xmlFile) {
+ XRootNamespace root = new XRootNamespace();
+ root.doc = XDocument.Load(xmlFile);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRootNamespace Load(string xmlFile, LoadOptions options) {
+ XRootNamespace root = new XRootNamespace();
+ root.doc = XDocument.Load(xmlFile, options);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRootNamespace Load(TextReader textReader) {
+ XRootNamespace root = new XRootNamespace();
+ root.doc = XDocument.Load(textReader);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRootNamespace Load(TextReader textReader, LoadOptions options) {
+ XRootNamespace root = new XRootNamespace();
+ root.doc = XDocument.Load(textReader, options);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRootNamespace Load(XmlReader xmlReader) {
+ XRootNamespace root = new XRootNamespace();
+ root.doc = XDocument.Load(xmlReader);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRootNamespace Parse(string text) {
+ XRootNamespace root = new XRootNamespace();
+ root.doc = XDocument.Parse(text);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRootNamespace Parse(string text, LoadOptions options) {
+ XRootNamespace root = new XRootNamespace();
+ root.doc = XDocument.Parse(text, options);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public virtual void Save(string fileName) {
+ doc.Save(fileName);
+ }
+
+ public virtual void Save(TextWriter textWriter) {
+ doc.Save(textWriter);
+ }
+
+ public virtual void Save(XmlWriter writer) {
+ doc.Save(writer);
+ }
+
+ public virtual void Save(TextWriter textWriter, SaveOptions options) {
+ doc.Save(textWriter, options);
+ }
+
+ public virtual void Save(string fileName, SaveOptions options) {
+ doc.Save(fileName, options);
+ }
+
+ public virtual XDocument XDocument {
+ get {
+ return doc;
+ }
+ }
+
+ public virtual XTypedElement Root {
+ get {
+ return rootObject;
+ }
+ }
+
+ public XRootNamespace(name root) {
+ this.doc = new XDocument(root.Untyped);
+ this.rootObject = root;
+ }
+
+
+ public name name { get {return rootObject as name; } }
+ }
+
+ public partial class XRoot {
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private XDocument doc;
+
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private XTypedElement rootObject;
+
+ private XRoot() {
+ }
+
+ public static XRoot Load(string xmlFile) {
+ XRoot root = new XRoot();
+ root.doc = XDocument.Load(xmlFile);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRoot Load(string xmlFile, LoadOptions options) {
+ XRoot root = new XRoot();
+ root.doc = XDocument.Load(xmlFile, options);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRoot Load(TextReader textReader) {
+ XRoot root = new XRoot();
+ root.doc = XDocument.Load(textReader);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRoot Load(TextReader textReader, LoadOptions options) {
+ XRoot root = new XRoot();
+ root.doc = XDocument.Load(textReader, options);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRoot Load(XmlReader xmlReader) {
+ XRoot root = new XRoot();
+ root.doc = XDocument.Load(xmlReader);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRoot Parse(string text) {
+ XRoot root = new XRoot();
+ root.doc = XDocument.Parse(text);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public static XRoot Parse(string text, LoadOptions options) {
+ XRoot root = new XRoot();
+ root.doc = XDocument.Parse(text, options);
+ XTypedElement typedRoot = XTypedServices.ToXTypedElement(root.doc.Root, LinqToXsdTypeManager.Instance);
+ if ((typedRoot == null)) {
+ throw new LinqToXsdException("Invalid root element in xml document.");
+ }
+ root.rootObject = typedRoot;
+ return root;
+ }
+
+ public virtual void Save(string fileName) {
+ doc.Save(fileName);
+ }
+
+ public virtual void Save(TextWriter textWriter) {
+ doc.Save(textWriter);
+ }
+
+ public virtual void Save(XmlWriter writer) {
+ doc.Save(writer);
+ }
+
+ public virtual void Save(TextWriter textWriter, SaveOptions options) {
+ doc.Save(textWriter, options);
+ }
+
+ public virtual void Save(string fileName, SaveOptions options) {
+ doc.Save(fileName, options);
+ }
+
+ public virtual XDocument XDocument {
+ get {
+ return doc;
+ }
+ }
+
+ public virtual XTypedElement Root {
+ get {
+ return rootObject;
+ }
+ }
+
+ public XRoot(global::urn.LinqToXsdCore.Elements.ListTypeWithDefaults.name root) {
+ this.doc = new XDocument(root.Untyped);
+ this.rootObject = root;
+ }
+
+
+ public global::urn.LinqToXsdCore.Elements.ListTypeWithDefaults.name name { get {return rootObject as global::urn.LinqToXsdCore.Elements.ListTypeWithDefaults.name; } }
+ }
+}
diff --git a/LinqToXsd/Properties/launchSettings.json b/LinqToXsd/Properties/launchSettings.json
index 79ccacf5..b323bdfa 100644
--- a/LinqToXsd/Properties/launchSettings.json
+++ b/LinqToXsd/Properties/launchSettings.json
@@ -101,6 +101,21 @@
"commandName": "Project",
"commandLineArgs": "gen -a .\\",
"workingDirectory": "..\\GeneratedSchemaLibraries\\XQueryX"
+ },
+ "XQueryX bug": {
+ "commandName": "Project",
+ "commandLineArgs": "gen xPathAxis_bug.xsd -a",
+ "workingDirectory": "..\\GeneratedSchemaLibraries\\XQueryX"
+ },
+ "AttributesFeatures": {
+ "commandName": "Project",
+ "commandLineArgs": "gen -a .\\",
+ "workingDirectory": "..\\LinqToXsd.Schemas\\XsdFeatureTests\\Attributes"
+ },
+ "ElementsFeatures": {
+ "commandName": "Project",
+ "commandLineArgs": "gen -a .\\",
+ "workingDirectory": "..\\LinqToXsd.Schemas\\XsdFeatureTests\\Elements"
}
}
}
\ No newline at end of file
diff --git a/RELEASENOTES.md b/RELEASENOTES.md
index b64700b0..cef320c4 100644
--- a/RELEASENOTES.md
+++ b/RELEASENOTES.md
@@ -1,12 +1,19 @@
# LinqToXsdCore Release Notes
+## Version 3.4.13
+Nuget packages:
+* https://www.nuget.org/packages/LinqToXsdCore/3.4.13
+* https://www.nuget.org/packages/XObjectsCore/3.4.13
+ * [#86](https://github.com/mamift/LinqToXsdCore/pull/86).
+ * Fixes a bug whereby the XObjects API (`XSimpleList`) did not include the requisite overload for allowing default values for elements of simple types.
+
## Version 3.4.12
Nuget packages:
* https://www.nuget.org/packages/LinqToXsdCore/3.4.12
* https://www.nuget.org/packages/XObjectsCore/3.4.12
* [#79](https://github.com/mamift/LinqToXsdCore/pull/79).
* The LinqToXsd CLI tool now runs on .NET 7,8,9 and 10. Still supports .NET core 3.1, 5 and 6 and .NET Framework 4.7.2
- * Fixes a bug occurring in the CLI tool when a directory with trailling quotes (' or ") is provided for the `gen -a path\` command.
+ * Fixes a bug occurring in the CLI tool when a directory with trailling quotes (' or ") is provided for the `gen -a path\` command.
## Version 3.4.10
Nuget packages:
@@ -36,7 +43,7 @@ Nuget packages:
Nuget packages:
* https://www.nuget.org/packages/LinqToXsdCore/3.4.6
* https://www.nuget.org/packages/XObjectsCore/3.4.6
- * Fixed a bug where Timezone info was lost (conversions from DateTimeOffset to DateTime no longer occur).
+ * Fixed a bug where Timezone info was lost (conversions from DateTimeOffset to DateTime no longer occur).
## Version 3.4.5
Nuget packages:
@@ -124,7 +131,7 @@ Nuget packages:
* Fixes an error that occurs when attempting to pass null to a property that had validation logic in the property setter (see [GitHub PR28](https://github.com/mamift/LinqToXsdCore/pull/28)).
* https://www.nuget.org/packages/XObjectsCodeGen/3.2.0
* The number of `XName` instantiations in generated code is now greatly reduced (see [GitHub PR23](https://github.com/mamift/LinqToXsdCore/pull/23)).
- * Now includes an option for null-annotating generated code (see [GitHub PR29](https://github.com/mamift/LinqToXsdCore/pull/29)).
+ * Now includes an option for null-annotating generated code (see [GitHub PR29](https://github.com/mamift/LinqToXsdCore/pull/29)).
* Enums in generated code are now properly generated as CLR value types (see [GitHub 21](https://github.com/mamift/LinqToXsdCore/pull/21)).
* Updated to fix ambiguous types where an element is a base type and a derrived type is used (see [GitHub 16](https://github.com/mamift/LinqToXsdCore/pull/16)).
@@ -158,48 +165,48 @@ Nuget packages:
Nuget packages:
* https://www.nuget.org/packages/LinqToXsdCore/3.0.0.11
* https://www.nuget.org/packages/XObjectsCore/3.0.0.10
- * Avoid type name conflicts in generated code.
+ * Avoid type name conflicts in generated code.
* Do not prefix an identifier with the '@' character when not needed.
## XObjectsCore 3.0.0.9
-Nuget packages:
+Nuget packages:
* https://www.nuget.org/packages/XObjectsCore/3.0.0.9
Added `XTypedElementEqualityComparer` and `XTypedElementDeepEqualityComparer` classes that implement `IEqualityComparer{T}` for the `XTypedElement` class.
## LinqToXsdCore 3.0.0.10 and XObjectsCore 3.0.0.8
-Nuget packages:
+Nuget packages:
* https://www.nuget.org/packages/XObjectsCore/3.0.0.8
* https://www.nuget.org/packages/LinqToXsdCore/3.0.0.10
Modified the behaviour of retrieving the value of an attribute, when the schema type is anyAtomicType (which is the default for attributes when no type is given). The value literal is now returned as a string (pre-existing behaviour would throw an exception saying that anyAtomicType is not a supported conversion to the CLR type 'string').
## XObjectsCore 3.0.0.7
-Nuget packages:
+Nuget packages:
* https://www.nuget.org/packages/XObjectsCore/3.0.0.7
* Fixed a regression bug with previous release.
## LinqToXsdCore 3.0.0.9 and XObjectsCore 3.0.0.6
-Nuget packages:
+Nuget packages:
* https://www.nuget.org/packages/XObjectsCore/3.0.0.6
* Fixed an issue when performing an explicit type conversion from XElement to its XTyped-equivalent when the XTyped-equivalent type was an internal class.
* https://www.nuget.org/packages/LinqToXsdCore/3.0.0.9
- * Generating a new config file no longers includes the Xml.Schema.Linq schema namespace mapping. Also generating a new config file will generate a default namespace mapping when the XSD does not target a namespace.
+ * Generating a new config file no longers includes the Xml.Schema.Linq schema namespace mapping. Also generating a new config file will generate a default namespace mapping when the XSD does not target a namespace.
## LinqToXsdCore 3.0.0.8
-Nuget packages:
+Nuget packages:
* https://www.nuget.org/packages/LinqToXsdCore/3.0.0.8
* Implemented saving merged output from multiple XSD files when generating a config file (using 'config -e' switch) using a folder as a source.
## XObjectsCore 3.0.0.5 and LinqToXsdCore 3.0.0.7
-Nuget packages:
+Nuget packages:
* https://www.nuget.org/packages/XObjectsCore/3.0.0.5
* Reversed a change made that removed the virtual keyword on properties on generated types. Added a test for it.
* https://www.nuget.org/packages/LinqToXsdCore/3.0.0.7
* Dropped emitting errors to a custom handler. Was outputting red console text needlessly.
## XObjectsCore 3.0.0.4 and LinqToXsdCore 3.0.0.6
-Nuget packages:
+Nuget packages:
* https://www.nuget.org/packages/XObjectsCore/3.0.0.4
* https://www.nuget.org/packages/LinqToXsdCore/3.0.0.6
diff --git a/Version.props b/Version.props
index 98abc018..e9c69536 100644
--- a/Version.props
+++ b/Version.props
@@ -1,6 +1,6 @@
- 3.4.12
+ 3.4.13
$(VersionSuffix)
$(Version)-$(VersionSuffix)
diff --git a/XObjectsCode/Src/ClrPropertyInfo.cs b/XObjectsCode/Src/ClrPropertyInfo.cs
index d2cf76ac..a9aad52b 100644
--- a/XObjectsCode/Src/ClrPropertyInfo.cs
+++ b/XObjectsCode/Src/ClrPropertyInfo.cs
@@ -1269,7 +1269,7 @@ protected void CreateFixedDefaultValue(CodeTypeDeclaration typeDecl)
fixedOrDefaultField.Attributes =
(fixedOrDefaultField.Attributes & ~MemberAttributes.AccessMask & ~MemberAttributes.ScopeMask)
- | MemberAttributes.Private
+ | MemberAttributes.FamilyAndAssembly
| MemberAttributes.Static;
fixedOrDefaultField.InitExpression =
diff --git a/XObjectsCore/API/XList.cs b/XObjectsCore/API/XList.cs
index cb8632d7..e46dee99 100644
--- a/XObjectsCore/API/XList.cs
+++ b/XObjectsCore/API/XList.cs
@@ -301,5 +301,19 @@ protected void InitializeFrom(IEnumerable values)
Clear();
foreach (T value in values) Add(value);
}
+
+#nullable enable
+ protected void InitializeFrom(IEnumerable? values, IList? defaultValues)
+ {
+ if (values != null)
+ {
+ Clear();
+ foreach (T value in values) Add(value);
+ }
+ else if (defaultValues != null)
+ {
+ foreach (T value in defaultValues) Add(value);
+ }
+ }
}
}
\ No newline at end of file
diff --git a/XObjectsCore/API/XSimpleList.cs b/XObjectsCore/API/XSimpleList.cs
index 24f43501..83957210 100644
--- a/XObjectsCore/API/XSimpleList.cs
+++ b/XObjectsCore/API/XSimpleList.cs
@@ -8,6 +8,9 @@ namespace Xml.Schema.Linq
public class XSimpleList : XList
{
XmlSchemaDatatype schemaDatatype;
+#nullable enable
+ public IList? DefaultValues { get; private set; }
+#nullable disable
public XSimpleList(XTypedElement container, XmlSchemaDatatype dataType, XName itemXName) : base(container,
itemXName)
@@ -15,6 +18,15 @@ public XSimpleList(XTypedElement container, XmlSchemaDatatype dataType, XName it
this.schemaDatatype = dataType;
}
+ public XSimpleList(XTypedElement container, XmlSchemaDatatype dataType, XName itemXName, IList defaultValues) : this(container, dataType, itemXName)
+ {
+ this.DefaultValues = defaultValues;
+ if (defaultValues != null && !EnumerateElements().Any())
+ {
+ InitializeFrom(defaultValues, defaultValues);
+ }
+ }
+
protected override void AddImpl(T value)
{
container.SetElement(itemXName, value, true, schemaDatatype);
@@ -79,5 +91,17 @@ public static XSimpleList Initialize(
simpleList.InitializeFrom(values);
return simpleList;
}
+
+#nullable enable
+ public static XSimpleList Initialize(
+ XTypedElement container,
+ XmlSchemaDatatype dataType,
+ IEnumerable? values,
+ XName itemXName, IList defaultValues)
+ {
+ XSimpleList simpleList = new(container, dataType, itemXName, defaultValues);
+ simpleList.InitializeFrom(values, defaultValues);
+ return simpleList;
+ }
}
}
\ No newline at end of file
diff --git a/XObjectsCore/Extensions/GeneralExtensionMethods.cs b/XObjectsCore/Extensions/GeneralExtensionMethods.cs
index b6c4c0f7..d2be2baa 100644
--- a/XObjectsCore/Extensions/GeneralExtensionMethods.cs
+++ b/XObjectsCore/Extensions/GeneralExtensionMethods.cs
@@ -64,7 +64,13 @@ public static XmlSchemaSet ToXmlSchemaSet(this XmlReader reader, XmlResolver res
};
newXmlSet.Add(null, reader);
- newXmlSet.Compile();
+ try {
+ newXmlSet.Compile();
+ } catch (XmlSchemaException ex) when
+ (ex.Message.Contains("The 'http://www.w3.org/XML/1998/namespace:base' attribute is not declared.")) {
+
+ throw new LinqToXsdException($"Error compiling schema: {reader.BaseURI}", ex);
+ }
return newXmlSet;
}
diff --git a/XObjectsTests/XsdFeatureTests/AttributeFeatureTests.cs b/XObjectsTests/XsdFeatureTests/AttributeFeatureTests.cs
new file mode 100644
index 00000000..32ba3a33
--- /dev/null
+++ b/XObjectsTests/XsdFeatureTests/AttributeFeatureTests.cs
@@ -0,0 +1,85 @@
+using System.Collections.Generic;
+using NUnit.Framework;
+
+namespace Xml.Schema.Linq.Tests.XsdFeatureTests;
+
+public class AttributeFeatureTests
+{
+ [Test]
+ public void AttributeFeatureTestOtherNamesWithCustomValues()
+ {
+ var xml = """
+
+
+ """;
+
+ var person = urn.LinqToXsdCore.ListTypeWithDefaults.person.Parse(xml);
+
+ Assert.NotNull(person.otherNames);
+
+ Assert.True(person.otherNames.Contains("mono"));
+ Assert.True(person.otherNames.Contains("duo"));
+ Assert.True(person.otherNames.Contains("trio"));
+ }
+
+ [Test]
+ public void AttributeFeatureTestMilestoneYearsWithDefaultValues()
+ {
+ var xml = """
+
+
+ """;
+
+ var person = urn.LinqToXsdCore.ListTypeWithDefaults.person.Parse(xml);
+
+ Assert.NotNull(person.milestoneYears);
+ Assert.IsNotEmpty(person.milestoneYears);
+ }
+
+ [Test]
+ public void AttributeFeatureTestOtherNamesWithEmptyAttrValue()
+ {
+ var xml = """
+
+
+ """;
+
+ var person = urn.LinqToXsdCore.ListTypeWithDefaults.person.Parse(xml);
+
+ Assert.NotNull(person.otherNames);
+ Assert.True(person.otherNames.Count == 0);
+ }
+
+ [Test]
+ public void AttributeFeatureTestTagsDefaults()
+ {
+ var xml = """
+
+
+ """;
+
+ var person = urn.LinqToXsdCore.ListTypeWithDefaults.person.Parse(xml);
+
+ Assert.NotNull(person.tags);
+ Assert.IsNotEmpty(person.tags);
+ }
+
+ [Test]
+ public void AttributeFeatureTestTagsDefaultsThenSetCustomValues()
+ {
+ var xml = """
+
+
+ """;
+
+ var person = urn.LinqToXsdCore.ListTypeWithDefaults.person.Parse(xml);
+
+ Assert.NotNull(person.tags);
+ Assert.IsNotEmpty(person.tags);
+
+ person.tags = new List() { "male", "adult" };
+
+ Assert.IsNotEmpty(person.tags);
+ Assert.True(person.tags.Count == 2);
+ }
+}
\ No newline at end of file
diff --git a/XObjectsTests/XsdFeatureTests/ElementFeatureTests.cs b/XObjectsTests/XsdFeatureTests/ElementFeatureTests.cs
new file mode 100644
index 00000000..a36eeb00
--- /dev/null
+++ b/XObjectsTests/XsdFeatureTests/ElementFeatureTests.cs
@@ -0,0 +1,48 @@
+using System.Xml.Linq;
+using NUnit.Framework;
+
+namespace Xml.Schema.Linq.Tests.XsdFeatureTests;
+
+public class ElementFeatureTests
+{
+ [Test]
+ public void TestDefaultElementsValues()
+ {
+ var xml = $"""
+
+ """;
+
+ var name = urn.LinqToXsdCore.Elements.ListTypeWithDefaults.name.Parse(xml);
+
+ Assert.NotNull(name);
+ Assert.NotNull(name.names);
+ Assert.True(name.names.Count == 3);
+ }
+
+
+ [Test]
+ public void TestDefaultElementsValuesThenSetCustomValues()
+ {
+ var xml = $"""
+
+ """;
+
+ var name = urn.LinqToXsdCore.Elements.ListTypeWithDefaults.name.Parse(xml);
+
+ Assert.NotNull(name);
+ Assert.NotNull(name.names);
+ Assert.True(name.names.Count == 3);
+
+ name.names = ["alex", "anton"];
+
+ var xmlElement = name.Untyped;
+
+ Assert.IsNotEmpty(xmlElement.Descendants());
+
+ XElement firstChild = (XElement)xmlElement.FirstNode;
+ XElement lastChild = (XElement)xmlElement.LastNode;
+
+ Assert.True(firstChild!.Value == "alex");
+ Assert.True(lastChild!.Value == "anton");
+ }
+}
\ No newline at end of file