У меня проблемы с постоянством в ЭДС. Проблема возникает, когда я добавляю элемент в файл, который содержит карту элементов. Процесс:
Load file
Add element
Save file
При первом добавлении элемента он работает нормально. Но если я пытаюсь добавить другой, он читает список дважды перед добавлением нового элемента. Все последующие использования также читают список дважды.
ПРИМЕР
Я начинаю с файла, который выглядит следующим образом:
<?xml version="1.0" encoding="ASCII"?>
<org.eclipse.mbt.core:CoreServicesResources xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:org.eclipse.mbt.core="http://org/eclipse/mbt/core">
<primaryResources>
<elementsMap key="1">
<value URI="1">
<traceabilityProperties traceable="true" derived="true" topLevel="true" />
<keywords tags="foo" />
</value>
</elementsMap>
</primaryResources>
</org.eclipse.mbt.core:CoreServicesResources>
Если я добавлю новый элемент, в результате я получаю файл, который выглядит следующим образом:
<?xml version="1.0" encoding="ASCII"?>
<org.eclipse.mbt.core:CoreServicesResources xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:org.eclipse.mbt.core="http://org/eclipse/mbt/core">
<primaryResources>
<elementsMap key="1">
<value URI="1">
<traceabilityProperties traceable="true" derived="true" topLevel="true"/>
<keywords tags="foo"/>
</value>
</elementsMap>
<elementsMap key="2">
<value URI="2">
<traceabilityProperties traceable="true" derived="true" topLevel="true"/>
<keywords tags="bar"/>
</value>
</elementsMap>
</primaryResources>
</org.eclipse.mbt.core:CoreServicesResources>
Однако, если я добавлю другой элемент, я получу это, что неверно:
<?xml version="1.0" encoding="ASCII"?>
<org.eclipse.mbt.core:CoreServicesResources xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:org.eclipse.mbt.core="http://org/eclipse/mbt/core">
<primaryResources>
<elementsMap key="1">
<value URI="1">
<traceabilityProperties traceable="true" derived="true" topLevel="true"/>
<keywords tags="foo"/>
</value>
</elementsMap>
<elementsMap key="2">
<value URI="2">
<traceabilityProperties traceable="true" derived="true" topLevel="true"/>
<keywords tags="bar"/>
</value>
</elementsMap>
<elementsMap key="1">
<value URI="1">
<traceabilityProperties traceable="true" derived="true" topLevel="true"/>
<keywords tags="bar"/>
</value>
</elementsMap>
<elementsMap key="2">
<value URI="2">
<traceabilityProperties traceable="true" derived="true" topLevel="true"/>
<keywords tags="foo"/>
</value>
</elementsMap>
<elementsMap key="3">
<value URI="3">
<traceabilityProperties traceable="true" derived="true" topLevel="true"/>
<keywords tags="bar"/>
</value>
</elementsMap>
</primaryResources>
</org.eclipse.mbt.core:CoreServicesResources>
Когда я отлаживаю код, кажется, что проблема происходит где-то в парсере. Я использую системную библиотеку Java SE-11, и синтаксический анализатор com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl
У кого-нибудь еще были такие проблемы?