/** * Read mappings from a <tt>String</tt> * * @param xml an XML string */ public Configuration addXML(String xml) throws MappingException { if ( log.isDebugEnabled() ) log.debug( "Mapping XML:\n" + xml ); try { List errors = new ArrayList(); org.dom4j.Document doc = xmlHelper.createSAXReader( "XML String", errors, entityResolver ).read( new StringReader( xml ) ); if ( errors.size() != 0 ) throw new MappingException( "invalid mapping", ( Throwable ) errors.get( 0 ) ); add( doc ); } catch ( Exception e ) { log.error( "Could not configure datastore from XML", e ); throw new MappingException( e ); } return this; }
/** * Read mappings from a particular XML file * * @param xmlFile a path to a file */ public Configuration addFile(String xmlFile) throws MappingException { log.info( "Mapping file: " + xmlFile ); try { List errors = new ArrayList(); org.dom4j.Document doc = xmlHelper.createSAXReader( xmlFile, errors, entityResolver ).read( new File( xmlFile ) ); if ( errors.size() != 0 ) throw new MappingException( "invalid mapping", ( Throwable ) errors.get( 0 ) ); add( doc ); return this; } catch ( Exception e ) { log.error( "Could not configure datastore from file: " + xmlFile, e ); throw new MappingException( "Could not configure datastore from file: " + xmlFile, e ); } }
/** * Read mappings from an <tt>InputStream</tt> * * @param xmlInputStream an <tt>InputStream</tt> containing XML */ public Configuration addInputStream(InputStream xmlInputStream) throws MappingException { try { List errors = new ArrayList(); org.dom4j.Document doc = xmlHelper.createSAXReader( "XML InputStream", errors, entityResolver ).read( new InputSource( xmlInputStream ) ); if ( errors.size() != 0 ) throw new MappingException( "invalid mapping", ( Throwable ) errors.get( 0 ) ); add( doc ); return this; } catch ( MappingException me ) { throw me; } catch ( Exception e ) { log.error( "Could not configure datastore from input stream", e ); throw new MappingException( e ); } finally { try { xmlInputStream.close(); } catch ( IOException ioe ) { log.error( "could not close input stream", ioe ); } } }
try { List errors = new ArrayList(); doc = xmlHelper.createSAXReader( resourceName, errors, entityResolver ).read( new InputSource( stream ) ); if ( errors.size() != 0 ) throw new MappingException( "invalid configuration", ( Throwable ) errors.get( 0 ) );
/** * Disable xml file validation. */ @Override protected Configuration doConfigure(InputStream stream, String resourceName) throws HibernateException { try { @SuppressWarnings("rawtypes") List errors = new ArrayList(); SAXReader reader = xmlHelper.createSAXReader(resourceName, errors, this.getEntityResolver()); reader.setValidation(false); Document document = reader.read(new InputSource(stream)); if (errors.size() != 0) { throw new MappingException("invalid configuration", (Throwable) errors.get(0)); } doConfigure(document); } catch (DocumentException e) { throw new HibernateException("Could not parse configuration: " + resourceName, e); } finally { try { stream.close(); } catch (IOException ioe) { logger.warn("could not close input stream for: " + resourceName, ioe); } } return this; }
doc = xmlHelper.createSAXReader( xmlFile.getAbsolutePath(), errors, entityResolver ).read( xmlFile ); try { log.info( "Writing cached file of " + xmlFile + " to " + lazyfile );
try { List errors = new ArrayList(); SAXReader saxReader = xmlHelper.createSAXReader( "XML InputStream", errors, getEntityResolver() ); try { saxReader.setFeature( "http://apache.org/xml/features/validation/schema", true );
SAXReader saxReader = xmlHelper.createSAXReader( "XML InputStream", errors, cfg.getEntityResolver() ); try { saxReader.setFeature( "http://apache.org/xml/features/validation/schema", true );
SAXReader saxReader = xmlHelper.createSAXReader( "XML InputStream", errors, cfg.getEntityResolver() ); try { saxReader.setFeature( "http://apache.org/xml/features/validation/schema", true );
List errors = new ArrayList(); try { doc = xmlHelper.createSAXReader( xmlFile.getAbsolutePath(), errors, entityResolver ).read( xmlFile ); if ( errors.size() != 0 ) { throw new MappingException( "invalid mapping", ( Throwable ) errors.get( 0 ) );