1 | private Source getSource(InputStream is, File infile)↵ | | 1 | private Source getSource(InputStream is, Resource resource)↵
|
2 | throws ParserConfigurationException, SAXException {↵ | | 2 | throws ParserConfigurationException, SAXException {↵
|
3 | // todo: is this comment still relevant ??↵ | | 3 | // todo: is this comment still relevant ??↵
|
4 | // FIXME: need to use a SAXSource as the source for the transform↵ | | 4 | // FIXME: need to use a SAXSource as the source for the transform↵
|
5 | // so we can plug in our own entity resolver↵ | | 5 | // so we can plug in our own entity resolver↵
|
6 | Source src = null;↵ | | 6 | Source src = null;↵
|
7 | if (entityResolver != null) {↵ | | 7 | if (entityResolver != null) {↵
|
8 | if (getFactory().getFeature(SAXSource.FEATURE)) {↵ | | 8 | if (getFactory().getFeature(SAXSource.FEATURE)) {↵
|
9 | SAXParserFactory spFactory = SAXParserFactory.newInstance();↵ | | 9 | SAXParserFactory spFactory = SAXParserFactory.newInstance();↵
|
10 | spFactory.setNamespaceAware(true);↵ | | 10 | spFactory.setNamespaceAware(true);↵
|
11 | XMLReader reader = spFactory.newSAXParser().getXMLReader();↵ | | 11 | XMLReader reader = spFactory.newSAXParser().getXMLReader();↵
|
12 | reader.setEntityResolver(entityResolver);↵ | | 12 | reader.setEntityResolver(entityResolver);↵
|
13 | src = new SAXSource(reader, new InputSource(is));↵ | | 13 | src = new SAXSource(reader, new InputSource(is));↵
|
14 | } else {↵ | | 14 | } else {↵
|
15 | throw new IllegalStateException("xcatalog specified, but "↵ | | 15 | throw new IllegalStateException("xcatalog specified, but "↵
|
16 | + "parser doesn't support SAX");↵ | | 16 | + "parser doesn't support SAX");↵
|
17 | }↵ | | 17 | }↵
|
18 | } else {↵ | | 18 | } else {↵
|
19 | // WARN: Don't use the StreamSource(File) ctor. It won't work with↵ | | 19 | // WARN: Don't use the StreamSource(File) ctor. It won't work with↵
|
20 | // xalan prior to 2.2 because of systemid bugs.↵ | | 20 | // xalan prior to 2.2 because of systemid bugs.↵
|
21 | src = new StreamSource(is);↵ | | 21 | src = new StreamSource(is);↵
|
22 | }↵ | | 22 | }↵
|
23 | src.setSystemId(JAXPUtils.getSystemId(infil↵ | | 23 | // The line below is a hack: the system id must an URI, but it is not↵
|
| | | 24 | // cleat to get the URI of an resource, so just set the name of the↵
|
| | | 25 | // resource as a system id↵
|
24 | e));↵ | | 26 | src.setSystemId(resourceToURI(resource));↵
|
25 | return src;↵ | | 27 | return src;↵
|
26 | | | 28 |
|