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