org.dom4j.Node.selectNodes()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(425)

本文整理了Java中org.dom4j.Node.selectNodes()方法的一些代码示例,展示了Node.selectNodes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.selectNodes()方法的具体详情如下:
包路径:org.dom4j.Node
类名称:Node
方法名:selectNodes

Node.selectNodes介绍

[英]selectNodes evaluates an XPath expression and returns the result as a List of Node instances or String instances depending on the XPath expression.
[中]selectNodes对XPath表达式求值,并根据XPath表达式返回Node实例或String实例的List结果。

代码示例

代码示例来源:origin: spotbugs/spotbugs

  1. @SuppressWarnings("unchecked")
  2. public static <T> List<T> selectNodes(Node node, String arg0) {
  3. return (List<T>)node.selectNodes(arg0);
  4. }

代码示例来源:origin: igniterealtime/Openfire

  1. private Map<String, String> readInitParams(Node configData) {
  2. Map<String, String> paramMap = new HashMap<>();
  3. List<Node> params = configData.selectNodes("init-params/init-param");
  4. for (Node param : params) {
  5. String paramName = param.selectSingleNode("param-name").getStringValue();
  6. String paramValue = param.selectSingleNode("param-value").getStringValue();
  7. paramMap.put(paramName, paramValue);
  8. }
  9. return paramMap;
  10. }

代码示例来源:origin: com.atlassian.bamboo.plugins.dotnet/atlassian-bamboo-plugin-dotnet

  1. @NotNull
  2. private static Map<String, Node> cacheUnitTestNodes(final Node document, final String namespacePrefix)
  3. {
  4. final Map<String, Node> cachedTestInfo = new HashMap<>();
  5. final List<Element> cachedNodes = document.selectNodes("//" + namespacePrefix + "UnitTest");
  6. for (final Element e : cachedNodes)
  7. {
  8. cachedTestInfo.put(e.attributeValue("id"), e);
  9. }
  10. return cachedTestInfo;
  11. }

代码示例来源:origin: org.craftercms/crafter-core

  1. /**
  2. * Executes the specified XPath query as a multiple node query, returning the text values of the resulting list of
  3. * nodes.
  4. */
  5. @SuppressWarnings("unchecked")
  6. public static List<String> selectNodeValues(Node node, String xpathQuery) {
  7. List<Node> resultNodes = node.selectNodes(xpathQuery);
  8. return extractNodeValues(resultNodes);
  9. }

代码示例来源:origin: com.atlassian.plugins/atlassian-plugins-core

  1. private void evaluate(Node e, List<String> errors) {
  2. @SuppressWarnings("unchecked")
  3. List<Node> contexts = e.selectNodes(contextPattern);
  4. if (contexts != null && contexts.size() > 0) {
  5. for (Node ctxNode : contexts) {
  6. for (RuleTest test : tests) {
  7. test.evaluate(ctxNode, errors);
  8. }
  9. }
  10. }
  11. }
  12. }

代码示例来源:origin: stackoverflow.com

  1. String getAllTextContent(Node node) {
  2. List<Node> nodes = node.selectNodes("descendant-or-self::text()");
  3. StringBuilder buf = new StringBuilder();
  4. for ( Node n : nodes ) {
  5. buf.append(n.getText());
  6. }
  7. return buf.toString();
  8. }
  9. // usage
  10. System.out.println(getAllTextContent(doc.selectSingleNode("//sentence")));

代码示例来源:origin: USPTO/PatentPublicData

  1. private void continuationPart(Node fragmentNode) {
  2. @SuppressWarnings("unchecked")
  3. List<Node> continuationPartN = fragmentNode.selectNodes("continuations/continuation-in-part-of/parent-child");
  4. for (Node continuationPart : continuationPartN) {
  5. readIds(continuationPart, DocumentIdType.CONTINUATION_IN_PART);
  6. }
  7. }

代码示例来源:origin: USPTO/PatentPublicData

  1. private void contionationOf(Node fragmentNode) {
  2. @SuppressWarnings("unchecked")
  3. List<Node> continuationN = fragmentNode.selectNodes("continuations/continuation-of/parent-child");
  4. for (Node continuation : continuationN) {
  5. readIds(continuation, DocumentIdType.CONTINUATION);
  6. }
  7. }

代码示例来源:origin: USPTO/PatentPublicData

  1. private List<String> getValues(String mathMLString) {
  2. List<String> values = new ArrayList<String>();
  3. List<Node> textNodes = mathNode.selectNodes("//*[text()]");
  4. for (Node node : textNodes) {
  5. String value = node.getText().trim();
  6. if (!value.isEmpty() && !"=".equals(value)) {
  7. values.add(value);
  8. }
  9. }
  10. return values;
  11. }

代码示例来源:origin: pentaho/pentaho-platform

  1. public void setPaintSequence( final Node paletteNode ) {
  2. if ( paletteNode != null ) {
  3. List colorNodes = paletteNode.selectNodes( ChartDefinition.COLOR_NODE_NAME );
  4. Paint[] paints = new Paint[colorNodes.size()];
  5. for ( int i = 0; i < colorNodes.size(); i++ ) {
  6. paints[i] = JFreeChartEngine.getPaint( (Node) colorNodes.get( i ) );
  7. }
  8. setPaintSequence( paints );
  9. }
  10. }

代码示例来源:origin: pentaho/pentaho-platform

  1. public void setPaintSequence( final Node paletteNode ) {
  2. if ( paletteNode != null ) {
  3. List colorNodes = paletteNode.selectNodes( ChartDefinition.COLOR_NODE_NAME );
  4. Paint[] paints = new Paint[colorNodes.size()];
  5. for ( int i = 0; i < colorNodes.size(); i++ ) {
  6. paints[i] = JFreeChartEngine.getPaint( (Node) colorNodes.get( i ) );
  7. }
  8. setPaintSequence( paints );
  9. }
  10. }

