Package org.jdom2.xpath

Examples of org.jdom2.xpath.XPathFactory


                Document document = domBuilder.build((org.w3c.dom.Document) node);
                return document.getRootElement();
            }
        }
        // we have no other option than to transform
        JDOMResult jdomResult = new JDOMResult();
        transform(source, jdomResult);
        return jdomResult.getDocument().getRootElement();
    }
View Full Code Here


    }

    @Override
    protected Source createResponsePayload(MethodParameter returnType, Object returnValue) {
        Element returnedElement = (Element) returnValue;
        return new JDOMSource(returnedElement);
    }
View Full Code Here

    @Override
    public final Source invoke(Source request) throws Exception {
        Element requestElement = getDocumentElement(request);
        Element responseElement = invokeInternal(requestElement);
        return responseElement != null ? new JDOMSource(responseElement) : null;
    }
View Full Code Here

    {
        StringBuffer sb = new StringBuffer();
       
        try
        {
            XPath xp = XPath.newInstance( ALL_TEXT_NODES );
       
            List nodes = xp.selectNodes(m_document.getDocument());
           
            for( Iterator i = nodes.iterator(); i.hasNext(); )
            {
                Object el = i.next();
               
View Full Code Here

        while( resources.hasMoreElements() ) {
                  URL resource = resources.nextElement();
                 
                  log.debug( "reading " + resource.toString() );
                  Document doc = builder.build( resource );
                  XPathFactory xpfac = XPathFactory.instance();
                  XPathExpression< Element > xp = xpfac.compile( requestedNodes, Filters.element() );
                  readed.addAll( xp.evaluate( doc ) ); // filter out repeated items
              }
        return new ArrayList< Element >( readed );
      } catch ( IOException ioe ) {
        log.error( "Couldn't load all " + xml + " resources", ioe );
View Full Code Here

  public static List< Element > parse( InputStream xmlStream, String requestedNodes ) {
    if( xmlStream != null && StringUtils.isNotEmpty( requestedNodes ) ) {
      SAXBuilder builder = new SAXBuilder();
      try {
                Document doc = builder.build( xmlStream );
                XPathFactory xpfac = XPathFactory.instance();
                XPathExpression< Element > xp = xpfac.compile( requestedNodes, Filters.element() );
               
        return xp.evaluate( doc );
      } catch ( IOException ioe ) {
        log.error( "Couldn't load all " + xmlStream + " resources", ioe );
      } catch ( JDOMException jdome ) {
View Full Code Here

  public void invoke(MavenProject mavenProject, final Map<String, Object> models, final ResultCollector resultCollector) {
   
    final Document document = (Document) models.get("jdom2");
   
    final XPathFactory xpathFactory = XPathFactory.instance();
    final Filter<LocatedElement> filter = Filters.fclass(LocatedElement.class);
    Namespace mavenNamespace = Namespace.getNamespace("m", "http://maven.apache.org/POM/4.0.0");
    final XPathExpression<LocatedElement> dependenciesXpath = xpathFactory.compile("/m:project/m:dependencies/m:dependency", filter, null, mavenNamespace);
    final XPathExpression<LocatedElement> managedDependenciesXpath = xpathFactory.compile("/m:project/m:dependencyManagement/m:dependency", filter, null, mavenNamespace);
   
    final List<LocatedElement> dependencies = dependenciesXpath.evaluate(document);
    final List<LocatedElement> managedDependencies = managedDependenciesXpath.evaluate(document);
   
   
View Full Code Here

        Enumeration< URL > resources = XmlUtil.class.getClassLoader().getResources( xml );
        while( resources.hasMoreElements() ) {
                  URL resource = resources.nextElement();
                  log.debug( "reading " + resource.toString() );
                  Document doc = builder.build( resource );
                  XPathFactory xpfac = XPathFactory.instance();
                  XPathExpression<Element> xp = xpfac.compile( requestedNodes, Filters.element() );
                  readed.addAll( xp.evaluate( doc ) ); // filter out repeated items
              }
        return new ArrayList<Element>( readed );
      } catch ( IOException ioe ) {
        log.error( "Couldn't load all " + xml + " resources", ioe );
View Full Code Here

  {
    if( xmlStream != null && StringUtils.isNotEmpty( requestedNodes ) ) {
      SAXBuilder builder = new SAXBuilder();
      try {
                Document doc = builder.build(xmlStream);
                XPathFactory xpfac = XPathFactory.instance();
                XPathExpression< Element > xp = xpfac.compile(requestedNodes,Filters.element());
        return xp.evaluate( doc );
      } catch ( IOException ioe ) {
        log.error( "Couldn't load all " + xmlStream + " resources", ioe );
      } catch ( JDOMException jdome ) {
        log.error( "error parsing " + xmlStream + " resources", jdome );
View Full Code Here

      XPathExpressionException {
    this.humanResourceService = humanResourceService;

    Namespace namespace = Namespace.getNamespace("hr", NAMESPACE_URI);

    XPathFactory xPathFactory = XPathFactory.instance();

    this.startDateExpression = xPathFactory.compile("//hr:StartDate",
        Filters.element(), null, namespace);
    this.endDateExpression = xPathFactory.compile("//hr:EndDate", Filters.element(),
        null, namespace);
    this.nameExpression = xPathFactory.compile(
        "concat(//hr:FirstName,' ',//hr:LastName)", Filters.fstring(), null,
        namespace);
  }
View Full Code Here

TOP

Related Classes of org.jdom2.xpath.XPathFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.