mt-additional-xml-shema-support #6
|
@ -9,6 +9,7 @@ def export_to_xml(model):
|
|||
|
||||
|
||||
def export_entry(entry):
|
||||
console.log(entry)
|
||||
parser = __new__(DOMParser())
|
||||
doc = parser.parseFromString("<entry />", "text/xml")
|
||||
entry_xml = doc.firstChild
|
||||
|
@ -23,6 +24,9 @@ def export_entry(entry):
|
|||
|
||||
headword = doc.createElement("headword")
|
||||
headword_lemma = doc.createElement("lemma")
|
||||
|
||||
# headword_lemma = entry.original_xml.querySelector("head headword lemma")
|
||||
|
||||
headword_lemma.textContent = entry.headword
|
||||
if entry.headword_type is not None:
|
||||
headword_lemma.setAttribute("type", entry.headword_type)
|
||||
|
@ -54,11 +58,21 @@ def export_entry(entry):
|
|||
lexunit.appendChild(lexeme)
|
||||
head.appendChild(lexunit)
|
||||
|
||||
grammar = doc.createElement("grammar")
|
||||
grammar_category = doc.createElement("category")
|
||||
grammar_category = entry.original_xml.querySelector("head grammar category")
|
||||
if grammar_category is None:
|
||||
grammar = doc.createElement("grammar")
|
||||
grammar_category = doc.createElement("category")
|
||||
grammar.appendChild(grammar_category)
|
||||
entry.original_xml.querySelector("head").appendChild(grammar_category)
|
||||
|
||||
grammar_category.textContent = entry.grammar
|
||||
grammar.appendChild(grammar_category)
|
||||
head.appendChild(grammar)
|
||||
|
||||
head.appendChild(entry.original_xml.querySelector("head grammar"))
|
||||
# if (grammar_category)
|
||||
|
||||
# entry.original_xml.querySelector("head grammar category").textContent
|
||||
# grammar.appendChild(grammar_category)
|
||||
# head.appendChild(grammar)
|
||||
|
||||
if len(entry.measure) > 0:
|
||||
measure_list = doc.createElement("measureList")
|
||||
|
|
|
@ -23,15 +23,12 @@ class Entry(Data):
|
|||
self.measure = {}
|
||||
self.labels = []
|
||||
self.senses = []
|
||||
self.original_xml = None
|
||||
|
||||
def import_xml(self, entry_xml):
|
||||
# console.log(entry_xml)
|
||||
# xmlClone = entry_xml.cloneNode(True)
|
||||
|
||||
self.original_xml = entry_xml.cloneNode(True)
|
||||
status = entry_xml.querySelector("head status")
|
||||
|
||||
# xmlClone.removeChild(status)
|
||||
# console.log(xmlClone)
|
||||
headword = entry_xml.querySelector("head headword lemma")
|
||||
|
||||
grammar = entry_xml.querySelector("head grammar category")
|
||||
|
|
Loading…
Reference in New Issue
Block a user