代码示例来源:origin: pentaho/pentaho-platform

  1. public void setPaintSequence( final Node paletteNode ) {
  2. if ( paletteNode != null ) {
  3. List colorNodes = paletteNode.selectNodes( ChartDefinition.COLOR_NODE_NAME );
  4. Paint[] paints = new Paint[colorNodes.size()];
  5. for ( int i = 0; i < colorNodes.size(); i++ ) {
  6. paints[i] = JFreeChartEngine.getPaint( (Node) colorNodes.get( i ) );
  7. }
  8. setPaintSequence( paints );
  9. }
  10. }

代码示例来源:origin: pentaho/pentaho-platform

  1. public void setBarSeries( final Node barSeriesNode ) {
  2. if ( barSeriesNode != null ) {
  3. List barNodes = barSeriesNode.selectNodes( BarLineChartDefinition.SERIES_NODE_NAME );
  4. String[] bars = new String[barNodes.size()];
  5. for ( int i = 0; i < barNodes.size(); i++ ) {
  6. Node barNode = (Node) barNodes.get( i );
  7. bars[i] = barNode.getText();
  8. }
  9. setBarColumns( bars );
  10. }
  11. }

代码示例来源:origin: pentaho/pentaho-platform

  1. public void setLineSeries( final Node lineSeriesNode ) {
  2. if ( lineSeriesNode != null ) {
  3. List lineNodes = lineSeriesNode.selectNodes( BarLineChartDefinition.SERIES_NODE_NAME );
  4. String[] lines = new String[lineNodes.size()];
  5. for ( int i = 0; i < lineNodes.size(); i++ ) {
  6. Node lineNode = (Node) lineNodes.get( i );
  7. lines[i] = lineNode.getText();
  8. }
  9. setLineColumns( lines );
  10. }
  11. }

代码示例来源:origin: pentaho/pentaho-platform

  1. public void setPaintSequence( final Node paletteNode ) {
  2. if ( paletteNode != null ) {
  3. List colorNodes = paletteNode.selectNodes( ChartDefinition.COLOR_NODE_NAME );
  4. Paint[] paints = new Paint[colorNodes.size()];
  5. for ( int i = 0; i < colorNodes.size(); i++ ) {
  6. paints[i] = JFreeChartEngine.getPaint( (Node) colorNodes.get( i ) );
  7. }
  8. setPaintSequence( paints );
  9. }
  10. }

代码示例来源:origin: pentaho/pentaho-platform

  1. public void setPaintSequence( final Node paletteNode ) {
  2. if ( paletteNode != null ) {
  3. List colorNodes = paletteNode.selectNodes( ChartDefinition.COLOR_NODE_NAME );
  4. Paint[] paints = new Paint[colorNodes.size()];
  5. for ( int i = 0; i < colorNodes.size(); i++ ) {
  6. paints[i] = JFreeChartEngine.getPaint( (Node) colorNodes.get( i ) );
  7. }
  8. setPaintSequence( paints );
  9. }
  10. }

代码示例来源:origin: pentaho/pentaho-platform

  1. public void setPaintSequence( final Node paletteNode ) {
  2. if ( paletteNode != null ) {
  3. List colorNodes = paletteNode.selectNodes( ChartDefinition.COLOR_NODE_NAME );
  4. Paint[] paints = new Paint[colorNodes.size()];
  5. for ( int i = 0; i < colorNodes.size(); i++ ) {
  6. paints[i] = JFreeChartEngine.getPaint( (Node) colorNodes.get( i ) );
  7. }
  8. setPaintSequence( paints );
  9. }
  10. }

代码示例来源:origin: com.googlecode.cernunnos/cernunnos

  1. public void perform(TaskRequest req, TaskResponse res) {
  2. Node srcNode = (Node) source.evaluate(req, res);
  3. List nodes = srcNode.selectNodes((String) xpath.evaluate(req, res));
  4. String name = (String) attribute_name.evaluate(req, res);
  5. for (Iterator it = nodes.iterator(); it.hasNext();) {
  6. Node n = (Node) it.next();
  7. res.setAttribute(name, n);
  8. super.performSubtasks(req, res);
  9. }
  10. }

代码示例来源:origin: USPTO/PatentPublicData

  1. public ClassificationItem parse(Document document) {
  2. Node parentClassItemN = document.selectSingleNode("/class-scheme/classification-item");
  3. ClassificationItem parentClassItem = readClassificationItem(parentClassItemN, null);
  4. List<Node> childClassItems = parentClassItemN.selectNodes("classification-item");
  5. for (Node childClass: childClassItems){
  6. readClassificationItem(childClass, parentClassItem);
  7. }
  8. return parentClassItem;
  9. }

代码示例来源:origin: USPTO/PatentPublicData

  1. private void divisionOf(Node fragmentNode) {
  2. @SuppressWarnings("unchecked")
  3. List<Node> divisionalN = fragmentNode.selectNodes("division-of/parent-child");
  4. for (Node divisional : divisionalN) {
  5. readIds(divisional, DocumentIdType.DIVISION);
  6. Node parentPNode = divisional.selectSingleNode("parent-patent");
  7. if (parentPNode != null) {
  8. DocumentId documentId = new DocumentIdNode(parentPNode).read();
  9. relatedDocIds.add(documentId);
  10. }
  11. }
  12. }

相关文章