java/alt2xml-cli/src/cz/frantovo/alt2xml/cli/CLI.java
changeset 39 a5020340362b
parent 31 c9f1e497132e
child 40 4afb00b7b1a9
     1.1 --- a/java/alt2xml-cli/src/cz/frantovo/alt2xml/cli/CLI.java	Sun Jun 08 11:24:03 2014 +0200
     1.2 +++ b/java/alt2xml-cli/src/cz/frantovo/alt2xml/cli/CLI.java	Sun Jun 08 15:00:19 2014 +0200
     1.3 @@ -26,6 +26,7 @@
     1.4  import javax.xml.parsers.SAXParserFactory;
     1.5  import javax.xml.stream.XMLOutputFactory;
     1.6  import javax.xml.stream.XMLStreamWriter;
     1.7 +import org.xml.sax.ext.LexicalHandler;
     1.8  import org.xml.sax.helpers.DefaultHandler;
     1.9  
    1.10  /**
    1.11 @@ -34,6 +35,7 @@
    1.12   */
    1.13  public class CLI {
    1.14  
    1.15 +	public static final String LEXICAL_HANDLER_PROPERTY = "http://xml.org/sax/properties/lexical-handler";
    1.16  	private static final Logger log = Logger.getLogger(CLI.class.getName());
    1.17  
    1.18  	public static void main(String[] args) {
    1.19 @@ -56,6 +58,20 @@
    1.20  
    1.21  			SAXParserFactory t = SAXParserFactory.newInstance();
    1.22  			SAXParser p = t.newSAXParser();
    1.23 +
    1.24 +			if (h instanceof LexicalHandler
    1.25 +					// TODO: add option/feature to disable LexicalHandler registration
    1.26 +					&& false) {
    1.27 +				try {
    1.28 +					p.setProperty(LEXICAL_HANDLER_PROPERTY, h);
    1.29 +				} catch (Exception e) {
    1.30 +					log.log(Level.WARNING, "LexicalHandler registration exception:", e);
    1.31 +					log.log(Level.WARNING,
    1.32 +							"Tried to register the handler {0} as a LexicalHandler but LexicalHandlers are not supported by the parser {1}",
    1.33 +							new Object[]{h, p});
    1.34 +				}
    1.35 +			}
    1.36 +
    1.37  			p.parse(vstup, h);
    1.38  		} catch (Exception e) {
    1.39  			log.log(Level.SEVERE, "Error during processing: " + Arrays.toString(args), e);