Use the setInitialTemplate() method, and then call the transform() method supplying null as the first argument.
(It's actually possible from the Java API, though not from the command line, to have both an initial template and an initial source document)
Michael Kay

From: [] On Behalf Of Roman Kasianenko
Sent: 10 October 2006 16:40
Subject: [saxon] Calling a styelsheet by initial template using Java API

In my project (note: i'm Java programmer having very basic XSL knowledges) i currently use XSL source as parameter to newTransformer() method of the TransformerFactory class to instantiate Controller instance, like that:

            Transformer transformer = factory.newTransformer(xslSource);

Here, transformer is an instance of Controller class implementing Transformer interface.
Transformation is invoked using following call:

            transformer.transform(xmlSource, result);

It works, but now i have new requirement: i have to use so called method of "calling a styelsheet by initial template".

In the docs on i've found that we can use initial template from command line:

-it template        :          Selects the initial named template to be executed. If this is namespaced, it can be written as {uri}localname. When this option is used, the source file should be omitted.

Now i wonder: is there some way to do the same using Saxon's Java API?

>From Saxon's javadocs I know that Controller class has method

setInitialTemplate(String expandedName)

that can be used to set initial template name, but i'm still not sure how should i invoke transformation without using Source document again...

There's one more (besides one mentioned above) transform method in the Controller class:
transformDocument(NodeInfo arg0, Result arg1)

Is that the one i should use or do i do something wrong?

Thanks in advance!
R. Kasianenko