List of usage examples for org.dom4j.io SAXReader read
public Document read(InputSource in) throws DocumentException
Reads a Document from the given InputSource
using SAX
From source file:com.googlecode.starflow.engine.xml.Dom4jProcDefParser.java
License:Apache License
/** * ??/* www . j av a 2 s . c om*/ * * @param document * @param activityDefId * @return */ public static List<Element> parserTransitionInfo(String processDefContent, String activityDefId) { SAXReader reader = new SAXReader(); Document document = null; List<Element> list = null; try { document = reader.read(new StringReader(processDefContent)); list = parserTransitionInfoFromTo(document, activityDefId); } catch (Exception e) { throw new StarFlowParserException("???", e); } return list; }
From source file:com.googlecode.starflow.engine.xml.ProcessDefineParser.java
License:Apache License
public static Document createDocument(String xml) { SAXReader reader = new SAXReader(); Document document = null;// ww w.j a v a 2 s.com try { document = reader.read(new StringReader(xml)); } catch (Exception e) { throw new StarFlowParserException("???", e); } return document; }
From source file:com.gote.importexport.ExportTournamentForOpenGotha.java
License:Apache License
/** * Build a Document object from File content * /* w w w . j a v a 2 s. c om*/ * @param pContent String * @return Document */ private Document getDocumentFromContent(String pContent) { SAXReader reader = new SAXReader(); try { return reader.read(new StringReader(pContent)); } catch (DocumentException e) { LOGGER.log(Level.SEVERE, "DocumentException, creation stopped : " + e); return null; } }
From source file:com.gote.importexport.ImportTournamentFromGOTE.java
License:Apache License
@Override public Tournament createTournamentFromConfig(File pFile) { LOGGER.log(Level.INFO, "Loading tournament from file " + pFile); Tournament tournament = new Tournament(); String content = ImportExportUtil.getFileContent(pFile); if (content == null) { LOGGER.log(Level.SEVERE, "File \"" + pFile.getPath() + "\" content is null"); return null; }//from ww w. jav a 2 s . c om SAXReader reader = new SAXReader(); Document document; try { document = reader.read(new StringReader(content)); } catch (DocumentException e) { LOGGER.log(Level.SEVERE, "DocumentException, creation stopped : " + e); return null; } Element pElementTournament = document.getRootElement(); boolean initSuccess = initTournament(tournament, pElementTournament); if (initSuccess) { return tournament; } else { return null; } }
From source file:com.gote.importexport.ImportTournamentFromOpenGotha.java
License:Apache License
@Override public Tournament createTournamentFromConfig(File pFile) { LOGGER.log(Level.INFO, "A new tournament is going to be created from the file : " + pFile.getPath()); Tournament tournament = new Tournament(); String content = ImportExportUtil.getFileContent(pFile); if (content == null) { LOGGER.log(Level.SEVERE, "File \"" + pFile.getPath() + "\" content is null"); return null; }//from ww w .java 2 s. c o m SAXReader reader = new SAXReader(); Document document; try { document = reader.read(new StringReader(content)); } catch (DocumentException e) { LOGGER.log(Level.SEVERE, "DocumentException, creation stopped : " + e); return null; } Element pElementTournament = document.getRootElement(); boolean initSuccess = initTournament(tournament, pElementTournament); if (initSuccess) { return tournament; } else { return null; } }
From source file:com.haulmont.bali.util.Dom4j.java
License:Apache License
public static Document readDocument(Reader reader) { SAXReader xmlReader = getSaxReader(); try {//from w w w . java 2 s. c om return xmlReader.read(reader); } catch (DocumentException e) { throw new RuntimeException("Unable to read XML from reader", e); } }
From source file:com.haulmont.bali.util.Dom4j.java
License:Apache License
public static Document readDocument(InputStream stream) { SAXReader xmlReader = getSaxReader(); try {/*from w w w. j ava 2 s . co m*/ return xmlReader.read(stream); } catch (DocumentException e) { throw new RuntimeException("Unable to read XML from stream", e); } }
From source file:com.haulmont.chile.core.datatypes.Datatypes.java
License:Apache License
private Datatypes() { SAXReader reader = new SAXReader(); URL resource = Datatypes.class.getResource("/datatypes.xml"); if (resource == null) { log.info("Can't find /datatypes.xml, using default datatypes settings"); resource = Datatypes.class.getResource("/com/haulmont/chile/core/datatypes/datatypes.xml"); }/*from w ww . j av a 2s.co m*/ try { Document document = reader.read(resource); Element element = document.getRootElement(); List<Element> datatypeElements = element.elements("datatype"); for (Element datatypeElement : datatypeElements) { String datatypeClassName = datatypeElement.attributeValue("class"); try { Datatype datatype; Class<Datatype> datatypeClass = ReflectionHelper.getClass(datatypeClassName); try { final Constructor<Datatype> constructor = datatypeClass.getConstructor(Element.class); datatype = constructor.newInstance(datatypeElement); } catch (Throwable e) { datatype = datatypeClass.newInstance(); } __register(datatype); } catch (Throwable e) { log.error(String.format("Fail to load datatype '%s'", datatypeClassName), e); } } } catch (DocumentException e) { log.error("Fail to load datatype settings", e); } }
From source file:com.haulmont.cuba.core.sys.AbstractViewRepository.java
License:Apache License
protected void addFile(Element commonRootElem, String fileName) { if (readFileNames.contains(fileName)) return;//from w w w. j a v a 2s.co m log.debug("Deploying views config: " + fileName); readFileNames.add(fileName); InputStream stream = null; try { stream = resources.getResourceAsStream(fileName); if (stream == null) { throw new IllegalStateException("Resource is not found: " + fileName); } SAXReader reader = new SAXReader(); Document doc; try { doc = reader.read(new InputStreamReader(stream, StandardCharsets.UTF_8)); } catch (DocumentException e) { throw new RuntimeException("Unable to parse view file " + fileName, e); } Element rootElem = doc.getRootElement(); for (Element includeElem : Dom4j.elements(rootElem, "include")) { String incFile = includeElem.attributeValue("file"); if (!StringUtils.isBlank(incFile)) addFile(commonRootElem, incFile); } for (Element viewElem : Dom4j.elements(rootElem, "view")) { commonRootElem.add(viewElem.createCopy()); } } finally { IOUtils.closeQuietly(stream); } }
From source file:com.haulmont.cuba.core.sys.AbstractViewRepository.java
License:Apache License
public void deployViews(Reader xml) { lock.readLock().lock();/*from w w w . j ava 2 s . c o m*/ try { checkInitialized(); } finally { lock.readLock().unlock(); } SAXReader reader = new SAXReader(); Document doc; try { doc = reader.read(xml); } catch (DocumentException e) { throw new RuntimeException("Unable to read views xml", e); } Element rootElem = doc.getRootElement(); for (Element includeElem : Dom4j.elements(rootElem, "include")) { String file = includeElem.attributeValue("file"); if (!StringUtils.isBlank(file)) deployViews(file); } for (Element viewElem : Dom4j.elements(rootElem, "view")) { deployView(rootElem, viewElem); } }