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.

 

Andy.

 

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

 

Thanks for the quick response.

 

I generate a wrapper around the output that also contains meta-data that is tracked in a database if I persist the data or send it over the internet.  For my immediate needs I can make a name->type association outside of the XSLT process but would like to know if/how to at least see what the XSLT stylesheet assigns for the media-type either for confirmation or for cases where the external mapping is not desirable or possible.

 

I will look into the sub-classing the SerializerFactory in the same class as the OutputURIResolver implementation so that I can use my object-identity Maps to store the info during processing and build it into my wrapper when I process the close(Result) method.

 

Let me know if there is any reason my plan wouldn't work or if you have any thoughts on a better way.

 

Again, Thanks!

 

Dave

 


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

If you look at the code for net.sf.saxon.instruct.ResultDocument, you will see that it actually calls the OutputURIResolver before it computes the serialization properties.

 

I think your best bet might be to subclass SerializerFactory and register your subclass with the Configuration. In the SerializerFactory.getReceiver() method you will then have access to both the Result object that was returned by your OutputURIResolver, and the serialization properties. You can then discover the media-type property and return super.getReceiver(). It then depends what you want to do with the media-type - you can't at this stage substitute a different Result object.

 

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay

 


From: David Johnston [mailto:polobo@yahoo.com]
Sent: 26 August 2009 14:33
To: saxon-help@lists.sourceforge.net
Subject: [saxon] Access the media-type of a result-document in Saxon9HE

Hi Everyone,

 

Saxon9HE; Java

 

I can successfully attach an OutputURIResolver implementation to the Saxon Controller to obtain the content and the href/base parts of any <xsl:result-document> elements that I generate in my stylesheet but cannot determine how/where to access the media-type attribute that is allowed on the element.  For the primary output you can query the output properties with the "media-type" key via the Controller but it is quite likely that individual result documents would want to have their own media-types.

 

I am unsure where to look as the "Result" interface does not appear to have any fields or a property map where this could be stored and the Controller appears to pull only the main document path/output.

 

My guess is this is not implemented anywhere, which I understand though would recommend be considered, but figured I'd ask and see if I can either get confirmation or have someone point me to the proper location.

 

Thanks

 

David Johnston