Quantcast

outputting xsl:message to a file within xsl:result-document

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

outputting xsl:message to a file within xsl:result-document

Andrew Welch
I'm currently outputting 'xml' using xsl:message whilst in the middle
of an xsl:result-document eg:

<xsl:result-document>
  ..
  <xsl:if test="not(doc-available(somedoc)">
    <xsl:message>
      <error>...</error>
    </xsl:message>
  </xsl:if>
  ..
</xsl:result-document>

I'm then getting this psuedo xml off of standard out and saving it to a file.

This was just a "quick and dirty" way of checking if the target of a
link existed.  Now I want to do it the proper way:

- is there a way of switching between result documents?
- if not, is there a way of telling Saxon to write std out to a file
from the command line?
- or is there a better way all together :)

Out of interest, does doc-available() do anything more than check for
the files existence?  Using it seems to slow the processing down more
than expected...

thanks
andrew


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: outputting xsl:message to a file within xsl:result-document

Dieter Böll

Hello Andrew,

try to define the otput file with

<xsl:result-document href="{$filename}.html">

with e.g. <xsl:variable name="filename" select="url what you need"/>

regards
Dieter

[hidden email] schrieb am 20.09.05 11:05:40:

>
> I'm currently outputting 'xml' using xsl:message whilst in the middle
> of an xsl:result-document eg:
>
> <xsl:result-document>
>   ..
>   <xsl:if test="not(doc-available(somedoc)">
>     <xsl:message>
>       <error>...</error>
>     </xsl:message>
>   </xsl:if>
>   ..
> </xsl:result-document>
>
> I'm then getting this psuedo xml off of standard out and saving it to a file.
>
> This was just a "quick and dirty" way of checking if the target of a
> link existed.  Now I want to do it the proper way:
>
> - is there a way of switching between result documents?
> - if not, is there a way of telling Saxon to write std out to a file
> from the command line?
> - or is there a better way all together :)
>
> Out of interest, does doc-available() do anything more than check for
> the files existence?  Using it seems to slow the processing down more
> than expected...
>
> thanks
> andrew
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by:
> Tame your development challenges with Apache's Geronimo App Server. Download
> it for free - -and be entered to win a 42" plasma tv or your very own
> Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
> _______________________________________________
> saxon-help mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help


______________________________________________________________________
XXL-Speicher, PC-Virenschutz, Spartarife & mehr: Nur im WEB.DE Club!
Jetzt gratis testen! http://freemail.web.de/home/landingpad/?mc=021130



-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: outputting xsl:message to a file within xsl:result-document

Michael Kay
In reply to this post by Andrew Welch
You can simply replace the call on xsl:message with a call on
xsl:result-document, specifying the output destination and if necessary the
serialization parameters. The only time this won't work is if you are in the
middle of evaluating an xsl:variable or xsl:function - that's because in
these actions aren't allowed to have side-effects, and writing a result tree
counts as a side-effect. (xsl:message is allowed here because it's assumed
your application doesn't depend on the result).

However, there's another difference: xsl:message can append to a file,
xsl:result-document can't. Again the theory here is that you can't predict
order of execution, so the contents of the result document would be
undefined. So if you're producing error messages as your output, as it seems
you are, then xsl:message might be a better bet.

xsl:message by default writes to the standard error output. From the command
line (on some operating systems, at any rate) you can redirect standard
error to a file using "2>errors.out". Note that this will also redirect -t
and -T output. If you're prepared to write some Java you have more control:
you can define your own MessageEmitter that does anything it likes with the
output, or you can call setWriter() on the standard MessageEmitter
(available from the Controller/Transformer) if you only want to change the
destination.

doc-available() checks that the file exists and that it contains well-formed
XML (and valid XML if you are validating). It actually builds the tree in
memory. When you subsequently call document() or doc(), this work won't be
repeated. If you just want to check file existence, calling out to a java
method is going to be rather cheaper.

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

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of
> andrew welch
> Sent: 20 September 2005 10:04
> To: [hidden email]
> Subject: [saxon] outputting xsl:message to a file within
> xsl:result-document
>
> I'm currently outputting 'xml' using xsl:message whilst in the middle
> of an xsl:result-document eg:
>
> <xsl:result-document>
>   ..
>   <xsl:if test="not(doc-available(somedoc)">
>     <xsl:message>
>       <error>...</error>
>     </xsl:message>
>   </xsl:if>
>   ..
> </xsl:result-document>
>
> I'm then getting this psuedo xml off of standard out and
> saving it to a file.
>
> This was just a "quick and dirty" way of checking if the target of a
> link existed.  Now I want to do it the proper way:
>
> - is there a way of switching between result documents?
> - if not, is there a way of telling Saxon to write std out to a file
> from the command line?
> - or is there a better way all together :)
>
> Out of interest, does doc-available() do anything more than check for
> the files existence?  Using it seems to slow the processing down more
> than expected...
>
> thanks
> andrew
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by:
> Tame your development challenges with Apache's Geronimo App
> Server. Download
> it for free - -and be entered to win a 42" plasma tv or your very own
> Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
> _______________________________________________
> saxon-help mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>




