I just finished the sub-class; not difficult at all - all the info is in the Properties instance supplied to the method getReceiver()
I believe that your xf.getOutputProperty(OutuptKeys.MEDIA_TYPE) only returns the media type of the document whose properties are set using the <xs:output> element and not those whose properties are set using the <xsl:result-document> element.
The JAXP API is deficient in putting the getOutputProperty method on the Transformer interface and not on the Result interface.  When a stylesheet could only output a single document (baring extensions) it was not a problem but now that it can output multiple files there are no API methods to retrieve the additional properties associated with the auxillary output (not that I've come across though I didn't look super hard).
>>Responding to future note regarding streaming
For better or worse the inputs and outputs to the process are all in-memory instances.  I wouldn't gain much by injecting into the middle of the processing compared to just taking the end result.  Something to consider for next time or the future but for the present wrapping upon close() works just fine.  I do, however, appreciate the insight.
Thanks Again,

From: Michael Kay [mailto:mike@saxonica.com]
Sent: Wednesday, August 26, 2009 10:52 AM
To: 'Mailing list for the SAXON XSLT and XQuery processor'
Subject: Re: [saxon] Access the media-type of a result-document in Saxon9HE


I’m not sure that you need to go through all that trouble to find out the media-type.  I had a need to find out the media-type assigned to the transform output and all I did was:


                        xf.transform(src, out);

                        log.info("transform completed");


                        String mediaType = xf.getOutputProperty(OutputKeys.MEDIA_TYPE);

                        String encoding  = xf.getOutputProperty(OutputKeys.ENCODING);


Maybe this would work in your situation.


That will only get the media-type for the default (unnamed) xsl:output declaration. With xsl:result-document you can use a named xsl:output declaration or you can compute the serialization properties dynamically.



Michael Kay