Skip to content

Commit 80e0542

Browse files
committed
Added RelaxNG schema caching
1 parent ce66b07 commit 80e0542

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

lib/xmljava.jar

182 Bytes
Binary file not shown.

src/com/maxprograms/xml/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
public class Constants {
1414

1515
public static final String VERSION = "5.0.0";
16-
public static final String BUILD = "20260610_0723";
16+
public static final String BUILD = "20260613_1707";
1717

1818
private Constants() {
1919
// private for security

src/com/maxprograms/xml/CustomContentHandler.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public class CustomContentHandler implements IContentHandler {
4444
private String encoding;
4545
private Catalog catalog;
4646
private boolean isRelaxNG;
47+
private static Hashtable<String, Map<String, Map<String, String>>> relaxNgCache = new Hashtable<>();
4748
private Map<String, Map<String, String>> defaultAttributes;
4849
private File documentBase;
4950

@@ -432,8 +433,13 @@ private void parseRelaxNG(String href) throws SAXException, IOException, ParserC
432433
}
433434
}
434435
if (system != null) {
435-
RelaxNGParser relaxngParser = new RelaxNGParser(system, catalog);
436-
defaultAttributes = relaxngParser.getElements();
436+
synchronized (relaxNgCache) {
437+
if (!relaxNgCache.containsKey(system)) {
438+
RelaxNGParser relaxngParser = new RelaxNGParser(system, catalog);
439+
relaxNgCache.put(system, relaxngParser.getElements());
440+
}
441+
defaultAttributes = relaxNgCache.get(system);
442+
}
437443
isRelaxNG = true;
438444
}
439445
}

0 commit comments

Comments
 (0)