List of usage examples for org.jdom2.filter Filters text
public static final Filter<Text> text()
From source file:com.c4om.autoconf.ulysses.extra.svrlmultipathinterpreter.PartialNodeGenerator.java
License:Apache License
/** * Gets a list of selectable values from a single select from path. * @param singleSelectFromPath a path of the form <code>doc('mydoc')/mypath</code>, that points to the selectable values. * @return a {@link List} with the selectable values * @throws IOException If there are I/O errors while loading documents to select values from. * @throws JDOMException If there are problems at XML parsing while loading documents to select values from. *//*from w ww.j av a 2 s. c o m*/ private List<String> getSelectableValuesFromSinglePath(String singleSelectFromPath) throws JDOMException, IOException { String[] selectFromDocAndPath = divideDocAndPath(singleSelectFromPath); File documentFile = new File(selectFromDocAndPath[0]); if (!documentFile.isAbsolute()) { documentFile = new File(this.pathToConfiguration, selectFromDocAndPath[0]); } Document documentToSelectFrom = loadJDOMDocumentFromFile(documentFile); List<String> gatheredPossibleValues = new ArrayList<>(); if (selectFromDocAndPath[1].matches(".+/@[^@/]+$")) { //It is an attribute path List<Attribute> selectableValuesQueryResult = performJAXENXPath(selectFromDocAndPath[1], documentToSelectFrom, Filters.attribute(), xpathNamespaces); for (int i = 0; i < selectableValuesQueryResult.size(); i++) { gatheredPossibleValues.add(selectableValuesQueryResult.get(i).getValue()); } } else { //It is a text path List<Text> selectableValuesQueryResult = performJAXENXPath(selectFromDocAndPath[1], documentToSelectFrom, Filters.text(), xpathNamespaces); for (int i = 0; i < selectableValuesQueryResult.size(); i++) { gatheredPossibleValues.add(selectableValuesQueryResult.get(i).getTextNormalize()); } } return gatheredPossibleValues; }
From source file:com.c4om.autoconf.ulysses.extra.svrlmultipathinterpreter.SVRLMultipathInterpreterMain.java
License:Apache License
/** * This method gets a list of all the paths occurring in <code>//svrl:failed-assert/svrl:text</code>, as expected by SVRLMultipathInterpreterMain. * @param svrlDocument The SVRL document, as a JDOM2 {@link Document} * @return a {@link List} of {@link String}, with the paths. *///www . ja v a 2s . c o m private List<String> getPathsFromDocument(Document svrlDocument) { List<String> results = new ArrayList<>(); List<Namespace> namespaces = Arrays.asList(CommonXMLConstants.NAMESPACE_SVRL); List<Text> resultingTexts = performJAXENXPath("//svrl:failed-assert/svrl:text/text()", svrlDocument, Filters.text(), namespaces); for (Text resultingText : resultingTexts) { for (String untrimmedResult : resultingText.getText().split("[\r\n]+")) { String trimmedResult = untrimmedResult.trim(); if (!trimmedResult.equals("")) { results.add(trimmedResult); } } } return results; }
From source file:io.macgyver.plugin.ci.jenkins.decorators.GitHubDecorator.java
License:Apache License
@Override public void call(NodeInfo t1) { final XPathExpression<Text> githubProjectXPath = XPathFactory.instance().compile( "//com.coravy.hudson.plugins.github.GithubProjectProperty/projectUrl/text()", Filters.text()); JenkinsScanner c = ((JenkinsScanner) t1.getUserData()); Document d = c.getServiceClient().getJobConfig(t1.getNode().get("name").asText()); Optional<String> cloneUrl = extractText(d, "//hudson.plugins.git.UserRemoteConfig/url/text()"); Optional<String> projectUrl = extractText(d, "//com.coravy.hudson.plugins.github.GithubProjectProperty/projectUrl/text()"); List<String> tmp = Lists.newArrayList(); ObjectNode params = new ObjectMapper().createObjectNode(); if (projectUrl.isPresent()) { tmp.add("j.githubProjectUrl={projectUrl}"); params.put("projectUrl", stripTrailingSlash(projectUrl.get())); }/*from www.ja v a 2 s .c o m*/ if (cloneUrl.isPresent()) { tmp.add("j.githubCloneUrl={cloneUrl}"); params.put("cloneUrl", stripTrailingSlash(cloneUrl.get())); } if (!tmp.isEmpty()) { String clause = Joiner.on(", ").join(tmp); String cypher = "match (j:CIJob) where ID(j)={nodeId} SET " + clause + " return j"; params.put("nodeId", t1.getNodeId()); t1.getNeoRxClient().execCypher(cypher, params); } if (projectUrl.isPresent()) { String cypher = "match (j:CIJob) where ID(j)={nodeId} MERGE (s:SCMRepo {url:{projectUrl}, type:'github'}) MERGE (j)-[r:BUILDS]->(s)" + " ON CREATE set r.createTs=timestamp(), s.createTs=timestamp(), r.updateTs=timestamp(), s.updateTs=timestamp() " + " ON MATCH set r.updateTs=timestamp(), s.updateTs=timestamp()"; t1.getNeoRxClient().execCypher(cypher, params); } else if (cloneUrl.isPresent()) { String url = cloneUrl.get(); } }
From source file:io.macgyver.plugin.ci.jenkins.decorators.GitHubDecorator.java
License:Apache License
public Optional<String> extractText(Document d, String xpath) { XPathExpression<Text> expression = XPathFactory.instance().compile(xpath, Filters.text()); return getText(expression.evaluate(d)); }
From source file:org.mycore.frontend.editor.postprocessor.MCREditorPostProcessorXSL.java
License:Open Source License
public MCRJDOMContent transform(MCRContent source) throws IOException { try {// www . ja va 2 s. c om Element root = source.asXML().getRootElement().clone(); for (Iterator<Text> iter = root.getDescendants(Filters.text()).iterator(); iter.hasNext();) { Text text = iter.next(); text.setText(MCRXMLFunctions.normalizeUnicode(text.getText())); } return new MCRJDOMContent(root); } catch (JDOMException ex) { throw new IOException(ex); } catch (SAXException ex) { throw new IOException(ex); } }