1.1 --- a/java/alt2xml-lib/src/cz/frantovo/alt2xml/SuperReader.java Sat Jun 07 15:03:52 2014 +0200
1.2 +++ b/java/alt2xml-lib/src/cz/frantovo/alt2xml/SuperReader.java Sat Jun 07 15:42:48 2014 +0200
1.3 @@ -18,9 +18,9 @@
1.4 package cz.frantovo.alt2xml;
1.5
1.6 import java.io.IOException;
1.7 -import java.net.URI;
1.8 import java.util.HashMap;
1.9 import java.util.Map;
1.10 +import java.util.Map.Entry;
1.11 import org.xml.sax.ContentHandler;
1.12 import org.xml.sax.DTDHandler;
1.13 import org.xml.sax.EntityResolver;
1.14 @@ -41,7 +41,8 @@
1.15 private ErrorHandler errorHandler;
1.16 private DTDHandler dtdHandler;
1.17 private EntityResolver entityResolver;
1.18 - private Map<String, Object> properties = new HashMap<>();
1.19 + private final Map<String, Object> properties = new HashMap<>();
1.20 + private final Map<String, Boolean> features = new HashMap<>();
1.21 private final ReaderFinder readerFinder;
1.22
1.23 public SuperReader(ReaderFinder readerFinder) {
1.24 @@ -51,9 +52,25 @@
1.25 @Override
1.26 public void parse(InputSource input) throws IOException, SAXException {
1.27
1.28 + input = new AltInputSource(entityResolver, input);
1.29 +
1.30 System.err.println("SystemId: " + input.getSystemId());
1.31 -
1.32 +
1.33 XMLReader reader = readerFinder.findReader(input.getSystemId());
1.34 +
1.35 + reader.setContentHandler(contentHandler);
1.36 + reader.setDTDHandler(dtdHandler);
1.37 + reader.setEntityResolver(entityResolver);
1.38 + reader.setErrorHandler(errorHandler);
1.39 +
1.40 + for (Entry<String, Object> e : properties.entrySet()) {
1.41 + reader.setProperty(e.getKey(), e.getValue());
1.42 + }
1.43 +
1.44 + for (Entry<String, Boolean> e : features.entrySet()) {
1.45 + reader.setFeature(e.getKey(), e.getValue());
1.46 + }
1.47 +
1.48 reader.parse(input);
1.49 }
1.50
1.51 @@ -70,12 +87,15 @@
1.52 * the http://xml.org/sax/features/namespaces
1.53 * and the http://xml.org/sax/features/namespace-prefixes feature names.
1.54 */
1.55 - throw new SAXNotSupportedException("Zatím není podporováno.");
1.56 + return features.get(name);
1.57 }
1.58
1.59 @Override
1.60 public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException {
1.61 - throw new SAXNotSupportedException("Zatím není podporováno.");
1.62 + /**
1.63 + * TODO: filtrovat – povolit jen náš jmenný prostor
1.64 + */
1.65 + features.put(name, value);
1.66 }
1.67
1.68 @Override