XPath examples – WebService

By , last updated November 1, 2014

Now we are going to look at some complex examples.


Any WebService has a main class and we want that top-level logging happens there. We create our own LoggUtil and now we need to be sure that all our programmers use it while creating WebServices.

public class Foo {
     private LoggUtil log = new LoggUtil(Foo.class);

In order to do that we need:
a) find all classes in the project with annotation @javax.jws.WebService:


b) look if these classes have LoggUtil instances:

//VariableDeclarator[( contains(../Type/ReferenceType/ClassOrInterfaceType/attribute::Image,'LoggUtil'))]

To set it all together we look again through part 1 and produce the following code:

            contains (../Type/ReferenceType/ClassOrInterfaceType/attribute::Image,'LoggUtil')

Senior Software Engineer developing all kinds of stuff.


Be the first to comment.

Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>