[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: output file for xsl:message

Subject: Re: output file for xsl:message
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 20 Aug 2015 09:48:45 -0000
Re:  output file for xsl:message
By default Saxon writes xsl:message output to the java System.err destination
(the stderr output stream on most operating systems). The simplest way of
redirecting it to a file is using shell redirection, typically 2>error.txt to
overwrite error.txt, or 2>>error.txt to append to error.txt. But it depends on
the shell you are using and this doesnbt always work for me. This also has
the problem that xsl:message output will be mixed with other output sent to
System.err, e.g. the output of -t messages.

If you want something more sophisticated, you can implement the
MessageListener interface in the s9api XsltTransformer class. This allows you
full control over both the formatting of messages and their destination. You
need to be aware if you are using Saxon-EE that the message listener needs to
be thread-safe, because a transformation can execute in multiple threads. But
the content of each call of xsl:message will be passed in a single call to the
MessageListener, as an XML node.

If youbre using the JAXP API, and you only want to change the destination of
the message output, not its formatting, then you can do:

final Writer messageOut = new FileWriter(. . .);
Transformer transformer = templates.newTransformer();
((net.sf.saxon.jaxp.TransformerImpl)transformer).getUnderlyingController().se
tMessageEmitter(
    new MessageEmitter() {
        @Override
        public void open() throws XPathException {
            setWriter(messageOut);
            super.open();
        }
    }
);
At this level things can get messy if multiple threads are writing messages
simultaneously.

Michael Kay
Saxonica


> On 20 Aug 2015, at 10:15, VISH RAJPUT svishnu.singh4@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Hi,
>
> I am using xslt2.0 with saxon9 and want to store the <xsl:message> output in
a result document. There are multiple <xsl:message> in different
<xsl:templates> and I want to store the output of all <xsl:message> in a
single result txt file.
>
> --
> Vishnu Singh | http://marklogicgd.blogspot.in/
<http://marklogicgd.blogspot.in/>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <-list/293509> (by email <>)

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.