Getting an error in my xml schema editor code.

Hi,
I have an xsd file like this.
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="generic" 
elementFormDefault="qualified" targetNamespace="generic"> 
   <xsd:element name="bookstore" type="bookstoreType"/> 
   <xsd:complexType name="bookstoreType"> 
       <xsd:sequence maxOccurs="unbounded"> 
           <xsd:element name="book" type="bookType"/> 
       </xsd:sequence> 
   </xsd:complexType> 
   <xsd:complexType name="bookType"> 
       <xsd:sequence> 
           <xsd:element name="title" type="xsd:string"/> 
           <xsd:element name="author" type="authorName"/> 
           <xsd:element name="price" type="xsd:decimal"/> 
       </xsd:sequence> 
       <xsd:attribute name="genre" type="xsd:string"/> 
   </xsd:complexType> 
   <xsd:complexType name="authorName"> 
       <xsd:sequence> 
           <xsd:element name="first-name" type="xsd:string"/> 
           <xsd:element name="last-name" type="xsd:string"/> 
       </xsd:sequence> 
   </xsd:complexType> 
</xsd:schema> 

And my xml schema editor code is as follows
	private void mnuAddAnnotation_Click(object sender, System.EventArgs e)
		{
			XmlSchemaAnnotation annot=new XmlSchemaAnnotation();
			TreeNode newNode=CreateNode("--annotation--");

			// if adding at the schema root level...
			if (newNode.Parent==tvSchema.Nodes[0])
			{
				AddToCollection(schema.Items, annot, newNode, TreeViewImages.Annotation);
			}
			else
			{
				// otherwise, get the object as an XmlSchemaAnnotated type
				XmlSchemaAnnotated obj=newNode.Parent.Tag as XmlSchemaAnnotated;
				if (obj != null)
				{
					// if it exists, add the annotation
					obj.Annotation=annot;
					newNode.Tag=annot;
					newNode.ImageIndex=(int)TreeViewImages.Annotation;
					newNode.SelectedImageIndex=(int)TreeViewImages.Annotation;
					CompileSchema();
				}
				else
				{
					// otherwise, tell the user annotation cannot be added to this type.
					newNode.Parent.Nodes.Remove(newNode);
					MessageBox.Show("Cannot create an annotation for this item.");
				}
			}
		}

		private void mnuAddDocumentation_Click(object sender, System.EventArgs e)
		{
			bool success=false;
			XmlSchemaAnnotation annot=tvSchema.SelectedNode.Tag as XmlSchemaAnnotation;
			// if the parent node is an annotation type...
			if (annot != null)
			{
				// ...then add the documentation type
				TreeNode newNode=CreateNode("--documentation--");
				XmlSchemaDocumentation doc=new XmlSchemaDocumentation();
				doc.Markup=TextToNodeArray("Documentation");
				annot.Items.Add(doc);
				newNode.Tag=doc;
				newNode.ImageIndex=(int)TreeViewImages.Annotation;
				newNode.SelectedImageIndex=(int)TreeViewImages.Annotation;
				CompileSchema();
				success=true;
			}
			if (!success)
			{
				// otherwise create the annotation type first
				mnuAddAnnotation_Click(sender, e);
				annot=tvSchema.SelectedNode.Tag as XmlSchemaAnnotation;
				// if successful in adding the annotation type, add the documentation 
type now
				if (annot != null)
				{
					mnuAddDocumentation_Click(sender, e);
				}
			}
		}

		private void mnuAddAppInfo_Click(object sender, System.EventArgs e)
		{
			bool success=false;
			XmlSchemaAnnotation annot=tvSchema.SelectedNode.Tag as XmlSchemaAnnotation;
			// if the parent node is an annotation type...
			if (annot != null)
			{
				// ...then add the AppInfo type
				TreeNode newNode=CreateNode("--app info--");
				XmlSchemaAppInfo doc=new XmlSchemaAppInfo();
				doc.Markup=TextToNodeArray("Application Information");
				annot.Items.Add(doc);
				newNode.Tag=doc;
				newNode.ImageIndex=(int)TreeViewImages.Annotation;
				newNode.SelectedImageIndex=(int)TreeViewImages.Annotation;
				CompileSchema();
				success=true;
			}
			if (!success)
			{
				// otherwise create the annotation type first
				mnuAddAnnotation_Click(sender, e);
				annot=tvSchema.SelectedNode.Tag as XmlSchemaAnnotation;
				// if successful in creating the annotation type, add the AppInfo type now
				if (annot != null)
				{
					mnuAddAppInfo_Click(sender, e);
				}
			}
		}

		private void mnuAddAttribute_Click(object sender, System.EventArgs e)
		{
			TreeNode newNode=CreateNode("Attribute");
			XmlSchemaAttribute attrib=new XmlSchemaAttribute();
			attrib.Name="Attribute";
			attrib.SchemaTypeName=new XmlQualifiedName("string", 
"http://www.w3.org/2001/XMLSchema");

			// root node?
			if (newNode.Parent==tvSchema.Nodes[0])
			{
				// add to root of schema.  An global attribute cannot reference a global 
type
				AddToCollection(schema.Items, attrib, newNode, TreeViewImages.Attribute);
				cbGlobalTypes.Items.Add(new GlobalElementType(attrib.Name, attrib));
				cbGlobalTypes.Enabled=false;
				cbSimpleTypes.SelectedItem=-1;
				cbSimpleTypes.Enabled=true;
				cbSimpleTypes.SelectedItem="string";
			}
			else
			{
				// an attribute can only be added to a complex type
				XmlSchemaComplexType ct=newNode.Parent.Tag as XmlSchemaComplexType;
				if (ct != null)
				{
					// and can reference a global attribute, so enable the global combobox
					AddToCollection(ct.Attributes, attrib, newNode, 
TreeViewImages.Attribute);
					cbGlobalTypes.SelectedItem=-1;
					cbGlobalTypes.Enabled=true;
					cbSimpleTypes.SelectedItem="string";
					cbSimpleTypes.Enabled=true;
				}
				else
				{
					newNode.Parent.Nodes.Remove(newNode);
					MessageBox.Show("Cannot create an attribute for this item.");
				}
			}
		}
		private void mnuAddElement_Click(object sender, System.EventArgs e)
		{
			TreeNode newNode=CreateNode("Element");
			XmlSchemaElement element=new XmlSchemaElement();
			element.Name="Element";
			element.SchemaTypeName=new XmlQualifiedName("string", 
"http://www.w3.org/2001/XMLSchema");

			// root node?
			if (newNode.Parent==tvSchema.Nodes[0])
			{
				// add to root of schema.  A global element can reference another global 
type
				AddToCollection(schema.Items, element, newNode, TreeViewImages.Element);
				cbGlobalTypes.Items.Add(new GlobalElementType(element.Name, element));
				cbGlobalTypes.Enabled=true;
				cbSimpleTypes.SelectedItem=-1;
				cbSimpleTypes.Enabled=true;
				cbSimpleTypes.SelectedItem="string";
			}
			else
			{
				// otherwise, an element must be part of a complex type
				bool ret=AddToComplexType(newNode.Parent.Tag, element, newNode, 
TreeViewImages.Element);
				if (!ret)
				{
					// not successful
					newNode.Parent.Nodes.Remove(newNode);
					MessageBox.Show("Cannot add an element to this item.");
				}
				else
				{
					// successful
					cbGlobalTypes.SelectedItem=-1;
					cbGlobalTypes.Enabled=true;
					cbSimpleTypes.SelectedItem="string";
					cbSimpleTypes.Enabled=true;
				}
			}
		}
		
		private void mnuAddSimpleType_Click(object sender, System.EventArgs e)
		{
			TreeNode newNode=CreateNode("SimpleType");

			XmlSchemaSimpleType simpleType=new XmlSchemaSimpleType();
			simpleType.Name="SimpleType";
			XmlSchemaSimpleTypeRestriction restriction=new 
XmlSchemaSimpleTypeRestriction();
			restriction.BaseTypeName=new XmlQualifiedName("string", 
"http://www.w3.org/2001/XMLSchema");
			simpleType.Content=restriction;

			// root node?
			if (newNode.Parent==tvSchema.Nodes[0])
			{
				// add to root of schema.  A global simple type cannot reference another 
global
				AddToCollection(schema.Items, simpleType, newNode, 
TreeViewImages.SimpleType);
				cbGlobalTypes.Items.Add(new GlobalElementType(simpleType.Name, 
simpleType));
				cbGlobalTypes.Enabled=false;
				cbSimpleTypes.SelectedItem=-1;
				cbSimpleTypes.Enabled=true;
				cbSimpleTypes.SelectedItem="string";
			}
			else
			{
				// if not a root node, then it must be created as an element of simple 
type...
				XmlSchemaElement el=new XmlSchemaElement();
				el.Name="SimpleType";
				el.SchemaType=simpleType;
				simpleType.Name=null;
				// ...as a subnode to a complex type
				bool ret=AddToComplexType(newNode.Parent.Tag, el, newNode, 
TreeViewImages.SimpleType);
				if (!ret)
				{
					// failure
					newNode.Parent.Nodes.Remove(newNode);
					MessageBox.Show("Cannot add a simple type to this item.");
				}
				else
				{
					// success.  Can reference a global simple type
					cbGlobalTypes.SelectedItem=-1;
					cbGlobalTypes.Enabled=true;
					cbSimpleTypes.SelectedItem="string";
					cbSimpleTypes.Enabled=true;
				}
			}
		}
		
		private void mnuAddComplexType_Click(object sender, System.EventArgs e)
		{
			TreeNode newNode=CreateNode("ComplexType");

			XmlSchemaComplexType complexType=new XmlSchemaComplexType();
			XmlSchemaSequence sequence=new XmlSchemaSequence();
			complexType.Particle=sequence;
			complexType.Name="ComplexType";

			// root node?
			if (newNode.Parent==tvSchema.Nodes[0])
			{
				// add to root.  A complex type has no type reference information.
				AddToCollection(schema.Items, complexType, newNode, 
TreeViewImages.ComplexType);
				cbGlobalTypes.Items.Add(new GlobalElementType(complexType.Name, 
complexType));
				cbSimpleTypes.SelectedItem=-1;
				cbGlobalTypes.SelectedItem=-1;
				cbSimpleTypes.Enabled=false;
				cbGlobalTypes.Enabled=false;
			}
			else
			{
				// if not at root, create an element of complex type...
				XmlSchemaElement el=new XmlSchemaElement();
				el.Name="ComplexType";
				el.SchemaType=complexType;
				complexType.Name=null;
				// ...that is added as a subnode to a complex type.
				bool ret=AddToComplexType(newNode.Parent.Tag, el, newNode, 
TreeViewImages.ComplexType);
				if (!ret)
				{
					// failure
					newNode.Parent.Nodes.Remove(newNode);
					MessageBox.Show("Cannot add a complex type to this item.");
				}
				else
				{
					// success.  No type is referenced.
					cbSimpleTypes.SelectedItem=-1;
					cbGlobalTypes.SelectedItem=-1;
					cbSimpleTypes.Enabled=false;
					cbGlobalTypes.Enabled=false;
				}
			}
		}
				
		
		}
		
		private void SchemaValidationHandler(object sender, ValidationEventArgs 
args) 
		{
			Console.WriteLine(args.Message);
			edSchemaErrors.Text+=args.Message+"\r\n";
		}
		
		private void PreEventLabelChanged(object sender, NodeLabelEditEventArgs e)
		{
			prevLabel=tvSchema.SelectedNode.Text;
			if ( (e.Node.Tag is XmlSchemaFacet) ||
				(e.Node.Tag is XmlSchemaAnnotation) || 
				(e.Node.Tag is XmlSchemaDocumentation) ||
				(e.Node.Tag is XmlSchemaAppInfo) )
			{
				e.Node.EndEdit(false);
			}
		}

		private void EventLabelChanged(object sender, NodeLabelEditEventArgs e)
		{
			// if a node is selected...
			if (e.Node != null)
			{
				// and a label has been changed... (e.Label==null if ESC key pressed)
				if (e.Label != null)
				{
					// then change the name of the type in the schema
					UpdateTypeAndName(null, e.Label, null);

					// if this is a root node...
					if (e.Node.Parent == tvSchema.Nodes[0])
					{
						// ...then also change the name in the global list
						// (this is not case sensitive!)
						int idx=cbGlobalTypes.FindStringExact(prevLabel);
						if (idx != -1)
						{
							cbGlobalTypes.Items[idx]=new GlobalElementType(e.Label, 
((GlobalElementType)cbGlobalTypes.Items[idx]).type);
						}
					}
				}
			}
		}

		private void EventTreeViewKeyUp(object sender, KeyEventArgs e)
		{
			e.Handled=false;
			// F2
			if (e.KeyCode==Keys.F2)
			{
				if (tvSchema.SelectedNode != tvSchema.Nodes[0])
				{
					tvSchema.SelectedNode.BeginEdit();
					e.Handled=true;
				}
			}
			// Ctrl+A
			else if ( (e.KeyCode==Keys.A) && (e.Modifiers==Keys.Control) )
			{
				e.Handled=true;
				tvcmSchema.Show(this, tvSchema.Location+new Size(50, 50));
			}
			// Ctrl+T
			else if ( (e.KeyCode==Keys.T) && (e.Modifiers==Keys.Control) )
			{
				e.Handled=true;
				tvSchema.SelectedNode=tvSchema.Nodes[0];
			}
			// Ctrl+P
			else if ( (e.KeyCode==Keys.P) && (e.Modifiers==Keys.Control) )
			{
				e.Handled=true;
                
                TreeNode node = tvSchema.SelectedNode.Parent;
				if (node != null)
				{
					tvSchema.SelectedNode=node;
				}
			}
		}
		
		private void EventSchemaTextBoxLostFocus(object sender, EventArgs e)
		{
			mnuCompile_Click(sender, e);
		}
		
		private void EventMouseDown(object sender, MouseEventArgs e)
		{
			TreeNode tn=tvSchema.GetNodeAt(e.X, e.Y);
			if (tn != null)
			{
				tvSchema.SelectedNode=tn;
			}
		}
		
		private void tvSchema_AfterSelect(object sender, 
System.Windows.Forms.TreeViewEventArgs e)
		{
			XmlSchemaObject obj=e.Node.Tag as XmlSchemaObject;
			// if this is a schema object...
			if (obj != null)
			{
				// find the corresponding line in the XSD source and highlight it
				if ( (obj.LineNumber != 0) && (obj.LineNumber < edSchema.Lines.Length) )
				{
					int length=0;
					for (int i=0; i<obj.LineNumber-1; i++)
					{
						// get the length of the line including CRLF
						length+=edSchema.Lines[i].Length+2;
					}
					// highlight the line
					edSchema.Select(length, edSchema.Lines[obj.LineNumber-1].Length);
				}

				// Update simple and global type combo boxes.
				// Get the name of the element type so that we can find it in the simple 
or global type list
				XmlQualifiedName name=null;		// assume failure
				if (obj is XmlSchemaAttribute)
				{
					// this is easy.
					name=((XmlSchemaAttribute)obj).SchemaTypeName;
				}
				else if (obj is XmlSchemaSimpleType)
				{
					// if it's a simple type, get the restriction type, if it exists
					XmlSchemaSimpleTypeRestriction 
restriction=((XmlSchemaSimpleType)obj).Content as 
XmlSchemaSimpleTypeRestriction;
					if (restriction != null)
					{
						name=restriction.BaseTypeName;
					}
				}
				else if (obj is XmlSchemaElement)
				{
					// if it's an element, determine if it's a simple type subnode of a 
complex type...
					// and then get the restriction type, if it exists
					XmlSchemaElement el=obj as XmlSchemaElement;
					if (el.SchemaType is XmlSchemaSimpleType)
					{
						XmlSchemaSimpleType st=el.SchemaType as XmlSchemaSimpleType;
						XmlSchemaSimpleTypeRestriction rest=st.Content as 
XmlSchemaSimpleTypeRestriction;
						if (rest != null)
						{
							name=rest.BaseTypeName;
						}
					}
					else
					{
						// otherwise get the element name
						name=el.SchemaTypeName;

						// if the name is null, then there must be a reference instead
						if (name.Name=="")
						{
							name=el.RefName;
						}
					}
				}

				// select the name from either the simple type list or the global 
element type list
				if (name != null)
				{
					// see if the name exists in the simple type list
					int idx=cbSimpleTypes.FindStringExact(name.Name);
					cbSimpleTypes.SelectedIndex=idx;
					cbSimpleTypes.Enabled=true;

					// see if the name exists in the complex type list
					idx=cbGlobalTypes.FindStringExact(name.Name);
					cbGlobalTypes.SelectedIndex=idx;
					cbGlobalTypes.Enabled=true;
				}
				else
				{
					// if there is no name, then disable the comboboxes
					cbSimpleTypes.SelectedIndex=-1;
					cbGlobalTypes.SelectedIndex=-1;
					cbSimpleTypes.Enabled=false;
					cbGlobalTypes.Enabled=false;
				}
			}
			else
			{
				// if this isn't a schema object, then disable the comboboxes
				cbSimpleTypes.SelectedIndex=-1;
				cbGlobalTypes.SelectedIndex=-1;
				cbSimpleTypes.Enabled=false;
				cbGlobalTypes.Enabled=false;
			}
		}
		
		private void cbSimpleTypes_SelectedIndexChanged(object sender, 
System.EventArgs e)
		{
			if (cbSimpleTypes.SelectedIndex != -1)
			{
				UpdateTypeAndName(cbSimpleTypes.SelectedItem.ToString(), null, 
"http://www.w3.org/2001/XMLSchema");
				cbGlobalTypes.SelectedIndex=-1;
			}
		}
		
		private void cbGlobalTypes_SelectedIndexChanged(object sender, 
System.EventArgs e)
		{
			if (cbGlobalTypes.SelectedIndex != -1)
			{
				UpdateTypeAndName(cbGlobalTypes.SelectedItem.ToString(), null, null);
				cbSimpleTypes.SelectedIndex=-1;
			}
		}
		
		private void CreateRootNode()
		{
			tvSchema.Nodes.Clear();
			TreeNode rootNode=new TreeNode("Schema:");
			tvSchema.Nodes.Add(rootNode);
			rootNode.ImageIndex=(int)TreeViewImages.Schema;
			rootNode.SelectedImageIndex=(int)TreeViewImages.Schema;
			cbGlobalTypes.Items.Clear();
		}
	
		private void CompileSchema()
		{
			edSchemaErrors.Text="";
			schema.Compile(new ValidationEventHandler(SchemaValidationHandler));
			StringWriter sw=new StringWriter();
			schema.Write(sw);
			edSchema.Text=sw.ToString();

		}
		
		private TreeNode CreateNode(string name)
		{
			TreeNode tn=tvSchema.SelectedNode;
			TreeNode newNode=new TreeNode(name);
			tn.Nodes.Add(newNode);
			tn.Expand();
			tvSchema.SelectedNode=newNode;
			newNode.BeginEdit();
			return newNode;
		}
		
		void AddToCollection(XmlSchemaObjectCollection coll, XmlSchemaObject obj, 
TreeNode node, TreeViewImages imgIdx)
		{
			coll.Add(obj);
			node.Tag=obj;
			node.ImageIndex=(int)imgIdx;
			node.SelectedImageIndex=(int)imgIdx;
			CompileSchema();
		}
		
		private XmlSchemaComplexType ChangeElementToComplexType(XmlSchemaElement 
el, TreeNode tn)
		{
			// if the element is currently a reference, we need to remove the reference
			// and set the name to something, which in this case is the old ref name.
			if (el.RefName != null)
			{
				el.Name=el.RefName.Name;
				el.RefName=null;
			}
			// creat the complex type.
			XmlSchemaComplexType ct=new XmlSchemaComplexType();
			el.SchemaType=ct;
			// a complex type cannot have a type name
			el.SchemaTypeName=null;
			// create the sequence
			XmlSchemaSequence sequence=new XmlSchemaSequence();
			ct.Particle=sequence;

			// update the image indices
			tn.ImageIndex=(int)TreeViewImages.ComplexType;
			tn.SelectedImageIndex=(int)TreeViewImages.ComplexType;

			return ct;
		}
		
		private bool AddToComplexType(object obj, XmlSchemaObject item, TreeNode 
newNode, TreeViewImages imgIdx)
		{
			bool success=true;
			XmlSchemaElement el=obj as XmlSchemaElement;
			XmlSchemaComplexType complexType=obj as XmlSchemaComplexType;

			// is it an element...
			if (el != null)
			{
				// of complex type (so we know it's a local complex type, not a global 
one!)
				XmlSchemaComplexType ct=el.SchemaType as XmlSchemaComplexType;
				if (ct != null)
				{
					// does it have a sequence?
					XmlSchemaSequence seq=ct.Particle as XmlSchemaSequence;
					if (seq != null)
					{
						// yes--add it to the sequence collection
						AddToCollection(seq.Items, item, newNode, imgIdx);
					}
					else
					{
						// no--we can't add it.
						MessageBox.Show("Complex type is missing sequence!");
						success=false;
					}
				}
				else
				{
					// change the basic element to a complex type by adding a sequence and 
then
					// add the sub-element
					ct=ChangeElementToComplexType(el, newNode.Parent);
					AddToCollection(((XmlSchemaSequence)ct.Particle).Items, item, newNode, 
imgIdx);
				}
			}
			// or is it a global complex type...
			else	if (complexType != null)
			{
				XmlSchemaSequence seq=complexType.Particle as XmlSchemaSequence;
				// which should have a sequence!
				if (seq != null)
				{
					// yes--add it to the collection
					AddToCollection(seq.Items, item, newNode, imgIdx);
				}
				else
				{
					// no--we can't add it.
					MessageBox.Show("Complex type is missing sequence!");
					success=false;
				}
			}
			else
			{
				// failure--current node is not an element and not a complex type
				success=false;
			}
			return success;
		}
		
		private void UpdateTypeAndName(string typeName, string name, string 
nameSpace)
		{
			// Is the type referenced by the tree node an XmlSchemaObject?
            
            
            XmlSchemaObject obj = tvSchema.SelectedNode.Tag as 
XmlSchemaObject;
			if (obj != null)
			{
				// is it an attribute?
				if (obj is XmlSchemaAttribute)
				{
					XmlSchemaAttribute attrib=obj as XmlSchemaAttribute;
					// if we're changing the name:
					if (name != null)
					{
						attrib.Name=name;
						CompileSchema();
					}
					// if we're changing the type:
					if (typeName != null)
					{
						// if the name refers to a global attribute, then use ref instead of 
type
						int idx=cbGlobalTypes.FindStringExact(typeName);
						GlobalElementType glet=null;
						if (idx != -1)
						{
							glet=cbGlobalTypes.Items[idx] as GlobalElementType;
						}
						// if a global exists of this type...
						if ( (glet != null) && (glet.type is XmlSchemaAttribute) )
						{
							// then get rid of the type name and use a ref instead
							attrib.SchemaTypeName=null;
							attrib.RefName=new XmlQualifiedName(typeName, nameSpace);
							// can't have a name
							attrib.Name=null;
						}
						else
						{
							// otherwise, use a type name and get rid of the ref
							attrib.SchemaTypeName=new XmlQualifiedName(typeName, nameSpace);
							attrib.RefName=null;
							if (attrib.Name==null)
							{
								// if changing from ref to type, we need some sort of default name
								attrib.Name=tvSchema.SelectedNode.Text;
							}
						}
						CompileSchema();
						// update the tree node name
						tvSchema.SelectedNode.Text=attrib.QualifiedName.Name;
					}
				}
				// is it an element?
				else if (obj is XmlSchemaElement)
				{
					XmlSchemaElement el=obj as XmlSchemaElement;
					// if we're changing the name:
					if (name != null)
					{
						el.Name=name;
						CompileSchema();
					}

					// if we're changing the type:
					if (typeName != null)
					{
						if (el.SchemaType is XmlSchemaSimpleType)
						{
							XmlSchemaSimpleType st=el.SchemaType as XmlSchemaSimpleType;
							XmlSchemaSimpleTypeRestriction rest=st.Content as 
XmlSchemaSimpleTypeRestriction;
							if (rest != null)
							{
								rest.BaseTypeName=new XmlQualifiedName(typeName, nameSpace);
								CompileSchema();
							}
						}
						else
						{
							// if the name refers to a global element, then use ref instead of type
							// Same deal as for changing the element type name.
							// Since the SchemaTypeName and RefName are not part of any base 
class shared
							// between the SchemaXmlAttribute and SchemaXmlElement, we need 
separate code.
							int idx=cbGlobalTypes.FindStringExact(typeName);
							GlobalElementType glet=null;
							if (idx != -1)
							{
								glet=cbGlobalTypes.Items[idx] as GlobalElementType;
							}
							if ( (glet != null) && (glet.type is XmlSchemaElement) )
							{
								el.SchemaTypeName=null;
								el.RefName=new XmlQualifiedName(typeName, nameSpace);
								el.Name=null;
							}
							else
							{
								el.SchemaTypeName=new XmlQualifiedName(typeName, nameSpace);
								el.RefName=null;
								if (el.Name==null)
								{
									el.Name=tvSchema.SelectedNode.Text;
								}
							}
							CompileSchema();
							tvSchema.SelectedNode.Text=el.QualifiedName.Name;
						}
					}
				}
				// is it a simple type?
				else if (obj is XmlSchemaSimpleType)
				{
					XmlSchemaSimpleType st=obj as XmlSchemaSimpleType;
					// if we're changing the name:
					if (name != null)
					{
						st.Name=name;
						CompileSchema();
					}

					// if we're changing the type name:
					if (typeName != null)
					{
						// this must be done in the Restriction object
						XmlSchemaSimpleTypeRestriction restriction=st.Content as 
XmlSchemaSimpleTypeRestriction;
						if (restriction != null)
						{
							restriction.BaseTypeName=new XmlQualifiedName(typeName, nameSpace);
							CompileSchema();
							cbGlobalTypes.SelectedIndex=-1;
						}
					}
				}
				// is it a complex type?
				else if (obj is XmlSchemaComplexType)
				{
					// if we're changing the name:
					if (name != null)
					{
						((XmlSchemaComplexType)obj).Name=name;
						CompileSchema();
					}
					// there is no such thing as changing the type of a complex type
				}
			}
		}
		
		bool AddFacet(XmlSchemaFacet facet, string val, TreeViewImages imgIdx)
		{
			// get the simple type.
			XmlSchemaSimpleType st=tvSchema.SelectedNode.Tag as XmlSchemaSimpleType;

			// assume failure
			XmlSchemaSimpleTypeRestriction rs=null;
			bool success=false;

			// if the simple type exists, get the restriction type
			if (st != null)
			{
				rs=st.Content as XmlSchemaSimpleTypeRestriction;
			}

			// if the restriction type exists...
			if (rs != null)
			{
				// create the node and add it to the facet collection
				TreeNode newNode=CreateNode(facet.ToString());
				facet.Value=val;
				rs.Facets.Add(facet);
				CompileSchema();
				success=true;
			}
			return success;
		}
		
		public static XmlNode[] TextToNodeArray(string text) 
		{
			XmlDocument doc = new XmlDocument();
			return new XmlNode[1] {doc.CreateTextNode(text)};
		}
		
		private void DecodeSchema(XmlSchema schema, TreeNode node)
		{
			try
			{
				DecodeSchema2(schema, node);
			}
			catch(Exception err)
			{
				edSchemaErrors.Text=err.ToString();
			}
		}

		
		
	}
}
When i open my xml file using this editor and click on any element in the 
tree view, the following error is displayed.
Type 'bookstoreType' is not declared.
Type 'authorName' is not declared.
Type 'bookType' is not declared.
Actually i got this code from code project. Can anyone help me in fixing 
this error.

