/// <summary>
        /// Builds an in-memory action model from the specified XML model and the specified set of actions.
        /// </summary>
        /// <remarks>
        /// The actions will be ordered according to the XML model.  Any actions that are not a part of the
        /// XML model will be added to the memory model and inserted into the XML model based on a 'group hint'.
        /// The XML model is automatically persisted, and new models that have never before been persisted
        /// will be added.
        /// </remarks>
        /// <param name="namespace">A namespace to qualify the site.</param>
        /// <param name="site">The site.</param>
        /// <param name="actions">The set of actions to include. This set should be prefiltered on <paramref name="site"/>.</param>
        /// <returns>An <see cref="ActionModelNode"/> representing the root of the action model.</returns>
        public ActionModelRoot BuildAndSynchronize(string @namespace, string site, IActionSet actions)
        {
            // do one time initialization
            if (_actionModelXmlDoc == null)
            {
                Initialize();
            }

            string actionModelID = string.Format("{0}:{1}", @namespace, site);

            IDictionary <string, IAction> actionMap = BuildActionMap(actions);

            XmlElement      xmlActionModel = Synchronize(actionModelID, actionMap);
            ActionModelRoot modelRoot      = Build(site, xmlActionModel, actionMap);

            return(modelRoot);
        }
        /// <summary>
        /// Builds an in-memory action model from the specified XML model and the specified set of actions.
        /// The actions will be ordered according to the XML model.
        /// </summary>
        /// <param name="site">the action model site</param>
        /// <param name="xmlActionModel">an XML "action-model" node</param>
        /// <param name="actions">the set of actions that the model should contain</param>
        /// <returns>an <see cref="ActionModelNode"/> representing the root of the action model</returns>
        private static ActionModelRoot Build(string site, XmlElement xmlActionModel, IDictionary <string, IAction> actions)
        {
            ActionModelRoot   model       = new ActionModelRoot(site);
            List <XmlElement> actionNodes = GetActionNodeList(xmlActionModel);

            // process xml model, inserting actions in order
            for (int i = 0; i < actionNodes.Count; i++)
            {
                XmlElement xmlAction = actionNodes[i];
                if (xmlAction.Name == "action")
                {
                    string actionID = xmlAction.GetAttribute("id");

                    //This accounts for "former action IDs" because the same action will be in the map for each ID (current and former).
                    if (actions.ContainsKey(actionID))
                    {
                        IAction action = actions[actionID];

                        // update the action path from the xml
                        ProcessXmlAction(xmlAction, action);

                        // insert the action into the model
                        model.InsertAction(action);
                    }
                }
                else if (xmlAction.Name == "separator")
                {
                    Path separatorPath = ProcessSeparator(actionNodes, i, actions);

                    // insert separator into model
                    if (separatorPath != null)
                    {
                        model.InsertSeparator(separatorPath);
                    }
                }
            }

            return(model);
        }