Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/common/JRReportSaxParserFactory.java @ 8999:e3b3ce32c825
Work on uinfo
author | gernotbelger |
---|---|
date | Thu, 12 Apr 2018 19:15:42 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
8998:c38098b15427 | 8999:e3b3ce32c825 |
---|---|
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 package org.dive4elements.river.artifacts.common; | |
11 | |
12 import java.util.ArrayList; | |
13 import java.util.Collection; | |
14 import java.util.List; | |
15 | |
16 import net.sf.jasperreports.engine.component.ComponentsBundle; | |
17 import net.sf.jasperreports.engine.component.ComponentsEnvironment; | |
18 import net.sf.jasperreports.engine.component.ComponentsXmlParser; | |
19 import net.sf.jasperreports.engine.xml.BaseSaxParserFactory; | |
20 import net.sf.jasperreports.engine.xml.JRXmlConstants; | |
21 | |
22 /** | |
23 * Own sax parser factory, because: | |
24 * - we do not want xml validation (we know it's good) | |
25 * - xerxes sax parser complains about two schemas with same namespace... | |
26 * | |
27 * @author Domenico Nardi Tironi | |
28 */ | |
29 public class JRReportSaxParserFactory extends BaseSaxParserFactory { | |
30 | |
31 @Override | |
32 protected boolean isValidating() { | |
33 return false; | |
34 } | |
35 | |
36 @Override | |
37 protected List<String> getSchemaLocations() { | |
38 final List<String> schemas = new ArrayList<>(); | |
39 | |
40 schemas.add(getResourceURI(JRXmlConstants.JASPERREPORT_XSD_RESOURCE)); | |
41 // schemas.add(getResourceURI(JRXmlConstants.JASPERREPORT_XSD_DTD_COMPAT_RESOURCE)); | |
42 | |
43 final Collection<ComponentsBundle> components = ComponentsEnvironment.getComponentBundles(); | |
44 for (final ComponentsBundle componentManager : components) { | |
45 final ComponentsXmlParser xmlParser = componentManager.getXmlParser(); | |
46 | |
47 String schemaURI; | |
48 final String schemaResource = xmlParser.getInternalSchemaResource(); | |
49 if (schemaResource != null) { | |
50 schemaURI = getResourceURI(schemaResource); | |
51 } else { | |
52 schemaURI = xmlParser.getPublicSchemaLocation(); | |
53 } | |
54 | |
55 schemas.add(schemaURI); | |
56 } | |
57 return schemas; | |
58 } | |
59 } |