-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: outputting xsl:message to a file within xsl:result-document

Andrew Welch
Thanks for the info, the redirect on std out is what I need.  

Further to the doc-available() comments, do successive calls to
doc-available() with the same argument reuse the same document? It
looks as though it does, and if it does it's not such a bad thing to
avoid using it...




On 9/20/05, Michael Kay <[hidden email]> wrote:

> You can simply replace the call on xsl:message with a call on
> xsl:result-document, specifying the output destination and if necessary the
> serialization parameters. The only time this won't work is if you are in the
> middle of evaluating an xsl:variable or xsl:function - that's because in
> these actions aren't allowed to have side-effects, and writing a result tree
> counts as a side-effect. (xsl:message is allowed here because it's assumed
> your application doesn't depend on the result).
>
> However, there's another difference: xsl:message can append to a file,
> xsl:result-document can't. Again the theory here is that you can't predict
> order of execution, so the contents of the result document would be
> undefined. So if you're producing error messages as your output, as it seems
> you are, then xsl:message might be a better bet.
>
> xsl:message by default writes to the standard error output. From the command
> line (on some operating systems, at any rate) you can redirect standard
> error to a file using "2>errors.out". Note that this will also redirect -t
> and -T output. If you're prepared to write some Java you have more control:
> you can define your own MessageEmitter that does anything it likes with the
> output, or you can call setWriter() on the standard MessageEmitter
> (available from the Controller/Transformer) if you only want to change the
> destination.
>
> doc-available() checks that the file exists and that it contains well-formed
> XML (and valid XML if you are validating). It actually builds the tree in
> memory. When you subsequently call document() or doc(), this work won't be
> repeated. If you just want to check file existence, calling out to a java
> method is going to be rather cheaper.
>
> Michael Kay
> http://www.saxonica.com/
>
> > -----Original Message-----
> > From: [hidden email]
> > [mailto:[hidden email]] On Behalf Of
> > andrew welch
> > Sent: 20 September 2005 10:04
> > To: [hidden email]
> > Subject: [saxon] outputting xsl:message to a file within
> > xsl:result-document
> >
> > I'm currently outputting 'xml' using xsl:message whilst in the middle
> > of an xsl:result-document eg:
> >
> > <xsl:result-document>
> >   ..
> >   <xsl:if test="not(doc-available(somedoc)">
> >     <xsl:message>
> >       <error>...</error>
> >     </xsl:message>
> >   </xsl:if>
> >   ..
> > </xsl:result-document>
> >
> > I'm then getting this psuedo xml off of standard out and
> > saving it to a file.
> >
> > This was just a "quick and dirty" way of checking if the target of a
> > link existed.  Now I want to do it the proper way:
> >
> > - is there a way of switching between result documents?
> > - if not, is there a way of telling Saxon to write std out to a file
> > from the command line?
> > - or is there a better way all together :)
> >
> > Out of interest, does doc-available() do anything more than check for
> > the files existence?  Using it seems to slow the processing down more
> > than expected...
> >
> > thanks
> > andrew
> >
> >
> > -------------------------------------------------------
> > SF.Net email is sponsored by:
> > Tame your development challenges with Apache's Geronimo App
> > Server. Download
> > it for free - -and be entered to win a 42" plasma tv or your very own
> > Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
> > _______________________________________________
> > saxon-help mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/saxon-help
> >
>
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by:
> Tame your development challenges with Apache's Geronimo App Server. Download
> it for free - -and be entered to win a 42" plasma tv or your very own
> Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
> _______________________________________________
> saxon-help mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: outputting xsl:message to a file within xsl:result-document

Michael Kay
> Further to the doc-available() comments, do successive calls to
> doc-available() with the same argument reuse the same document?

Yes (I hope, can't swear it's tested).

Michael Kay




-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Loading...