Skip to content

Commit

Permalink
Fixed catalog
Browse files Browse the repository at this point in the history
  • Loading branch information
rmraya committed Sep 22, 2019
1 parent 6a9b12a commit d2d5499
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
Binary file modified lib/openxliff.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions src/com/maxprograms/converters/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ private Constants() {

public static final String TOOLID = "OpenXLIFF";
public static final String TOOLNAME = "OpenXLIFF Filters";
public static final String VERSION = "1.6.0";
public static final String BUILD = "20190909_1218";
public static final String VERSION = "1.5.1";
public static final String BUILD = "20190922_0931";

public static final String SUCCESS = "0";
public static final String ERROR = "1";
Expand Down
8 changes: 7 additions & 1 deletion src/com/maxprograms/validation/Xliff20.java
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,13 @@ private boolean validateInlineElements(Element e) {
}

private Source getSource(String string) {
String location = resolver.matchPublic(string);
String location = resolver.matchURI(string);
if (location == null) {
location = resolver.matchPublic(string);
}
if (location == null) {
location = resolver.matchSystem("", string);
}
Source source = new StreamSource(location);
return source;
}
Expand Down
30 changes: 18 additions & 12 deletions src/com/maxprograms/xml/Catalog.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ public Catalog(String catalogFile)
if (!workDir.endsWith(File.separator)) {
workDir = workDir + File.separator;
}
String[] catalogs = new String[1];
catalogs[0] = file.toURI().toURL().toString();

systemCatalog = new Hashtable<>();
publicCatalog = new Hashtable<>();
Expand All @@ -74,6 +72,13 @@ private void recurse(Element root)

if (!child.getAttributeValue("xml:base", "").equals("")) {
base = child.getAttributeValue("xml:base");
File b = new File(base);
if (!b.isAbsolute()) {
base = XMLUtils.getAbsolutePath(workDir, base);
if (!base.endsWith(File.separator)) {
base = base + File.separator;
}
}
}

if (child.getName().equals("system") && !systemCatalog.containsKey(child.getAttributeValue("systemId"))) {
Expand Down Expand Up @@ -173,17 +178,16 @@ private static boolean validate(String uri) {
return file.exists();
}

private String makeAbsolute(String uri) throws URISyntaxException {
URI b = new URI(base);
URI u = b.resolve(uri).normalize();
if (!u.isAbsolute()) {
URI work = new URI(workDir);
private String makeAbsolute(String uri) throws IOException {
File f = new File(base + uri);
if (!f.isAbsolute()) {
if (!base.isEmpty()) {
work = work.resolve(base);
return XMLUtils.getAbsolutePath(base, uri);
} else {
return XMLUtils.getAbsolutePath(workDir, uri);
}
u = work.resolve(uri).normalize();
}
return u.toString();
return base + uri;
}

private Hashtable<String, String> getSystemCatalogue() {
Expand Down Expand Up @@ -324,8 +328,10 @@ public String matchURI(String uri) {
}
try {
URI u = new URI(uri).normalize();
return u.toString();
} catch (URISyntaxException e) {
if (u.toURL().getProtocol().startsWith("file")) {
return u.toString();
}
} catch (URISyntaxException | MalformedURLException e) {
// ignore
}
}
Expand Down

0 comments on commit d2d5499

Please sign in to comment.