League league = new League();
Team team = new Team();
league.getTeams().add( team );
Person coach = new Person();
coach.setFirstName( "Coach Bob" );
team.setCoach( coach );
Person player1 = new Person();
player1.setFirstName( "Player Charlie" );
team.getPlayers().add( player1 );
Person player2 = new Person();
player2.setFirstName( "Player Ted" );
team.getPlayers().add( player2 );
Person player3 = new Person();
player3.setFirstName( "Player Bart" );
team.getPlayers().add( player3 );
Team team2 = new Team();
league.getTeams().add( team2 );
Person coach2 = new Person();
coach2.setFirstName( "Coach Susan" );
team2.setCoach( coach2 );
Person player4 = new Person();
player4.setFirstName( "Player Jim" );
team2.getPlayers().add( player4 );
JXPathContext context = JXPathContext.newContext( league );
System.out.println( "** Retrieve the first name of Ted's coach");
Object value = context.getValue( "teams/players[firstName = 'Player Ted']/../coach/firstName" );
System.out.println( value );
context = JXPathContext.newContext( league );
System.out.println( "** Retrieve the players on Coach Susan's team");
value = context.getValue( "teams/coach[firstName = 'Coach Susan']/../players" );
System.out.println( value );