mt-additional-xml-shema-support #6

Merged
lkavcic merged 10 commits from mt-additional-xml-shema-support into master 2020-08-14 09:32:35 +00:00
3 changed files with 10 additions and 1 deletions
Showing only changes of commit efe4d07464 - Show all commits

View File

@ -26,6 +26,8 @@ def export_entry(entry):
headword_lemma.textContent = entry.headword
if entry.headword_type is not None:
headword_lemma.setAttribute("type", entry.headword_type)
if entry.headword_audio is not None:
headword_lemma.setAttribute("audio", entry.headword_audio)
headword.appendChild(headword_lemma)
head.appendChild(headword)
@ -146,6 +148,9 @@ def export_translation(doc, translation):
actual_t.textContent = translation.translation
actual_t.setAttribute("targetLang", translation.targetLang)
if translation.audio:
actual_t.setAttribute("audio", translation.audio)
if translation.source:
actual_t.setAttribute("source", translation.source)
translation_xml.appendChild(actual_t)

View File

@ -14,6 +14,7 @@ class Entry(Data):
self.headword = ""
self.homonymy = []
self.headword_type = None
self.headword_audio = None
self.grammar = ""
self.comment = ""
self.variants = []
@ -31,7 +32,8 @@ class Entry(Data):
comment = entry_xml.querySelector("head comment")
self.status = status.textContent if status else ""
self.headword = headword.textContent if headword else ""
self.headword_type = headword.getAttribute("type") if headword else None
self.headword_type = headword.getAttribute("type") if .hasAttribute("type") else None
self.headword_audio = headword.getAttribute("audio") if headword.hasAttribute("audio") else None
self.grammar = grammar.textContent if grammar else ""
self.comment = comment.textContent if comment else ""
self.variants = [v.textContent for v in entry_xml.querySelectorAll("head variantList variant")]

View File

@ -33,6 +33,7 @@ class Translation(Data):
self.translation = ""
self.source = ""
self.targetLang = ""
self.audio = ""
self.explanation = ""
self.explanationList = []
self.tags = []
@ -44,6 +45,7 @@ class Translation(Data):
self.translation = translation.textContent
self.source = translation.getAttribute("source") if translation.hasAttribute("source") else ""
self.targetLang = translation.getAttribute("targetLang") if translation.hasAttribute("targetLang") else ""
self.audio = translation.getAttribute("audio") if translation.hasAttribute("audio") else ""
explanationList = translation_xml.querySelectorAll("explanationList explanation")