Thanks for taking all the trouble.
Btw: Windows 10, SWI-Prolog 8.2.4
I radically condensed the xml-file. Suppose we have a file miniodenet.xml:
(lines are very long, sorry…)
<?xml version="1.0" encoding="UTF-8"?>
<LexicalResource xmlns:dc="http://purl.org/dc/elements/1.1/" >
<Lexicon id="minimal_odenet" >
<LexicalEntry id="w8"><Lemma writtenForm="wegfahren" partOfSpeech="v"/><Sense id="w8_3-v" synset="odenet-3-v"></Sense></LexicalEntry>
<LexicalEntry id="w4007" confidenceScore="1.0"><Lemma writtenForm="Tenor" partOfSpeech="n"/><Sense id="w4007_811-n" synset="odenet-811-n" note="PHON:ˈteːnoːɐ̯"/><Sense id="w4007_15099-n" synset="odenet-15099-n" note="PHON:teˈnoːɐ̯"/><Sense id="w4007_34494-n" synset="odenet-34494-n" note="PHON:ˈteːnoːɐ̯"/></LexicalEntry>
<LexicalEntry id="w67853"><Lemma writtenForm="π" partOfSpeech="n"/><Sense id="w67853_18808-n" synset="odenet-18808-n"/></LexicalEntry>
</Lexicon>
</LexicalResource>
and a prolog source odenet.pro:
:- encoding(utf8).
:- dynamic element/3.
go:-
load_xml('miniodenet.xml',Tree,[]),
% extracting list of entries
[element(_,_,[_,element(_,_,EntryList),_])] = Tree,
maplist(to_fact,EntryList).
to_fact('\n'):- !. % skipping newlines
to_fact(E):- assert(E).
save:- tell('miniodenet.pro'), listing(element), told.
Executing prolog:
?- go.
?- save.
?- listing(element).
:- dynamic element/3.
element('LexicalEntry', [id=w8], [element('Lemma', [writtenForm=wegfahren, partOfSpeech=v], []), element('Sense', [id='w8_3-v', synset='odenet-3-v'], [])]).
element('LexicalEntry', [id=w4007, confidenceScore='1.0'], [element('Lemma', [writtenForm='Tenor', partOfSpeech=n], []), element('Sense', [id='w4007_811-n', synset='odenet-811-n', note='PHON:ˈteːnoːɐ̯'], []), element('Sense', [id='w4007_15099-n', synset='odenet-15099-n', note='PHON:teˈnoːɐ̯'], []), element('Sense', [id='w4007_34494-n', synset='odenet-34494-n', note='PHON:ˈteːnoːɐ̯'], [])]).
element('LexicalEntry', [id=w67853], [element('Lemma', [writtenForm=π, partOfSpeech=n], []), element('Sense', [id='w67853_18808-n', synset='odenet-18808-n'], [])]).
Everything looks fine.
But saved database in miniodenet.pro looks like:
:- dynamic element/3.
element('LexicalEntry', [id=w8], [element('Lemma', [writtenForm=wegfahren, partOfSpeech=v], []), element('Sense', [id='w8_3-v', synset='odenet-3-v'], [])]).
element('LexicalEntry', [id=w4007, confidenceScore='1.0'], [element('Lemma', [writtenForm='Tenor', partOfSpeech=n], []), element('Sense', [id='w4007_811-n', synset='odenet-811-n', note='PHON:'te\u02D0no\u02D0\u0250\u032F'], []), element('Sense', [id='w4007_15099-n', synset='odenet-15099-n', note='PHON:te'no\u02D0\u0250\u032F'], []), element('Sense', [id='w4007_34494-n', synset='odenet-34494-n', note='PHON:'te\u02D0no\u02D0\u0250\u032F'], [])]).
element('LexicalEntry', [id=w67853], [element('Lemma', [writtenForm=p, partOfSpeech=n], []), element('Sense', [id='w67853_18808-n', synset='odenet-18808-n'], [])]).
Obviously, prolog interprets the primary stress mark (ˈ) (some kind of phonetic symbol) as a quote (’).
?- consult('miniodenet.pro').
ERROR: c:/......../prolog/miniodenet.pro:4:1: Syntax error: End of file in quoted atom