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

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

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

Node.getPath介绍

[英]Returns the XPath expression which will return a node set containing the given node such as /a/b/@c. No indexing will be used to restrict the path if multiple elements with the same name occur on the path.
[中]返回XPath表达式,该表达式将返回包含给定节点(如/a/b/@c)的节点集。如果路径上出现多个同名元素,则不会使用索引来限制路径。

代码示例

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

  1. private void addLoopXPath( Node node, IProgressMonitor monitor ) {
  2. Element ce = (Element) node;
  3. monitor.worked( 1 );
  4. // List child
  5. for ( int j = 0; j < ce.nodeCount(); j++ ) {
  6. if ( monitor.isCanceled() ) {
  7. return;
  8. }
  9. Node cnode = ce.node( j );
  10. if ( !Utils.isEmpty( cnode.getName() ) ) {
  11. Element cce = (Element) cnode;
  12. if ( !listpath.contains( cnode.getPath() ) ) {
  13. nr++;
  14. monitor.subTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.FetchNodes",
  15. String.valueOf( nr ) ) );
  16. monitor.subTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.AddingNode",
  17. cnode.getPath() ) );
  18. listpath.add( cnode.getPath() );
  19. }
  20. // let's get child nodes
  21. if ( cce.nodeCount() > 1 ) {
  22. addLoopXPath( cnode, monitor );
  23. }
  24. }
  25. }
  26. }

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

  1. return null;
  2. if ( !listpath.contains( node.getPath() ) ) {
  3. nr++;
  4. monitor.subTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.FetchNodes",
  5. String.valueOf( nr ) ) );
  6. monitor.subTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.AddingNode", node
  7. .getPath() ) );
  8. listpath.add( node.getPath() );
  9. addLoopXPath( node, monitor );

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

  1. .valueOf( nr ) ) );
  2. monitor.subTask( BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Task.FetchNodes", node
  3. .getPath() ) );
  4. setNodeField( node, monitor );
  5. childNode( node, monitor );

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

  1. String nodenametxt = cleanString( node.getPath() );

代码示例来源:origin: quickfix-j/quickfixj

  1. private String getSingleNodeTextSafe(Node node, String tag) {
  2. Node nodeWithTag = node.selectSingleNode(tag);
  3. if(nodeWithTag != null)
  4. return nodeWithTag.getText();
  5. else
  6. throw new RuntimeException("Node with tag "+tag+" not found in "+node.getPath());
  7. }

代码示例来源:origin: org.quickfixj/quickfixj-all

  1. private String getSingleNodeTextSafe(Node node, String tag) {
  2. Node nodeWithTag = node.selectSingleNode(tag);
  3. if(nodeWithTag != null)
  4. return nodeWithTag.getText();
  5. else
  6. throw new RuntimeException("Node with tag "+tag+" not found in "+node.getPath());
  7. }

代码示例来源:origin: org.quickfixj/quickfixj-dictgenerator

  1. private String getSingleNodeTextSafe(Node node, String tag) {
  2. Node nodeWithTag = node.selectSingleNode(tag);
  3. if(nodeWithTag != null)
  4. return nodeWithTag.getText();
  5. else
  6. throw new RuntimeException("Node with tag "+tag+" not found in "+node.getPath());
  7. }

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

  1. protected void testNodePath(Node node) {
  2. String path = node.getPath();
  3. log("Path: " + path + " node: " + node);
  4. }
  5. }

代码示例来源:origin: gradle.plugin.org.jamgo/eclipselink-plugin

  1. private void createTemporaryPersistenceInfo(List<String> entityClassNames) throws DocumentException, IOException {
  2. SAXReader reader = new SAXReader();
  3. Document persistenceXmlDocument = reader.read(Resources.asCharSource(Resources.getResource("empty-persistence.xml"), Charsets.UTF_8).openStream());
  4. Node persistenceUnitNode = persistenceXmlDocument.selectSingleNode("//*[name()='persistence-unit']");
  5. this.logger.debug(persistenceUnitNode.getPath());
  6. if (persistenceUnitNode != null) {
  7. this.logger.debug("persistence-unit found");
  8. for (String eachEntityClassName : entityClassNames) {
  9. Element classElement = ((Element) persistenceUnitNode).addElement("class");
  10. classElement.setText(eachEntityClassName);
  11. }
  12. }
  13. GFileUtils.mkdirs(new File(this.getTemporaryDir().getAbsolutePath() + "/META-INF"));
  14. File temporaryPersistenceInfoFile = new File(this.getTemporaryDir().getAbsolutePath() + "/META-INF/persistence.xml");
  15. Writer writer = new FileWriter(temporaryPersistenceInfoFile);
  16. OutputFormat format = OutputFormat.createPrettyPrint();
  17. XMLWriter xmlWriter = new XMLWriter(writer, format);
  18. xmlWriter.write(persistenceXmlDocument);
  19. xmlWriter.close();
  20. }

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

  1. Node node = (Node) nodeIterator.next();
  2. String name = node.getText();
  3. if ( name.startsWith( "%" ) && !node.getPath().endsWith( "/text()" ) ) { //$NON-NLS-1$ //$NON-NLS-2$
  4. try {
  5. String localeText = getLocaleString( name, baseName, file, true );

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

  1. protected void testPath(Node node, String path, String uniquePath) {
  2. assertEquals("getPath expression should be what is expected", path,
  3. node.getPath());
  4. assertEquals("getUniquePath expression should be what is expected",
  5. uniquePath, node.getUniquePath());
  6. }

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

  1. protected void testRelativePath(Element context, Node node, String pathRel,
  2. String uniquePathRel) {
  3. assertEquals("relative getPath expression should be what is expected",
  4. pathRel, node.getPath(context));
  5. assertEquals("relative getUniquePath expression not correct",
  6. uniquePathRel, node.getUniquePath(context));
  7. }

相关文章