Hello Andy Thanks, worked perfectly now!
-- diogo patrĂ£o On Sun, Mar 10, 2013 at 3:14 PM, Andy Seaborne <[email protected]> wrote: > On 10/03/13 02:19, Diogo FC Patrao wrote: > >> Hello >> >> I'm studying doing transformations in SPARLQ queries; based on this [1] >> tutorial, I wrote the code below. >> >> teste.main() was supposed to print a query specifiying ":teste3" instead >> of >> ":teste1" (that`s what my QueryExpander was supposed to do), however the >> two printed algebras are identical! >> >> I thought that when the QueryExpander.transform method would return >> something else than the original opBGP, it would be substituted on the >> algebra. I couldn't find any other example other than [1]. >> >> Any help would be greatly appreciated. >> >> dfcp >> ---- >> >> > Two points: > > > public class QueryExpander extends TransformBase { > > That should be > > ..... extends TransformCopy > > which is why you are seeing no change. As you have it you make aone level > change, but it's not copied back up the tree. > > Also, > > > public Op transform(OpBGP opBGP) { > // TODO Auto-generated method stub > BasicPattern x = opBGP.getPattern(); > BasicPattern opNewPattern = new BasicPattern(); > for( int i =0; i< x.size(); i++ ) { > opNewPattern.add( transform(x.get(i)) ); > } > Op newOpBGP = new OpBGP( ); > return newOpBGP; > } > > You haven't connected the opNewPattern with newOpBGP > > Try: > > Op newOpBGP = new OpBGP( opNewPattern ); > > Andy > >
