Re: How to get xsl:output/@method after transformation?
Michael Kay <[email protected]> Fri, 30 Apr 2021 00:53:14 +0100
| Newsgroups | gmane.text.xml.saxon.help |
|---|---|
| Message-ID | <[email protected]> |
The question is unfortunately a lot more complex than it seems. The properties of the unnamed xsl:output declaration are available using XsltExecutable.getUnderlyingCompiledStylesheet().getDeclaredSerializationProperties(). But that's far from being the end of the story. This might not tell you the actual output method used, for a variety of reasons: (a) if xsl:output doesn't give a method attribute, the default is determined dynamically (it depends on the name of the first element node actually output) (b) the xsl:output properties can be overridden programmatically from the external API, e.g. by setting properties in the s9api Serializer (c) the xsl:output properties can be ignored/overridden internally within the XSLT code, by using xsl:result-document with no @href attribute. If you want to know dynamically what output method has been selected, your best bet is to define your own implementation of Destination (which could be a subclass of Serializer, or it could pipe output through to a Serializer), which is notified of the properties when Saxon calls Destination.getReceiver(). (I'd have to do some investigation to be sure what happens in the case where the method is defaulted, because in this case the stylesheet can start outputting comments and processing instructions before we know what output method will be chosen. I suspect that these are buffered and we only call Destination.getReceiver() when the first startElement event is emitted.) Michael Kay Saxonica > On 29 Apr 2021, at 20:24, John Ulric <[email protected]> wrote: > > Hello all, when using s9api, after a transformation with net.sf.saxon.s9api.XsltTransformer.transform(), is there a way to get the output method that the stylesheet declared in its xsl:output element? (Or the corresponding content type?) > > I tried calling .getOutputProperty(Serializer.Property.METHOD) on the net.sf.saxon.s9api.Serializer in use, but this seems to return a value only if it was set programatically, not the method that the stylesheet declares. > > Thanks > John > > _______________________________________________ > saxon-help mailing list archived at http://saxon.markmail.org/ > [email protected] > https://lists.sourceforge.net/lists/listinfo/saxon-help