Re: RE: RE: [xsl] Saxon servlet and xsl:result-document (multiple documents) problem - solution found

Subject: Re: RE: RE: [xsl] Saxon servlet and xsl:result-document (multiple documents) problem - solution found
From: <xml4pharma@xxxxxxxxxxxxxxxx>
Date: Sat, 10 Apr 2004 09:04:01 +0200
After being up early in the morning (8 a.m. is early for me), and a good
cup of strong coffee, I now could find the solution.

The trick is that you have to use 'file:///filename.html' (or similar)
for the value of the href attribute in xsl:result-document. E.g. use:
<xsl:variable name="file"
select="concat('file:///test',$pos_as_string,'.html')"/> <!-- gives e.g.
test1.html -->

then in the main output document make a reference to it:
<xsl:element name="a">
    <xsl:attribute name="href"><xsl:value-of
select="$file"/></xsl:attribute>
    Here is a link to the additional created document
</xsl:element>

and then start the second document by:
<xsl:result-document href="{$file}" format="..."> 
<!-- format references to a defined xsl:output-format at the top of the
document -->
<!-- do all the stuff here -->
</xsl:result-document -->

The SAXON servlet then sends you back the main document, in which there
is a link to the secondly created document. When you click on the link,
you get the second document.

Note that the second document is actually NOT written to disk on the
server where the servlet resides. It is only there in memory.

Many thanks for all those helping me on this, and hope this solution
also helps many other in their work.

Have a very nice Eastern weekend

Jozef

==================================



Michael Kay <mhk@xxxxxxxxx> schrieb am 09.04.2004, 20:56:32:
> In my own tests, I haven't managed to persuade Java to create a writeable
> file connection for any kind of URI other than a file:/ URI. I would expect
> to get an error message if you use an http:// URI, and I'm a little
> surprised that you don't get an error, but I wouldn't expect it to succeed. 
> 
> You can always write your own OutputURIResolver that intercepts any kind of
> URI, of course.
> 
> Michael Kay
> 
> > -----Original Message-----
> > From: xml4pharma@xxxxxxxxxxxxxxxx 
> > [mailto:xml4pharma@xxxxxxxxxxxxxxxx] 
> > Sent: 09 April 2004 16:42
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Subject: Re: RE: [xsl] Saxon servlet and xsl:result-document 
> > (multiple documents) problem
> > 
> > 
> > Many thanks, it already helped me somewhat further.
> > 
> > So I did the following in my stylesheet:
> > 
> >  
> >  select="concat('http://localhost:8080/servlets-examples/file',
> > $pos_as_string,'.html')"
> > /> 
> > 
> > 
> > 
> > 
> > I also use  to check the value of $file
> > and see in the Tomcat logs:
> > "Creating file http://localhost:8080/servlets-examples/file1.html";
> > (generated by the xsl:message), and
> > "Writing to http://localhost:8080/servlets-examples/file1.html";
> > (generated by the SaxonServlet after adding FeatureKeys.TIMING 
> > according to your suggestion). 
> > 
> > However, nothing seems to be written.
> > 
> > I also deployed everything to my public Linux webserver (of course
> > adapting the localhost to the real URL) and did 'chmod 777
> > servlets-examples' to ensure that everything has write access to the
> > directory.
> > 
> > In the Tomcat loggings I see the same things ("writing to ...
> > messages"), but also there I see nothing created.
> > 
> > Any idea what I am doing wrong ?
> > 
> > Jozef
> > 
> > P.S. I did not change anything in the "new StreamResult(out)" of the
> > SaxonServlet as I did not entirely understand your suggestion.
> > 
> > --------------------------------
> > 
> > 
> > 
> > Michael Kay  schrieb am 08.04.2004, 22:54:41:
> > > Firstly, I think you will need to use absolute URIs in the 
> > href attribute.
> > > If you use relative URIs, there's nothing really for them 
> > to be resolved
> > > against.
> > > 
> > > Secondly, the sample servlet uses "new StreamResult(out)" 
> > as the transform
> > > destination. I think you may have to change this so the 
> > systemId on the
> > > result object is set.
> > > 
> > > Finally, for diagnostics, try setting the 
> > FeatureKeys.TIMING feature on the
> > > TransformerFactory. This causes Saxon to trace the names of 
> > secondary output
> > > files to System.err, which will probably end up in the 
> > servlet container's
> > > log file.
> > > 
> > > Michael Kay
> > > 
> > > > -----Original Message-----
> > > > From: xml4pharma@xxxxxxxxxxxxxxxx 
> > > > [mailto:xml4pharma@xxxxxxxxxxxxxxxx] 
> > > > Sent: 08 April 2004 19:16
> > > > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > > > Subject: [xsl] Saxon servlet and xsl:result-document 
> > > > (multiple documents) problem
> > > > 
> > > > 
> > > > I have a stylesheet that creates several output documents (using
> > > > multiple xsl:result-document). It works fine with Saxon from line
> > > > command.
> > > > 
> > > > Now I want to use the SaxonServlet to have it generated on 
> > > > the server. 
> > > > I tried several things for defining the URI, but I can't see any
> > > > documents being written on the server (at the moment I am 
> > still using
> > > > http://localhost:8080/test on my Windows 2000 computer).
> > > > Can anyone tell me how I have to define the output path 
> > so that the
> > > > files are really created on the server ?
> > > > Or do I have to change anything in the SaxonServlet ?
> > > > 
> > > > Many thanks in advance
> > > > 
> > > > Jozef Aerts
> > > > xml4pharma@xxxxxxxxxxxxxxxx

Current Thread