public static void BindRoot( XmlDocument doc, Mappings model )
		{
			XmlNode hmNode = doc.DocumentElement;
			XmlAttribute schemaNode = hmNode.Attributes[ "schema" ];
			model.SchemaName = ( schemaNode == null ) ? null : schemaNode.Value;
			XmlAttribute dcNode = hmNode.Attributes[ "default-cascade" ];
			model.DefaultCascade = ( dcNode == null ) ? "none" : dcNode.Value;
			XmlAttribute daNode = hmNode.Attributes[ "default-access" ];
			model.DefaultAccess = ( daNode == null ) ? "property" : daNode.Value;
			XmlAttribute aiNode = hmNode.Attributes[ "auto-import" ];
			model.IsAutoImport = ( aiNode == null ) ? true : "true".Equals( aiNode.Value );
			XmlAttribute nsNode = hmNode.Attributes[ "namespace" ];
			model.DefaultNamespace = ( nsNode == null ) ? null : nsNode.Value;
			XmlAttribute assemblyNode = hmNode.Attributes[ "assembly" ];
			model.DefaultAssembly = ( assemblyNode == null ) ? null : assemblyNode.Value;

			nsmgr = new XmlNamespaceManager( doc.NameTable );
			// note that the prefix has absolutely nothing to do with what the user
			// selects as their prefix in the document.  It is the prefix we use to 
			// build the XPath and the nsmgr takes care of translating our prefix into
			// the user defined prefix...
			nsmgr.AddNamespace( nsPrefix, Configuration.MappingSchemaXMLNS );

			foreach( XmlNode n in hmNode.SelectNodes( nsClass, nsmgr ) )
			{
				RootClass rootclass = new RootClass();
				Binder.BindRootClass( n, rootclass, model );
				model.AddClass( rootclass );
			}

			foreach( XmlNode n in hmNode.SelectNodes( nsSubclass, nsmgr ) )
			{
				PersistentClass superModel = GetSuperclass( model, n );
				HandleSubclass( superModel, model, n );
			}

			foreach( XmlNode n in hmNode.SelectNodes( nsJoinedSubclass, nsmgr ) )
			{
				PersistentClass superModel = GetSuperclass( model, n );
				HandleJoinedSubclass( superModel, model, n );
			}

			foreach( XmlNode n in hmNode.SelectNodes( nsQuery, nsmgr ) )
			{
				string qname = n.Attributes[ "name" ].Value;
				string query = n.InnerText;
				log.Debug( "Named query: " + qname + " -> " + query );
				model.AddQuery( qname, query );
			}

			foreach( XmlNode n in hmNode.SelectNodes( nsSqlQuery, nsmgr ) )
			{
				string qname = n.Attributes[ "name" ].Value;
				NamedSQLQuery namedQuery = new NamedSQLQuery( n.InnerText );

				foreach( XmlNode returns in n.SelectNodes( nsReturn, nsmgr ) )
				{
					string alias = returns.Attributes[ "alias" ].Value;
					System.Type clazz = ClassForNameChecked(
						returns.Attributes[ "class" ].Value, model,
						"class not found: {0} for alias " + alias );
					namedQuery.AddAliasedClass( alias, clazz );
				}

				foreach( XmlNode table in n.SelectNodes( nsSynchronize, nsmgr ) )
				{
					namedQuery.AddSynchronizedTable( table.Attributes[ "table" ].Value );
				}

				log.Debug( "Named sql query: " + qname + " -> " + namedQuery.QueryString );
				model.AddSQLQuery( qname, namedQuery );
			}

			foreach( XmlNode n in hmNode.SelectNodes( nsImport, nsmgr ) )
			{
				string className = FullClassName( n.Attributes[ "class" ].Value, model );
				XmlAttribute renameNode = n.Attributes[ "rename" ];
				string rename = ( renameNode == null ) ? StringHelper.GetClassname( className ) : renameNode.Value;
				log.Debug( "Import: " + rename + " -> " + className );
				model.AddImport( className, rename );
			}
		}
		/// <summary>
		/// 
		/// </summary>
		/// <param name="name"></param>
		/// <param name="query"></param>
		public void AddSQLQuery( string name, NamedSQLQuery query )
		{
			CheckQueryExists( name );
			sqlqueries[ name ] = query;
		}