private void NotifyIfAnyNonOptionalAttributeIsMissing(
            Document document,
            Element elementPrototype,
            Element newElement)
        {
            const string MissingNonOptionalAttributeErrorMessage =
                "Value missing for: attribute {0}, word id {1}, sentence id: {2}, document id: {3}";

            foreach (var wordPrototypeAttribute in elementPrototype.Attributes)
            {
                if (!wordPrototypeAttribute.IsOptional)
                {
                    var wordAttribute =
                        newElement.Attributes.SingleOrDefault(atr => atr.Name.Equals(wordPrototypeAttribute.Name));
                    if ((wordAttribute == null) || string.IsNullOrEmpty(wordAttribute.Value))
                    {
                        if ((document == null) || !document.Sentences.Any())
                        {
                            continue;
                        }

                        var lastSentence = document.Sentences.Last();

                        var newWordId = newElement.GetAttributeByName("id");
                        var sentenceId = lastSentence.GetAttributeByName("id");
                        var documentId = document.GetAttributeByName("id");

                        EventAggregator.GetEvent<ValidationExceptionEvent>()
                            .Publish(
                                string.Format(
                                    MissingNonOptionalAttributeErrorMessage,
                                    wordPrototypeAttribute.Name,
                                    newWordId,
                                    sentenceId,
                                    documentId));
                    }
                }
            }
        }
        private void AddAttributesToElement(ConfigurationPair item, Element elementToModify)
        {
            foreach (var itemAttributes in item.Attributes)
            {
                foreach (var itemAttribute in itemAttributes)
                {
                    var attrib0 = elementToModify.Attributes.FirstOrDefault(a => a.Name == itemAttribute.Key);

                    if (attrib0 != null)
                    {
                        attrib0.Value = itemAttribute.Value;
                    }
                    else
                    {
                        elementToModify.Attributes.Add(
                            new Attribute
                            {
                                Name = itemAttribute.Key,
                                DisplayName = itemAttribute.Key,
                                Value = itemAttribute.Value,
                                IsOptional = true,
                                IsEditable = true
                            });
                    }
                }
            }
        }