changeset 7130:b315cb9a7544

8014500: bootcycle-images fails after upgrade to JAXP 1.5 Reviewed-by: lancea
author alanb
date Tue, 14 May 2013 14:32:15 +0100
parents a50bad038f31
children 5ea5f5dfb96a
files make/tools/src/build/tools/cldrconverter/CLDRConverter.java
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/make/tools/src/build/tools/cldrconverter/CLDRConverter.java	Mon May 13 22:16:55 2013 -0700
+++ b/make/tools/src/build/tools/cldrconverter/CLDRConverter.java	Tue May 14 14:32:15 2013 +0100
@@ -34,6 +34,8 @@
 import java.util.*;
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
 
 
 /**
@@ -234,6 +236,17 @@
         }
     }
 
+    /**
+     * Configure the parser to allow access to DTDs on the file system.
+     */
+    private static void enableFileAccess(SAXParser parser) throws SAXNotSupportedException {
+        try {
+            parser.setProperty("http://javax.xml.XMLConstants/property/accessExternalDTD", "file");
+        } catch (SAXNotRecognizedException ignore) {
+            // property requires >= JAXP 1.5
+        }
+    }
+
     private static List<Bundle> readBundleList() throws Exception {
         ResourceBundle.Control defCon = ResourceBundle.Control.getControl(ResourceBundle.Control.FORMAT_DEFAULT);
         List<Bundle> retList = new ArrayList<>();
@@ -279,6 +292,7 @@
         SAXParserFactory factory = SAXParserFactory.newInstance();
         factory.setValidating(true);
         SAXParser parser = factory.newSAXParser();
+        enableFileAccess(parser);
         LDMLParseHandler handler = new LDMLParseHandler(id);
         File file = new File(SOURCE_FILE_DIR + File.separator + id + ".xml");
         if (!file.exists()) {
@@ -314,6 +328,7 @@
         SAXParserFactory factorySuppl = SAXParserFactory.newInstance();
         factorySuppl.setValidating(true);
         SAXParser parserSuppl = factorySuppl.newSAXParser();
+        enableFileAccess(parserSuppl);
         handlerSuppl = new SupplementDataParseHandler();
         File fileSupply = new File(SPPL_SOURCE_FILE);
         parserSuppl.parse(fileSupply, handlerSuppl);
@@ -322,6 +337,7 @@
         SAXParserFactory numberingParser = SAXParserFactory.newInstance();
         numberingParser.setValidating(true);
         SAXParser parserNumbering = numberingParser.newSAXParser();
+        enableFileAccess(parserNumbering);
         handlerNumbering = new NumberingSystemsParseHandler();
         File fileNumbering = new File(NUMBERING_SOURCE_FILE);
         parserNumbering.parse(fileNumbering, handlerNumbering);
@@ -330,6 +346,7 @@
         SAXParserFactory metazonesParser = SAXParserFactory.newInstance();
         metazonesParser.setValidating(true);
         SAXParser parserMetaZones = metazonesParser.newSAXParser();
+        enableFileAccess(parserMetaZones);
         handlerMetaZones = new MetaZonesParseHandler();
         File fileMetaZones = new File(METAZONES_SOURCE_FILE);
         parserNumbering.parse(fileMetaZones, handlerMetaZones);