public void save()
        {
            // Save the conditions in docx
            string ser = conditions.Serialize();

            log.Info(ser);
            CustomXmlUtilities.replaceXmlDoc(model.conditionsPart, ser);
        }
        public void save()
        {
            // Save it in docx
            string result = xpaths.Serialize();

            log.Info(result);
            CustomXmlUtilities.replaceXmlDoc(model.xpathsPart, result);
        }
        /// <summary>
        /// Add the condition to the conditions part.
        /// </summary>
        /// <param name="model"></param>
        /// <param name="cxpId"></param>
        /// <param name="strXPath"></param>
        /// <param name="prefixMappings"></param>
        public condition setup(xpathsXpath xpath)
        {
            condition result = null;

            //////////////////////////
            // Second, create and add the condition

            // If the Condition is already defined in our Condition part, don't do it again.
            // Also need this for ID generation.


            Dictionary <string, string> conditionsById = new Dictionary <string, string>();

            foreach (condition xx in conditions.condition)
            {
                conditionsById.Add(xx.id, "");
                if (xx.Item is xpathref)
                {
                    xpathref ex = (xpathref)xx.Item;

                    if (ex.id.Equals(xpath.id))
                    {
                        result = xx;
                        log.Info("This Condition is already setup, with ID: " + xx.id);
                        break;
                    }
                }
            }



            if (result == null) // not already defined
            {
                // Add the new condition
                result = new condition();
                //result.id = IdGenerator.generateIdForXPath(conditionsById, null, null, xpath.dataBinding.xpath);
                result.id = IdHelper.GenerateShortID(5);

                xpathref xpathref = new xpathref();
                xpathref.id = xpath.id;

                result.Item = xpathref;

                conditions.condition.Add(result);

                // Save the conditions in docx
                string ser = conditions.Serialize();
                log.Info(ser);
                CustomXmlUtilities.replaceXmlDoc(model.conditionsPart, ser);
            }

            // Set this
            conditionId = result.id;

            log.Debug("Condition written!");

            return(result);
        }
        public void updateQuestionsPart(question q)
        {
            questionnaire questionnaire = new questionnaire();

            questionnaire.Deserialize(questionsPart.XML, out questionnaire);

            questionnaire.questions.Add(q);

            // Save it in docx
            string result = questionnaire.Serialize();

            log.Info(result);
            CustomXmlUtilities.replaceXmlDoc(questionsPart, result);
        }
        /// <summary>
        /// Stuff required to create XPath element
        /// (except for ID, which this method generates)
        /// </summary>
        /// <param name="xpath"></param>
        /// <param name="storeItemID"></param>
        /// <param name="prefixMappings"></param>
        /// <param name="questionID"></param>
        public static xpathsXpath updateXPathsPart(
            Office.CustomXMLPart xpathsPart,
            string xpath,
            string xpathId,
            string storeItemID, string prefixMappings,
            string questionID)
        {
            //Office.CustomXMLPart xpathsPart = ((WedTaskPane)this.Parent.Parent.Parent).xpathsPart;

            xpaths xpaths = new xpaths();

            xpaths.Deserialize(xpathsPart.XML, out xpaths);

            xpathsXpath item = new xpathsXpath();

            item.id = xpathId; //System.Guid.NewGuid().ToString();

            if (!string.IsNullOrWhiteSpace(questionID))
            {
                item.questionID = questionID;
            }

            xpathsXpathDataBinding db = new xpathsXpathDataBinding();

            db.xpath       = xpath;
            db.storeItemID = storeItemID;
            if (!string.IsNullOrWhiteSpace(prefixMappings))
            {
                db.prefixMappings = prefixMappings;
            }
            item.dataBinding = db;

            xpaths.xpath.Add(item);

            // Save it in docx
            string result = xpaths.Serialize();

            log.Info(result);
            CustomXmlUtilities.replaceXmlDoc(xpathsPart, result);

            return(item);
        }