private ArchivoXmlUsuario(String rutaArchivo) throws JDOMException, IOException { SAXBuilder saxB = new SAXBuilder(); saxB.setIgnoringElementContentWhitespace(true); this.documento = saxB.build(rutaArchivo); this.raiz = this.documento.getRootElement(); this.ruta = rutaArchivo; }
public LocaleExtractor( MavenProjectInfo mavenProjectInfo, String manifestFileName, String phrescoTargetDir) throws Exception { try { System.setProperty( "javax.xml.parsers.SAXParserFactory", "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl"); builder = new SAXBuilder(); // disabling xml validation builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); loc = mavenProjectInfo.getBaseDir() + File.separator + phrescoTargetDir; loopDoc = builder.build( new File( mavenProjectInfo.getBaseDir() + mavenProjectInfo .getProject() .getProperties() .getProperty("phresco.theme.target.dir") + File.separator + mavenProjectInfo .getProject() .getProperties() .getProperty("phresco.theme.config.name"))); } catch (JDOMException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
public Map getEnvironmentDetails(MavenProjectInfo mavenProjectInfo, String phrescoTargetDir) throws JDOMException, IOException { System.setProperty( "javax.xml.parsers.SAXParserFactory", "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl"); builder = new SAXBuilder(); // disabling xml validation builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); envXML = builder.build( new File( mavenProjectInfo.getBaseDir() + File.separator + mavenProjectInfo .getProject() .getProperties() .getProperty("phresco.environment.xml.file.path"))); // Get server details List<Element> serverDetails = ((List<Element>) XPath.selectNodes(envXML, "//Server")); System.out.println("serverDetails => " + serverDetails); // Get database details List<Element> dbDetails = ((List<Element>) XPath.selectNodes(envXML, "//Database")); System.out.println("dbDetails => " + dbDetails); for (Element server : serverDetails) { stringEnvDetails.put("context", server.getChildText("context")); stringEnvDetails.put("deploy_dir", server.getChildText("deploy_dir")); } for (Element db : dbDetails) { stringEnvDetails.put("username", db.getChildText("username")); stringEnvDetails.put("password", db.getChildText("password")); stringEnvDetails.put("host", db.getChildText("host")); stringEnvDetails.put("dbname", db.getChildText("dbname")); } return stringEnvDetails; }