Thanks.






0
Priya7318 (23)
11/14/2007 5:28:00 AM
dotnet.xml 7266 articles. 0 followers. Follow

0 Replies
965 Views

Similar Articles

[PageSpeed] 35

Reply:

Similar Artilces:

error: symbol "feof" not found
Any ideas why I would get this error in the debug window when asking for feof(fp) error: symbol "feof" not foun I know it's old school, but I think it should work. It compiles just fine, but crashes at runtime on the while(!feof(fp)) statement. Then in the debugger window I ask for feof(fp) and get that error next to it Solved: Stray pointer caused this. ...

Run-time error '2147217900 (80040e14)
I have a tree list control I want to populate with Categories based on a Client. The client number is input into a text box & then the update event populates the tree based on the selection. I get a syntax error when it tries to open the recordset based on the SQL. Two tables are invloved (Client & Categories; in a 1-to-many relationship on pID field). Here'e the code: Dim rstCategory As New ADODB.recordset, rstComponent As New ADODB.recordset Dim rstSubComponent As New ADODB.recordset Dim tvwTree As Object Dim nodX As Node Dim I As Integer Dim blnAllRecs As B...

Function to encapsulate code block into a constant?
I writing more and more apps where the application generates an Excel spreadsheet and pushes various VBA routines into it. I seem to be spending too many man hours on the details (placement of vblf's, "_", quotes, and such when creating constants. I'm thinking I should be able to develop the routine in an Excel spreadsheet, test it... and then feed the routine to a function that returns a monster constant like the one below - even checking for excessive continuations and breaking it up into multiple constants as needed. For example, this: --------------------------------...

Send/Receive doesn't get Exchange 2000 mail
Outlook 2002 Send/Receive does not get mail from the Exchange server as expected. If you open a previous message the mail is properly retrieved from the Exchange 2000 server. Using Outlook 2003 Send/Receive works as expected. It's a problem with your NAT router and UDP: http://support.microsoft.com/default.aspx?scid=kb;en-us;Q305572 -- "Gene" <gglenn@precisionimages.com> wrote in message news:0a9601c35dbc$0075a290$a401280a@phx.gbl... > Outlook 2002 Send/Receive does not get mail from the > Exchange server as expected. If you open a previous > message the ...

Action PostURL Error
Hi, I have a web service for integration, but when I test it sent the follow error "<description>Error in action posturl.</description><details>Failed to connect the url http://localhost/customwebservices" Thanks in advance Victor ...

Error Messages That Seem Incorrect
I have the following two messages appearing: "Error. An error has occurred. For more information, contact your system administrator" and "An error occurred while trying to send the e-mail. Try again." The first happens when closing activities or qualifying leads to accounts and contacts. The second when sending CRM e-mail from Outlook. In both cases the activity had actually been completed successfuly. eg customer received the e-mail, new account/contact created or activity showing in history. My users are repeating the process because of the error message and w...

Outlook 2003, Relaying denied error, Windows XP
I seem to have a problem when Outlook 2003 is first opened that it will not allow an email with an attachment to be sent. A 'Relaying denied' error message comes up. If I send an email without attachment this works OK and triggers the Norton anit virus software to check email before sent. After this the problem seems to go away i.e. I can now send attachments. Any ideas on why this error occurrs ? Is there a setup feature I've missed ? Have you set up authentication to your outgoing server ("More Settings..." on your account page, go to the "Outgoing Server&qu...

Error when using RMS EDC Settle function
Hello. We run RMSsp2, and use PCCharge PaymntSvr EDC software/First Data processor. PCCharge settles fine, if trying from within RMS, receive error on: 1st attempt: "Invalid Merchant" box error appears. 2nd and subsequent attempts "Invalid Destination Zip" box error appears. Erro occurs withing few seconds of settle attempt, settle progress doesnt go beyond 1/10 of progress meter and this error pops up. Any ideas? Our EDC config is fine and all batches and items are ok in PCCharge. thanks luke ...

Complie Error
Hi: When I open Excel 2003 I get a Microsoft Vusual Basic error message: "Compile Error in hidden module:AutoExecNew". My excel program runs fine after I close that message. But when I try to close Excel, I get a different message: ""Compile Error in hidden module: DistMon" I could not find any help on Micorsoft's Knowledgebase. Could any please help solving this problem? Thanks Mohan Hi have a look at http://support.microsoft.com/default.aspx?scid=kb;EN-US;q307410 -- Regards Frank Kabel Frankfurt, Germany mohan wrote: > Hi: > > When I open Ex...

getting sql report 2005 web service to work
The error I am getting in sql reporting service 2005 is 'The selected report is not ready for viewing. The report is still being rendered or a report snapshot is not available. (rsReportNotReady)'. There are lots of answers on the web and I have tried alot of them including obtaining extract space. The error I am getting is: " The report is still being rendered or a report snapshot is not available. (rsReportNotReady)". I am using using windows-authentication to the datasource, and I am wondering if I am not setting up the pass-through properly on t...

Hyperlink Error
I have a hyperlink set-up for a netwrok file. It works fine, but when the file is copied the hyperlin chages to the folder that the file has been copied to. original link - L:\folder\folder\file Changes to - C:\file How can I get it to keep the original link? Justin ...

getting a single line from a file
I was wondering if someone could tell me how to read a single line from a text file. I tried using getline, but my MFC program does not recognize the getline function. Nor does it recognize <string> or <string.h> or using namespace std. So is there another function that I can use in MFC? Roger Take a look at the CStdioFile MFC class. -- Cheers Check Abdoul [VC++ MVP] ----------------------------------- "R.H." <roger.huggins@intermec.com> wrote in message news:e98o6IMmDHA.1764@tk2msftngp13.phx.gbl... > I was wondering if someone could tell me ho...

Outlook 2007 CRM error
I get an error when starting Outlook that I have no CRM functionality, event ID 5897 shows up in the app logs with an autentication error message 0x8007002. Any ideas on what I should be looking for or how to fix this? ...

'error PRJ0019: A tool returned an error code from "Performing registration" Project Name
This is a multi-part message in MIME format. ------=_NextPart_000_0006_01C80055.07F02D20 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable Hi, all I wrote a COM project with VS2003, when I compile this project = ,finally I get the error like 'error PRJ0019: A tool returned an error = code from "Performing registration" Project Name. Any helpful ideas would be highly appreciated! -ja ------=_NextPart_000_0006_01C80055.07F02D20 Content-Type: text/html; charset="gb2312" Content-Transfer-Encoding: quoted-printable...

SDK Q: "taxes distribution(s) does not equal the actual amount" error when posting
I am trying to have our orders processing system properly populate the Great Plains tables so we can TRANSFER our orders to invoices (at which point third-party tools perform so WBS re-distribution) and then POST them to GL. Thanks to rrs1977@gmail.com for your previous help. With that, I've been able to get the system to create orders and batches which Dynamics allows our users to open and Transfer to invoice (and properly triggering our third-party redistribution utilities). However, when they try to post the invoices to GL, an error shows up indicating "taxes distribution(s...

CRM integration with GP: BizTalk errors
I've completed the integration, but I'm getting 2 Biztalk errors. Any help or direction appreciated: APPLICATION ERROR: Event Type: Error Event Source: Application Error Event Category: (100) Event ID: 1000 Date: 8/24/2005 Time: 4:51:50 AM User: N/A Computer: NJBTS02 Description: Faulting application MSCIS.exe, version 3.0.2023.0, faulting module ntdll.dll, version 5.2.3790.1830, fault address 0x000396d0. For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp. Data: 0000: 41 70 70 6c 69 63 61 74 Applicat 0008: 69 6f 6e 20 46 61 69 6c ...

Error after attempting to send message OTL6
each time i attempt to send a message in outlook6 the send and receive bar will proceed right to the end and immediately post following: unknown error protocal:SMTP, port:0, Secure(SSL):No Error Number OX800C0131 The new window: DIRECTDB.DLL HAS COMMITTED ERROR MSIMN WILL CLOSE NOW PROPERTIES OF DIRECTDB.DLL IS VERSION 6.0.2800.1106 HELPPPPPPPPPPPPPPPPPPPPPP!!!!! waynedog_7@passport.com <waynedog@prodigy.net> wrote: > each time i attempt to send a message in outlook6 Ask in an Outlook Express newsgroup. -- Brian Tillman ...

POP3 error
why does this keep appearing when I try to send pictures? Please post the entire error message (copy / paste). Is it only on picture emails - not on text emails? <maddogn@live.com> wrote in message news:u$x4XpEfKHA.2160@TK2MSFTNGP02.phx.gbl... > why does this keep appearing when I try to send pictures? Probably because you don't have your email account set up properly. It would have been helpful if you had included the complete error = message. Are you trying to set up your Live.com account in Windows Mail? If so, use the settings given here: http://mailcall...

Why Out of memory error when trying to create a thread?
I'm using MS Visual C++ .NET, Windows XP, and 1GB RAM. Why could be the reason why I get an error message saying Out of memory when running the following code CClientThread* pThread = (CClientThread*) AfxBeginThread(RUNTIME_CLASS(CClientThread), THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED); My application does only have this additional thread. Joachim wrote: > I'm using MS Visual C++ .NET, Windows XP, and 1GB RAM. > Why could be the reason why I get an error message saying > > Out of memory > > when running the following code > > CClientThread* pThread =...

get sql server schema to xml?
Hello, How can I get table/column schema of a sql server database? i want to convert the entire schema into an xml file. thanks in advance. You can use a DataReader's GetSchemaTable method "suzy" <suzy@spam.com> wrote in message news:ckNyb.372$nL5.173@news-binary.blueyonder.co.uk... > Hello, > > How can I get table/column schema of a sql server database? i want to > convert the entire schema into an xml file. > > thanks in advance. > > Oops, sorry for not posting the link... you can do it with the Connection Object as well... here's a ...

Messages in sent folder automatically gets deleted periodically on IMAP account
Windows Mail v6.0.6000.16386 using IMAP on Windows Vista Home Premium Every once a while, my email messages in my "sent" folder for some reason gets automatically deleted. Is there a way I can prevent this from taking place? Other than accessing the account via POP3 instead of IMAP, no. snomazushi wrote: > Windows Mail v6.0.6000.16386 using IMAP on Windows Vista Home Premium > > Every once a while, my email messages in my "sent" folder for some reason > gets automatically deleted. Is there a way I can prevent this from taking > place? ...

CrmCheckPrivilege failed error
We are using CRM 4.0, which was upgraded from 3.0. I just added new security roles into an existing business unit. Then I added new users and associated them with the new security roles. When the user tries to log in, I get this error: SecLib::CrmCheckPrivilege failed. Returned hr = -2147220960 on UserId: 9b85226b-0254-dd11-8024-001b78d05d74 and PrivilegeId: 588725dd-c878-41c5a4c3-5efc93cd3ffd If I take a user that existed in CRM before the upgrade and associate them to one of the new security roles, everything works ok. Does anyone have any idea how to fix this? I found knowledgebas...

How to get the associated application for a document
Hi all.. I am populating a CMainFrame menu with some document files. I want each menu item to display the icon for the associated application. For example, if the document is .DOC, Microsoft Word icon has to be displayed near to the menu item. I tried a lot of things, but without success... The last thing I tried was this: SHFILEINFO fi; CImageList imgShell; imgShell.Attach((HIMAGELIST)SHGetFileInfo(sFileExt, 0, &fi, sizeof(SHFILEINFO), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX | SHGFI_SMALLICON)); int iImgNdx = m_docImgList.Add(imgShell.ExtractIcon(fi....

OWA 404 error if subject ends in a full stop
I have just applied SP1 to our Exchange2003 server and yet OWA still suffers from the bug that displays a 404 error if you try and read an email where the subject line ends with a full stop. I was hopping this bug would be fixed in SP1. It's not a bug, and it's not a recent development. This is URLScan working as designed - protecting your IIS (which Exchange runs on) from CodeRed-like hacks. You can remove URLScan, but that is NOT my recommendation. I suggest you just educate your users as to the fact that this is the way it is. Tell them it's like the Internet, it's beyo...

Hpw to serialize boolean to 0/1 into XML?
I can deserialize my Xml that contains 0/1 to bool, but when I again serialize it, value is true/false. Is there some way to force boolean value to be serialized as 0 and 1, not true or false? Thanks. Rita wrote: > I can deserialize my Xml that contains 0/1 to bool, but when I again > serialize it, value is true/false. Is there some way to force boolean value > to be serialized as 0 and 1, not true or false? I suspect it is not possible, looking at http://www.w3.org/TR/xmlschema-2/#boolean the possible values are 0, 1, true, false but the canonical values are only tr...