The Java classes you can use as parameters to a stylesheet are the same as the classes you can return from a Java extension function, which are listed in the file extensibility.html under the heading "Result of an extension function".
 
Michael Kay
-----Original Message-----
From: David Hooker [mailto:dhooker@a4networks.com]
Sent: 12 June 2002 20:04
To: michael.h.kay@ntlworld.com
Cc: saxon-help@lists.sourceforge.net
Subject: RE: [saxon] Passing parameters to a transform

Ok... I've hunted through the docs and even the source code without any luck... what exactly can I pass as a parameter via transformer.setParameter("paramName", ????)
 
From your answers below, I see that it doesn't accept DOM nodes.  I'm still kinda green when it comes to all the xml api's so I'm not sure which type of object is most appropriate to give to Saxon as the parameter value.  I see from your replies that it must be a class that implements the JAXP Source interface, but which types exactly does Saxon recognize?
 
-----Original Message-----
From: saxon-help-admin@lists.sourceforge.net [mailto:saxon-help-admin@lists.sourceforge.net] On Behalf Of Michael Kay
Sent: Wednesday, June 12, 2002 11:07 AM
To: 'David Hooker'
Cc: saxon-help@lists.sourceforge.net
Subject: RE: [saxon] Passing parameters to a transform

 
From the dom4J docs:   DocumentSource DocumentSource implements a JAXP Source for a Document 
 
Source is a marker interface only. Saxon (like other processors) only supports implementations of Source that it recognizes. Saxon doesn't recognize this implementation of Source. 
 
So Saxon 6.1 doesn't support parameters at all??? 
 
Of course it supports parameters - but only of certain Java classes, which don't include DOM nodes. Some XSLT processors don't support third-party DOM implementations at all. Saxon does, but only in certain contexts, basically those where JAXP requires it, ie. the Source and Result. It doesn't support a DOM as a parameter.
 
Michael Kay
 
 
 
I already have dom4j Documents (their DOM object) all over the place, so it just makes sense to pass them in as parameters.  I'm afraid flattening to XML would be too slow... but I don't know that for sure.  We are using the document() function now, but it's clunky dealing with filenames across platforms.  I'll look into the URIResolver idea, and the DOMSource.
-----Original Message-----
From: saxon-help-admin@lists.sourceforge.net [mailto:saxon-help-admin@lists.sourceforge.net] On Behalf Of Michael Kay
Sent: Wednesday, June 12, 2002 4:43 AM
To: 'David Hooker'; saxon-help@lists.sourceforge.net
Subject: RE: [saxon] Passing parameters to a transform

You haven't explained what the "new DocumentSource()" does - is DocumentSource a subclass of DOMSource?
 
Saxon doesn't accept a DOM Node (from a non-Saxon DOM implementation) as a parameter. In 7.1 you can achieve this, but you must first wrap it in a DOMSource object. In 6.x it's not supported at all. One way around this is to supply an invented URI instead, and then access the document using the document() function, intercepting the invented URI with your own URIResolver.
 
But really, constructing a DOM simply in order to provide input to Saxon is very inefficient. Saxon's handling of DOM input is inefficient because DOM doesn't support things like sorting nodes into document order. So generating a DOM just so that you can pass it to Saxon is bad news. Generating a SAX stream, or a Saxon TinyTree, would be far better, even serializing to raw XML might be better.
 
Michael Kay
-----Original Message-----
From: saxon-help-admin@lists.sourceforge.net [mailto:saxon-help-admin@lists.sourceforge.net] On Behalf Of David Hooker
Sent: 12 June 2002 01:17
To: saxon-help@lists.sourceforge.net
Subject: [saxon] Passing parameters to a transform

Hi-
 
I'm using dom4j and Saxon.  I need to pass node set parameters to the transform, and I'm having a hard time figuring out the API to do this.  Here's what I have:
 
    org.dom4j.io.DOMWriter writer = new DOMWriter();
    org.w3c.dom.Document domDoc = writer.write(myDomForJDocument);
    TransformerFactory factory = TransformerFactory.newInstance();
    Transformer transformer = factory.newTransformer(new DocumentSource(myTransformDocument));
    transformer.setParameter("paramName", domDoc);
 
The transform doesn't seem to see the parameter document.  Does anyone have any examples/hints/suggestions for me?  Any other example code of passing parameters to a transform would be helpful.  Any insight into how Saxon handles parameters would be nice.
 
Thanks...
 
-David-