Skip to content

Commit

Permalink
Merge pull request #1674 from lat-lon/feature/samePrefixDifferent-965…
Browse files Browse the repository at this point in the history
…5-185

Enhanced GmlTool to support multiple namespaces with same prefix in one application schema (3.5)
  • Loading branch information
copierrj authored Apr 10, 2024
2 parents 21278b6 + 98d7050 commit 01cca9b
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;

import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
Expand Down Expand Up @@ -223,10 +225,21 @@ public synchronized Map<String, String> getNamespacePrefixes() {
if (prefix != null && !prefix.equals(XMLConstants.DEFAULT_NS_PREFIX)) {
String nsUri = xmlStream.getNamespaceURI(i);
String oldPrefix = nsToPrefix.get(nsUri);
Optional<String> oldNsUri = nsToPrefix.entrySet()
.stream()
.filter(entry -> prefix.equals(entry.getValue()))
.map(Map.Entry::getKey)
.findFirst();
if (oldPrefix != null && !oldPrefix.equals(prefix)) {
LOG.debug("Multiple prefices for namespace '" + nsUri + "': " + prefix
+ " / " + oldPrefix);
}
else if (oldNsUri.isPresent() && !oldNsUri.get().equals(nsUri)) {
String newPrefix = prefix + UUID.randomUUID();
LOG.warn("Multiple nsUrls for prefix '" + prefix + "': " + nsUri
+ ". Created new prefix: " + newPrefix);
nsToPrefix.put(nsUri, newPrefix);
}
else {
nsToPrefix.put(nsUri, prefix);
}
Expand Down

0 comments on commit 01cca9b

Please sign in to comment.