Project

Profile

Help

Support #2443

closed

xsl:message output

Added by Miguel Algorri over 9 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
JAXP Java API
Sprint/Milestone:
-
Start date:
2015-08-21
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

Description

Hello,

A friend asked me for help to output the xsl:message on a transformation with saxon in java. After reading a lot of posts on the internet I thought i could make it work like this:

                                        // Fetch the source file's content and the template to transform with.
					Source xmlSource = new StreamSource(IBFDHelper.getInputStreamByNodeRef(contentService, source));
					Source xslSource = new StreamSource(xslt);

					// Open a writer to the file.
					ContentWriter docWriter = contentService.getWriter(target, ContentModel.PROP_CONTENT, true);
					docWriter.setMimetype(targetMimetype);
					OutputStream os = new BufferedOutputStream(docWriter.getContentOutputStream());
					Result xmlResult = new StreamResult(os);

					// Set-up the transformer.
					TransformerFactory fact = TransformerFactory.newInstance();
					fact.setURIResolver(uriResolver);
					Transformer transformer = fact.newTransformer(xslSource);
					transformer.setErrorListener(errorHandler);
					((net.sf.saxon.Controller)transformer).setMessageEmitter(new net.sf.saxon.serialize.MessageWarner());

                                        transformer.transform(xmlSource, xmlResult);

However, for some reason, when the code gets to the line "((net.sf.saxon.Controller)transformer).setMessageEmitter(new net.sf.saxon.serialize.MessageWarner());" it doesn't continue naturally, the next line of code that gets executed is the first line in the finally, it doesn't even execute the generic Exception catch.

The saxon version used is 9.1 if I'm not wrong.

Please register to edit this issue

Also available in: Atom PDF