/** * DefaultConstructor. */ private RootEntityResolver() { entityResolver = ParserEntityResolver.getDefaultResolver(); }
/** * Returns a default resolver, which is initialized to redirect the parser to a local copy of the JFreeReport DTDs. * * @return the default entity resolver. */ public static synchronized ParserEntityResolver getDefaultResolver() { if ( singleton == null ) { singleton = new ParserEntityResolver(); } return singleton; }
/** * Collects the public and System-ID from the call for later use in the XmlDocumentInfo and then forwards the * resolver to the default resolver. * * @param publicId The public identifier of the external entity being referenced, or null if none was supplied. * @param systemId The system identifier of the external entity being referenced. * @return An InputSource object describing the new input source, or null to request that the parser open a regular * URI connection to the system identifier. * @throws org.xml.sax.SAXException Any SAX exception, possibly wrapping another exception. * @throws java.io.IOException A Java-specific IO exception, possibly the result of creating a new InputStream * or Reader for the InputSource. * @see org.xml.sax.InputSource */ public InputSource resolveEntity( final String publicId, final String systemId ) throws SAXException, IOException { this.publicId = publicId; this.systemId = systemId; return entityResolver.resolveEntity( publicId, systemId ); }
/** * Initializes the simple parser and registers this handler with the parser base module. * * @throws ModuleInitializeException * if initializing the module failes. */ public void performInit() throws ModuleInitializeException { final ParserEntityResolver res = ParserEntityResolver.getDefaultResolver(); final URL urlReportDTD = ObjectUtilities.getResource( "org/pentaho/reporting/engine/classic/core/modules/parser/simple/resources/report-085.dtd", SimpleParserModuleInit.class ); res.setDTDLocation( SimpleParserModuleInit.PUBLIC_ID_SIMPLE, SimpleParserModuleInit.SYSTEM_ID, urlReportDTD ); res.setDTDLocation( SimpleParserModuleInit.PUBLIC_ID_SIMPLE_084, SimpleParserModuleInit.SYSTEM_ID, urlReportDTD ); res.setDeprecatedDTDMessage( SimpleParserModuleInit.PUBLIC_ID_SIMPLE_084, "The given public identifier for the XML document is deprecated. " + "Please use the current document type declaration instead: \n" + " <!DOCTYPE report PUBLIC \n" + " \"-//JFreeReport//DTD report definition//EN//simple/version 0.8.5\"\n" + " \"http://jfreereport.sourceforge.net/report-085.dtd\">" ); } }
final URL location = getDTDLocation( systemId ); if ( location != null ) { final InputSource inputSource = new InputSource( location.openStream() ); final URL location = getDTDLocation( publicId ); if ( location != null ) { final InputSource inputSource = new InputSource( location.openStream() ); return inputSource; final String message = getDeprecatedDTDMessage( publicId ); if ( message != null ) { logger.info( message );
/** * Defines a DTD used to validate the report definition. Your XMLParser must be a validating parser for this feature * to work. * * @param publicID the public ID. * @param location the URL. * @return A boolean. */ public boolean setDTDLocation( final String publicID, final URL location ) { if ( isValid( location ) ) { this.dtds.put( publicID, location ); return true; } else { logger.warn( "Validate location failed for " + publicID + " location: " + location ); return false; } }
/** * Initializes the ext-parser and registers it at the parser base module. * * @throws org.pentaho.reporting.libraries.base.boot.ModuleInitializeException * if an error ocurres. */ public void performInit() throws ModuleInitializeException { final ParserEntityResolver res = ParserEntityResolver.getDefaultResolver(); final URL urlExtReportDTD = ObjectUtilities.getResource( "org/pentaho/reporting/engine/classic/core/modules/parser/ext/resources/extreport-085.dtd", ExtParserModuleInit.class ); res.setDTDLocation( ExtParserModuleInit.PUBLIC_ID_EXTENDED, ExtParserModuleInit.SYSTEM_ID, urlExtReportDTD ); res.setDTDLocation( ExtParserModuleInit.PUBLIC_ID_EXTENDED_084, ExtParserModuleInit.SYSTEM_ID, urlExtReportDTD ); res.setDeprecatedDTDMessage( ExtParserModuleInit.PUBLIC_ID_EXTENDED_084, "The given public identifier for the XML document is deprecated. " + "Please use the current document type declaration instead: \n" + " <!DOCTYPE report PUBLIC \n" + " \"-//JFreeReport//DTD report definition//EN//extended/version 0.8.5\"\n" + " \"http://jfreereport.sourceforge.net/extreport-085.dtd\">" ); } }
/** * Defines a DTD used to validate the report definition. Your XMLParser must be a validating parser for this feature * to work. * * @param systemId the system ID for the DTD. * @param publicID the public ID. * @param location the URL. * @return A boolean. */ public boolean setDTDLocation( final String publicID, final String systemId, final URL location ) { if ( isValid( location ) ) { this.dtds.put( publicID, location ); this.dtds.put( systemId, location ); return true; } else { logger.warn( "Validate location failed for " + publicID + " location: " + location ); return false; } }
dbf.setValidating( false ); final DocumentBuilder db = dbf.newDocumentBuilder(); db.setEntityResolver( ParserEntityResolver.getDefaultResolver() ); db.setErrorHandler( new LoggingErrorHandler() ); final ResourceDataInputSource input = new ResourceDataInputSource( data, manager );