RE: [xsl] xsl:result-document and TrAX Transformer getOutputProperty

Subject: RE: [xsl] xsl:result-document and TrAX Transformer getOutputProperty
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 21 Feb 2007 09:29:50 -0000
There's no JAXP method to do this because JAXP doesn't yet recognize XSLT
2.0.

In Saxon you can inspect the static contents of a named xsl:output
declaration using

((Controller)transformer).getExecutable().getOutputProperties(fp)

where fp is the fingerprint of the xsl:output name.

But as you rightly point out, the xsl:result-document can override these
properties dynamically. If you need to know the dynamic values, you can do
this (I think) by registering with the Configuration a SerializerFactory
that's a trivial subclass of the standard SerializerFactory, except that it
intercepts the getReceiver() method, which is given the run-time output
properties as a parameter.

An alternative approach is not to control serialization options from the
stylesheet at all, but to do it entirely from your application. You can do
this by writing an OutputURIResolver that constructs its own serializer
encapsulated in the Result object it returns.

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

> -----Original Message-----
> From: James A. Robinson [mailto:jim.robinson@xxxxxxxxxxxx] 
> Sent: 20 February 2007 18:33
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] xsl:result-document and TrAX Transformer 
> getOutputProperty
> 
> 
> Folks,
> 
> I was wondering if folks know of a clean way to get at the 
> output properties for an XSL Transformation which uses 
> xsl:result-document and a named xsl:output?
> 
> We've got a stylesheet which normal uses an xsl:output method 
> of xhtml, but which in some cases needs to use a method of 
> xml.  In those cases we used xsl:result-document to route 
> everything via a named xsl:output, but it looks to me like 
> TrAX is unable to get at that information (since it is 
> effectively a 'run-time' option which the Transformer does 
> not know about).
> 
> We ended up building a tiny 'head' stylesheet which consists 
> of an xsl:output declaration (which isn't actually used by 
> the XSLT engine but is examined by the TrAX Transformer!) and 
> then including our normal stylesheets. This seems like a very 
> ugly solution.
> 
> One of the issues is that we'd rather not buffer the results 
> of the transformation in order to examine it, we'd like to 
> just stream the
> results out.   It was looking to me like the only way to do this is to
> set up extra configuration to look at instead of using the 
> Transformer output properties.  I thought I should ask here 
> in case I'm missing the obvious.
> 
> Jim
> 
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> James A. Robinson                       jim.robinson@xxxxxxxxxxxx
> Stanford University HighWire Press      http://highwire.stanford.edu/
> +1 650 7237294 (Work)                   +1 650 7259335 (Fax)

Current Thread