You can write a template rule that matches the PI like this:
 
<xsl:template match="processing-instruction('java')">
...
</xsl:template>
 
You could then, if you wanted, interpret the data part of the PI as an XPath expression to be evaluated using saxon:evaluate:
 
   <xsl:sequence select="saxon:evaluate(string(.))"/>
 
or you could deal with it any other way you want to.
 
However, variables declared in the stylesheet are not accessible at run-time by name. Take a look at saxon:evaluate() to see how the design gets around this restriction.
 
There are of course existing, easier ways of calling Java methods from XSLT: see the "Extensibility" section of the documentation for details.
 
Michael Kay
http://www.saxonica.com/


From: saxon-help-admin@lists.sourceforge.net [mailto:saxon-help-admin@lists.sourceforge.net] On Behalf Of Alessandro Di Bella
Sent: 24 September 2004 13:35
To: saxon-help@lists.sourceforge.net
Subject: [saxon] using PI with xslt

Hi,
I'm trying to use an XSLT as a director in the GoF builder pattern where the builder itself is a java class.
My idea is to have a stylesheet that uses PI to execute some java operation. Let me explain with an example:

Let say I have this:

    <xsl:template match="/">
        <xsl:variable name="v1">this is a test</xsl:variable>
        <?java printMe($vi)?>
    </xsl:template>

I would like to tell the transformer that when a it find a PI during the transformation, it should pass it to the builder for further processing.

Is this possible or am I just talking rubbish?

Thanks

Alessandro