@SuppressWarnings("deprecation") public void setItemDescription(String itemDescription) throws JDOMException, IOException, URISyntaxException { StringReader is = new StringReader(itemDescription); SAXBuilder sb = new SAXBuilder(); sb.setValidation(true); ClassLoader loader = Thread.currentThread().getContextClassLoader(); URL url = loader.getResource("../../xml/cloud.xsd"); File file = new File(url.toURI()); if (file != null) { sb.setProperty( "http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema"); sb.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", file); } Document dDoc = sb.build(is); Element dDocElm = dDoc.getRootElement().clone(); this.descElm.removeContent(); this.descElm.addContent(dDocElm); }
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; }