diff --git a/core/src/main/java/tc/oc/pgm/map/MapFactoryImpl.java b/core/src/main/java/tc/oc/pgm/map/MapFactoryImpl.java index a1b592dbd3..c1d8e73466 100644 --- a/core/src/main/java/tc/oc/pgm/map/MapFactoryImpl.java +++ b/core/src/main/java/tc/oc/pgm/map/MapFactoryImpl.java @@ -93,7 +93,11 @@ public MapContext load() throws MapException { } catch (ModuleLoadException e) { throw new MapException(source, info, e.getFullMessage(), e); } catch (JDOMParseException e) { - final InvalidXMLException cause = InvalidXMLException.fromJDOM(e, source.getId()); + // Set base uri so when error is displayed it shows what XML caused the issue + Document d = e.getPartialDocument(); + if (d != null) d.setBaseURI(source.getId()); + + final InvalidXMLException cause = InvalidXMLException.fromJDOM(e); throw new MapException(source, info, cause.getMessage(), cause); } catch (Throwable t) { throw new MapException(source, info, "Unhandled " + t.getClass().getName(), t); diff --git a/core/src/main/java/tc/oc/pgm/map/MapFilePreprocessor.java b/core/src/main/java/tc/oc/pgm/map/MapFilePreprocessor.java index ed24a26847..97e27ab1cc 100644 --- a/core/src/main/java/tc/oc/pgm/map/MapFilePreprocessor.java +++ b/core/src/main/java/tc/oc/pgm/map/MapFilePreprocessor.java @@ -64,7 +64,7 @@ public Document getDocument() DocumentWrapper document; try (final InputStream stream = source.getDocument()) { document = (DocumentWrapper) DOCUMENT_FACTORY.get().build(stream); - document.setBaseURI(source.getId() + ("default".equals(variant) ? "" : "[" + variant + "]")); + document.setBaseURI(source.getId()); } document.runWithoutVisitation( diff --git a/core/src/main/java/tc/oc/pgm/map/source/SystemMapSource.java b/core/src/main/java/tc/oc/pgm/map/source/SystemMapSource.java index dad25e26d9..70c17d1a46 100644 --- a/core/src/main/java/tc/oc/pgm/map/source/SystemMapSource.java +++ b/core/src/main/java/tc/oc/pgm/map/source/SystemMapSource.java @@ -73,7 +73,8 @@ private File getFile() throws MapMissingException { @Override public String getId() { - return "<" + root.getDisplayName() + ">/" + dir.toString(); + String suffix = (variant != null ? "[" + variant + "]" : ""); + return "<" + root.getDisplayName() + ">/" + dir.toString() + suffix; } @Override diff --git a/util/src/main/java/tc/oc/pgm/util/xml/InvalidXMLException.java b/util/src/main/java/tc/oc/pgm/util/xml/InvalidXMLException.java index 39c5d08487..d835c58fc2 100644 --- a/util/src/main/java/tc/oc/pgm/util/xml/InvalidXMLException.java +++ b/util/src/main/java/tc/oc/pgm/util/xml/InvalidXMLException.java @@ -67,7 +67,7 @@ public InvalidXMLException(String message, Attribute attribute) { this(message, attribute, null); } - public static InvalidXMLException fromJDOM(JDOMParseException e, String documentPath) { + public static InvalidXMLException fromJDOM(JDOMParseException e) { return new InvalidXMLException( e.getMessage(), null,