示例#1
0
 private void ReadNotes(XmlNode node, TBase e)
 {
     // REVIEW (SRMc): Should we detect multiple occurrences of the same
     // type of note?  See ReadExtensibleElementDetails() for how field
     // elements are handled in this regard.
     foreach (XmlNode noteNode in node.SelectNodes("note"))
     {
         string        noteType = Utilities.GetOptionalAttributeString(noteNode, "type");
         LiftMultiText noteText = ReadMultiText(noteNode);
         _merger.MergeInNote(e, noteType, noteText, noteNode.OuterXml);
     }
 }
示例#2
0
        private void ReadFormNodes(XmlNodeList nodesWithForms, LiftMultiText text)
        {
            foreach (XmlNode formNode in nodesWithForms)
            {
                try
                {
                    string  lang     = Utilities.GetStringAttribute(formNode, _wsAttributeLabel);
                    XmlNode textNode = formNode.SelectSingleNode("text");
                    if (textNode != null)
                    {
                        // Add the separator if we need it.
                        if (textNode.InnerText.Length > 0)
                        {
                            text.AddOrAppend(lang, "", "; ");
                        }
                        foreach (XmlNode node in textNode.ChildNodes)
                        {
                            if (node.Name == "span")
                            {
                                text.AddSpan(lang,
                                             Utilities.GetOptionalAttributeString(node, "lang"),
                                             Utilities.GetOptionalAttributeString(node, "class"),
                                             Utilities.GetOptionalAttributeString(node, "href"),
                                             node.InnerText.Length);
                            }
                            text.AddOrAppend(lang, node.InnerText, "");
                        }
                    }

                    foreach (XmlNode annotationNode in formNode.SelectNodes("annotation"))
                    {
                        Annotation annotation = GetAnnotation(annotationNode);
                        annotation.LanguageHint = lang;
                        text.Annotations.Add(annotation);
                    }
                }
                catch (Exception e)
                {
                    // not a fatal error
                    NotifyFormatError(e);
                }
            }
        }
示例#3
0
        private void ReadEtymology(XmlNode node, TEntry entry)
        {
//            if (_limitedMerger != null && _limitedMerger.DoesPreferXmlForEtymology)
//            {
//                _limitedMerger.MergeInEtymology(entry, node.OuterXml);
//                return;
//            }

            string        source    = Utilities.GetOptionalAttributeString(node, "source");
            string        type      = Utilities.GetOptionalAttributeString(node, "type");
            LiftMultiText form      = LocateAndReadMultiText(node, null);
            LiftMultiText gloss     = LocateAndReadOneElementPerFormData(node, "gloss");
            TBase         etymology = _merger.MergeInEtymology(entry, source, type, form, gloss, node.OuterXml);

            if (etymology != null)
            {
                ReadExtensibleElementDetails(etymology, node);
            }
        }
示例#4
0
        private void FinishReadingSense(XmlNode node, TSense sense)
        {
            if (sense != null)//not been pruned
            {
                ReadGrammi(sense, node);
                LiftMultiText gloss = LocateAndReadOneElementPerFormData(node, "gloss");
                if (!gloss.IsEmpty)
                {
                    _merger.MergeInGloss(sense, gloss);
                }
                LiftMultiText def = LocateAndReadMultiText(node, "definition");
                if (!def.IsEmpty)
                {
                    _merger.MergeInDefinition(sense, def);
                }

                ReadNotes(node, sense);

                foreach (XmlNode n in node.SelectNodes("example"))
                {
                    ReadExample(n, sense);
                }
                foreach (XmlNode n in node.SelectNodes("relation"))
                {
                    ReadRelation(n, sense);
                }
                foreach (XmlNode n in node.SelectNodes("illustration"))
                {
                    ReadPicture(n, sense);
                }
                foreach (XmlNode n in node.SelectNodes("reversal"))
                {
                    ReadReversal(n, sense);
                }
                foreach (XmlNode n in node.SelectNodes("subsense"))
                {
                    ReadSubsense(n, sense);
                }
                ReadExtensibleElementDetails(sense, node);
            }
            // return sense;
        }
