public void importXML( String path, InputStream inputStream, int uuidBehavior, int rootBehavior, Map<String, String> replacements) throws IOException, InvalidSerializedDataException, RepositoryException { JCRNodeWrapper node = getNode(path); try { if (!node.isCheckedOut()) { checkout(node); } } catch (UnsupportedRepositoryOperationException ex) { // versioning not supported } DocumentViewImportHandler documentViewImportHandler = new DocumentViewImportHandler(this, path); documentViewImportHandler.setRootBehavior(rootBehavior); documentViewImportHandler.setUuidBehavior(uuidBehavior); documentViewImportHandler.setReplacements(replacements); try { SAXParserFactory factory; factory = new SAXParserFactoryImpl(); factory.setNamespaceAware(true); factory.setValidating(false); factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); SAXParser parser = factory.newSAXParser(); parser.parse(inputStream, documentViewImportHandler); } catch (SAXParseException e) { logger.error("Cannot import - File is not a valid XML", e); } catch (Exception e) { logger.error("Cannot import", e); } }