Fix serialization problem due to prefix clash

Make the prefix unique by appending a number, starting from zero,
if the default prefix is already mapped to a different namespace.

Check if the namespace has already been mapped to a prefix.

Bug: 329804
diff --git a/org.eclipse.bpmn2/src/org/eclipse/bpmn2/util/Bpmn2ResourceImpl.java b/org.eclipse.bpmn2/src/org/eclipse/bpmn2/util/Bpmn2ResourceImpl.java
index 1a1e657..204b3cc 100644
--- a/org.eclipse.bpmn2/src/org/eclipse/bpmn2/util/Bpmn2ResourceImpl.java
+++ b/org.eclipse.bpmn2/src/org/eclipse/bpmn2/util/Bpmn2ResourceImpl.java
@@ -244,12 +244,23 @@
          * @return

          */

         private String getPrefixDuringSave(String namespace) {

+            if (urisToPrefixes.containsKey(namespace))

+                return urisToPrefixes.get(namespace).get(0);

+

             EPackage ePackage = extendedMetaData.getPackage(namespace);

             if (ePackage == null) {

                 ePackage = extendedMetaData.demandPackage(namespace);

                 // This will internally create a nice prefix

             }

             String prefix = ePackage.getNsPrefix();

+

+            // Make prefix unique

+            String originalPrefix = prefix + "_";

+            int discr = 0;

+            while (prefixesToURIs.containsKey(prefix)

+                    && !prefixesToURIs.get(prefix).equals(namespace))

+                prefix = originalPrefix + discr++;

+

             // I'm not sure if the following code is needed, but I keep it to avoid inconsistencies

             if (!packages.containsKey(ePackage)) {

                 packages.put(ePackage, prefix);