示例#5
0
        private void ReadPronunciation(XmlNode node, TEntry entry)
        {
//            if (_limitedMerger != null && _limitedMerger.DoesPreferXmlForPhonetic)
//            {
//                _limitedMerger.MergeInPronunciation(entry, node.OuterXml);
//                return;
//            }

            LiftMultiText contents      = ReadMultiText(node);
            TBase         pronunciation = _merger.MergeInPronunciation(entry, contents, node.OuterXml);

            if (pronunciation != null)
            {
                foreach (XmlNode n in node.SelectNodes("media"))
                {
                    ReadMedia(n, pronunciation);
                }
                ReadExtensibleElementDetails(pronunciation, node);
            }
        }
示例#6
0
        private TBase ReadParentReversal(string type, XmlNode node)
        {
            XmlNodeList nodelist = node.SelectNodes("main");

            if (nodelist.Count > 1)
            {
                NotifyFormatError(new LiftFormatException(String.Format("Only one <main> element is allowed inside a <main> element:\r\n{0}", node.OuterXml)));
            }
            TBase parent = null;

            if (nodelist.Count == 1)
            {
                parent = ReadParentReversal(type, nodelist[0]);
            }
            LiftMultiText text     = ReadMultiText(node);
            TBase         reversal = _merger.GetOrMakeParentReversal(parent, text, type);

            if (reversal != null)
            {
                ReadGrammi(reversal, node);
            }
            return(reversal);
        }
示例#7
0
        private void ReadReversal(XmlNode node, TSense sense)
        {
            string      type     = Utilities.GetOptionalAttributeString(node, "type");
            XmlNodeList nodelist = node.SelectNodes("main");

            if (nodelist.Count > 1)
            {
                NotifyFormatError(new LiftFormatException(String.Format("Only one <main> element is allowed inside a <reversal> element:\r\n{0}", node.OuterXml)));
            }
            TBase parent = null;

            if (nodelist.Count == 1)
            {
                parent = ReadParentReversal(type, nodelist[0]);
            }
            LiftMultiText text     = ReadMultiText(node);
            TBase         reversal = _merger.MergeInReversal(sense, parent, text, type, node.OuterXml);

            if (reversal != null)
            {
                ReadGrammi(reversal, node);
            }
        }
示例#8
0
        internal TEntry ReadEntry(XmlNode node)
        {
            if (_changeReport != null)
            {
                string id = Utilities.GetOptionalAttributeString(node, "id");
                if (ChangeReport.GetChangeType(id) == LiftChangeReport.ChangeType.None)
                {
                    return(default(TEntry));
                }
            }

            Extensible extensible  = ReadExtensibleElementBasics(node);
            DateTime   dateDeleted = GetOptionalDate(node, "dateDeleted", default(DateTime));

            if (dateDeleted != default(DateTime))
            {
                _merger.EntryWasDeleted(extensible, dateDeleted);
                return(default(TEntry));
            }

            int    homograph = 0;
            string order     = Utilities.GetOptionalAttributeString(node, "order");

            if (!String.IsNullOrEmpty(order))
            {
                if (!Int32.TryParse(order, out homograph))
                {
                    homograph = 0;
                }
            }
            TEntry entry = _merger.GetOrMakeEntry(extensible, homograph);

            if (entry == null)// pruned
            {
                return(entry);
            }


            LiftMultiText lexemeForm = LocateAndReadMultiText(node, "lexical-unit");

            if (!lexemeForm.IsEmpty)
            {
                _merger.MergeInLexemeForm(entry, lexemeForm);
            }
            LiftMultiText citationForm = LocateAndReadMultiText(node, "citation");

            if (!citationForm.IsEmpty)
            {
                _merger.MergeInCitationForm(entry, citationForm);
            }

            ReadNotes(node, entry);

            foreach (XmlNode n in node.SelectNodes("sense"))
            {
                ReadSense(n, entry);
            }

            foreach (XmlNode n in node.SelectNodes("relation"))
            {
                ReadRelation(n, entry);
            }

            foreach (XmlNode n in node.SelectNodes("variant"))
            {
                ReadVariant(n, entry);
            }

            foreach (XmlNode n in node.SelectNodes("pronunciation"))
            {
                ReadPronunciation(n, entry);
            }

            foreach (XmlNode n in node.SelectNodes("etymology"))
            {
                ReadEtymology(n, entry);
            }

            ReadExtensibleElementDetails(entry, node);
            _merger.FinishEntry(entry);
            return(entry);
        }
示例#9
0
 public void Merge(LiftMultiText theirs, LiftMultiText ancestor)
 {
 }