From (query directive)
Takes the results from one directive and feeds them one row at a time to another combining all results.
From(Directive to,Directive from)
This directive is best used using the from method present in every directive. Calling A.from(B) will resolve to new From(A,B).
The from method, but not the directive constructor, can be given several directives. In this case they will be joined using the Join directive. A.from(B,C) will resolve to new From(A,new Join(B,C)).
You may also give the from method, not the directive constructor, one or more strings. In this case a Literals directive will be implicitly created from the strings. A.from("b","c","d") resolves to new From(A,new Literals("b","c","d")).
All directives also have a to method which is inverse of from. It is advisable that you use this sparingly as mixing both from and to in the same query can make it very hard to follow where the input comes from and where results go. A.from(B) is same as B.to(A).
importPackage(org.wandora.query2); new Instances().from(new Instances())
Above example selects the instances of the instances of the input topic.
importPackage(org.wandora.query2); new Instances().from("http://www.wandora.org/core/schema-type")
Above example gets instances of the specified topic. The from method implicitly creates a Literals directive. Instances directive can take as input both topics or subject identifier string so this works without explicitly converting the string to a topic.
Next two examples get the base names of the instances of the input. The second example uses to instead of from turning the query other way round.
importPackage(org.wandora.query2); new BaseName().from(new Instances())
importPackage(org.wandora.query2); new Instances().to(new BaseName())
One good place to use to instead of from is modifying the initial input before it gets to anything else. For example changing the role so the initial input is not overwritten immediately in other directives (see As directive).
importPackage(org.wandora.query2); new As("#input").to( new BaseName() )