List of usage examples for org.jdom2.input SAXBuilder build
@Override public Document build(final String systemId) throws JDOMException, IOException
This builds a document from the supplied URI.
From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java
License:Apache License
/** * //from w w w .j a va 2 s . c o m * ? ?? Chatper Data ? (data class : AnalyzeDefinition) * * @param writer * @param chapterE * @param cNum * @param pdf * @param builder * @param data * @param upload * @throws Exception */ public static void addChapterForDynamic(PdfWriter writer, Element chapterE, int cNum, Document pdf, SAXBuilder builder, AnalyzeDefinition data, Upload upload) throws Exception { //chapter xml File chapterXml = new File(PDFDocGenerator.class.getResource(chapterE.getText()).getFile()); org.jdom2.Document chapterDoc = builder.build(chapterXml); Element root = chapterDoc.getRootElement(); //?? ? ?? setting setDynamicSection(root, data, upload); //chapter ? Chapter chapter = PDFWriterUtil.getChapter(root.getAttributeValue("title"), cNum); PDFWriterUtil.setElement(writer, chapter, root); pdf.add(chapter); }
From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java
License:Apache License
/** * ? ?? Chatper Data ? (data class : PDFMetadataDefinition) * /*from ww w. j av a2s .c om*/ * @param writer * @param chapterE * @param cNum * @param pdf * @param builder * @param data * @param upload * @throws Exception */ public static void addChapterForDynamic(PdfWriter writer, Element chapterE, int cNum, Document pdf, SAXBuilder builder, PDFMetadataDefinition data, Upload upload) throws Exception { //chapter xml File chapterXml = new File(PDFDocGenerator.class.getResource(chapterE.getText()).getFile()); org.jdom2.Document chapterDoc = builder.build(chapterXml); Element root = chapterDoc.getRootElement(); //?? ? ?? setting setDynamicSection(root, data, upload); //chapter ? Chapter chapter = PDFWriterUtil.getChapter(root.getAttributeValue("title"), cNum); PDFWriterUtil.setElement(writer, chapter, root); pdf.add(chapter); }
From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java
License:Apache License
/** * //from ww w . ja v a 2s. c om * ? * * @param writer * @param chapterE * @param cNum * @param pdf * @param builder * @throws Exception */ public static void addChapter(PdfWriter writer, Element chapterE, int cNum, Document pdf, SAXBuilder builder) throws Exception { //chapter xml File chapterXml = new File(PDFDocGenerator.class.getResource(chapterE.getText()).getFile()); org.jdom2.Document chapterDoc = builder.build(chapterXml); //chapter ? Element root = chapterDoc.getRootElement(); Chapter chapter = PDFWriterUtil.getChapter(root.getAttributeValue("title"), cNum); PDFWriterUtil.setElement(writer, chapter, root); pdf.add(chapter); }
From source file:com.bc.ceres.binio.binx.BinX.java
License:Open Source License
private CompoundType parseDocument(URI uri) throws IOException, BinXException { SAXBuilder builder = new SAXBuilder(); Document document;//from w w w . ja v a2 s .c o m try { document = builder.build(uri.toURL()); } catch (JDOMException e) { throw new BinXException(MessageFormat.format("Failed to read ''{0}''", uri), e); } Element binxElement = document.getRootElement(); this.namespace = binxElement.getNamespace(); parseParameters(binxElement); parseDefinitions(binxElement); return parseDataset(binxElement); }
From source file:com.bc.ceres.jai.opimage.XmlRIF.java
License:Open Source License
private RenderedImage create(URI location, Map<String, Object> configuration, RenderingHints renderingHints) throws JDOMException, IOException, IllegalArgumentException { configuration = new HashMap<String, Object>(configuration); SAXBuilder builder = new SAXBuilder(); Document document = builder.build(location.toURL()); Element rootElement = document.getRootElement(); Map<String, Element> sourceMap = getElementMap(rootElement, ENAME_SOURCE); Map<String, Element> parameterMap = getElementMap(rootElement, ENAME_PARAMETER); Element targetElement = rootElement.getChild(ENAME_TARGET); return parseImage(targetElement, sourceMap, parameterMap, configuration, renderingHints, "rendered"); }
From source file:com.bennavetta.util.tycho.impl.DefaultWrapperGenerator.java
License:Apache License
private void writeModules(List<String> modules, File pomFile) throws JDOMException, IOException { SAXBuilder builder = new SAXBuilder(); Document pom = builder.build(pomFile); Namespace pomNs = pom.getRootElement().getNamespace(); Element modulesElem = pom.getRootElement().getChild("modules", pomNs); if (modulesElem == null) { modulesElem = new Element("modules", pomNs); pom.getRootElement().addContent(modulesElem); }//from w w w . java 2s . com for (String module : modules) { boolean exists = false; for (Element existingModule : modulesElem.getChildren()) { if (existingModule.getTextTrim().equals(module)) { exists = true; break; } } if (!exists) { Element moduleElem = new Element("module", pomNs); moduleElem.setText(module); modulesElem.addContent(moduleElem); } } XMLOutputter xout = new XMLOutputter(Format.getPrettyFormat().setIndent("\t")); try (FileOutputStream out = new FileOutputStream(pomFile)) { xout.output(pom, out); } }
From source file:com.bennavetta.util.tycho.Main.java
License:Apache License
private int run(String[] args) throws Exception { CmdLineParser parser = new CmdLineParser(this); try {/*from w ww .j a va 2s.com*/ parser.parseArgument(args); if (logLevel != null) { ThreadContext.put(LOGGING_PROP, logLevel.toUpperCase()); } if (version) { String version = Config.get(Config.VERSION); String aetherVersion = Config.get(Config.AETHER_VERSION); String mavenVersion = Config.get(Config.MAVEN_VERSION); String gradleVersion = Config.get(Config.GRADLE_VERSION); Date built = new Date(Long.parseLong(Config.get(Config.BUILD_TIMESTAMP))); System.out.println("Tycho Generator version: " + version); System.out.println("Sonatype Aether version: " + aetherVersion); System.out.println("Apache Maven version: " + mavenVersion); String builtDate = new SimpleDateFormat("dd MMMM yyyy").format(built); String builtTime = new SimpleDateFormat("hh:mm:ss.SSS aa").format(built); System.out.println("Built by Gradle " + gradleVersion + " on " + builtDate + " at " + builtTime); } else if (configFile == null) { throw new CmdLineException(parser, "No config file given"); } else { SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(configFile); WrapRequest request = new XmlWrapDescriptorParser().createRequest(doc); WrapperGenerator generator = new DefaultWrapperGenerator(); generator.generate(request); } return 0; } catch (CmdLineException e) { String invocation = "tycho-gen-" + Config.get(Config.VERSION) + "-dist.jar"; // tell the user what was wrong with the arguments System.err.println(e.getMessage()); // show usage information System.err.println("Usage: java -jar " + invocation + " [options] config-file"); parser.printUsage(System.err); // show an example System.err.println(); System.err.println(" Example: java -jar " + invocation + parser.printExample(ExampleMode.REQUIRED) + " myconfig.xml"); return 1; } }
From source file:com.c4om.autoconf.ulysses.extra.svrlinterpreter.SVRLInterpreterMain.java
License:Apache License
/** * Constructor//from ww w . ja v a2 s . co m * @param file {@link SVRLInterpreterMain#file} * @param metamodelPath {@link SVRLInterpreterMain#metamodelPath} */ public SVRLInterpreterMain(String file, String metamodelPath) throws IOException, JDOMException { this.metamodelPath = metamodelPath; SAXBuilder builder = new SAXBuilder(); InputStream is; if (file.equals("--")) { is = System.in; } else { File fileFile = new File(file); if (!fileFile.exists()) { throw new FileNotFoundException("File \"" + file + "\" does not exist."); } is = new FileInputStream(fileFile); } this.document = builder.build(is); }
From source file:com.c4om.autoconf.ulysses.extra.svrlinterpreter.SVRLInterpreterProcessor.java
License:Apache License
/** * Method that actually performs the process * @param intermediateResults a list of intermediate results. * @return the resulting report/*from w ww. j ava2 s . c om*/ * @throws SaxonApiException if a XQuery query fails. * @throws IOException required by internal methods, but it will never be thrown (normally) * @throws JDOMException if there are problems at XML Parsing */ public Document process(List<List<String>> intermediateResults) throws SaxonApiException, JDOMException, IOException { SAXBuilder builder = new SAXBuilder(); Element rootElement = new Element("report", NAMESPACE_SVRL_INTERPETER_REPORT); Document result = new Document(rootElement); Map<String, List<Element>> queryCache = performXPathMetamodelSuggestionQueries( listOfListsToSingleList(intermediateResults, 0)); for (int i = 0; i < intermediateResults.size(); i++) { List<String> intermediateResult = intermediateResults.get(i); Element currentDiscrepancyElement = new Element("discrepancy", NAMESPACE_SVRL_INTERPETER_REPORT); rootElement.addContent(currentDiscrepancyElement); String partialNodeString = saxonQuery(intermediateResult.get(1)); Reader partialNodeStringReader = new StringReader(partialNodeString); Document partialNodeDoc = builder.build(partialNodeStringReader); Element partialNode = partialNodeDoc.getRootElement().detach(); Element currentInterestingPathsElement = new Element("interestingPaths", NAMESPACE_SVRL_INTERPETER_REPORT); moveAndRemoveNSOfAttr(partialNode, currentInterestingPathsElement, "mandatory-path", NAMESPACE_SVRL_INTERPETER_REPORT); moveAndRemoveNSOfAttr(partialNode, currentInterestingPathsElement, "base-path", NAMESPACE_SVRL_INTERPETER_REPORT); moveAndRemoveNSOfAttr(partialNode, currentInterestingPathsElement, "key-subpath", NAMESPACE_SVRL_INTERPETER_REPORT); moveAndRemoveNSOfAttr(partialNode, currentInterestingPathsElement, "search-path", NAMESPACE_SVRL_INTERPETER_REPORT); currentDiscrepancyElement.addContent(currentInterestingPathsElement); Element currentSuggestedPartialNodeElement = new Element("suggestedPartialNode", NAMESPACE_SVRL_INTERPETER_REPORT); currentDiscrepancyElement.addContent(currentSuggestedPartialNodeElement); currentSuggestedPartialNodeElement.addContent(partialNode); Element currentMetamodelSuggestionsElement = new Element("metamodelSuggestions", NAMESPACE_SVRL_INTERPETER_REPORT); currentDiscrepancyElement.addContent(currentMetamodelSuggestionsElement); List<Element> queryResults = queryCache.get(intermediateResult.get(0)); for (Element queryResult : queryResults) { currentMetamodelSuggestionsElement.addContent(queryResult.clone()); } } return result; }
From source file:com.c4om.utils.xmlutils.JDOMUtils.java
License:Apache License
/** * Loads a XML file from a stream as a JDOM Document * @param is the input stream/* w ww. j a va 2s. c om*/ * @return the loaded document * @throws IOException Input/Output errors. * @throws JDOMException Errors at XML parsing. */ public static Document loadJDOMDocumentFromStream(InputStream is) throws JDOMException, IOException { SAXBuilder builder = new SAXBuilder(); return builder.build(is); }