Project

Profile

Help

Some xsl:result-document Docs Not Showing Up

Added by Anonymous almost 15 years ago

Legacy ID: #7523754 Legacy Poster: W. Eliot Kimber (drmacro)

I have a transform that uses xsl:result-document to generate all of its output into a bunch of files. When I run this transform through Oxygen using 9.0.1.7 I get all my output, as I would expect. When I run the same transform on the same data through the S9I API from code running within a Web app (Tomcat), two of my xsl:result-document calls work fine, in that the expected docs show up, but another one produces no output even though there is no failure from the transform. I am echoing the URI given to the href= attribute so I can tell that the expected value is being supplied. This is running under OSX (haven't had a chance to test under Windows yet). My question: what would cause xsl:result-document to appear to work in the transform (e.g., no IO exception is thrown indicating inability to write to the result) but the file not actually be created? The two result files that work are going into the same directory as the specified output (that is, the file used to create the Destination argument to the transform) and the files that aren't showing up are put in a subdirectory of that directory. Just to be sure, I've set my Java code to ensure the subdirectory exists before I run the transform, although that shouldn't be necessary. Since it works outside my Web service, it's either something I'm doing wrong in setting up the transform with the S9I API or some subtle aspect of running in a Web service but I have no idea what I could have done. Here's my code for constructing an XsltTransformer: if (messageListener == null) messageListener = new LoggingSaxonMessageListenerImpl(log); XsltCompiler compiler = getSaxonXsltCompiler(context, messageListener); XsltTransformer trans = null; if (style != null) { try { XsltExecutable xsltExe = null; xsltExe = compiler.compile(style); trans = xsltExe.load(); } catch (SaxonApiException e) { throw new RSuiteException(0, "SaxonApiException compiling XSLT "" + style.getSystemId() + "": " + e.getMessage(), e); } trans.setMessageListener(messageListener); return trans; } else { return null; } I don't see much opportunity to go wrong there. Thanks, Eliot


Replies (8)

Please register to reply

RE: Some xsl:result-document Docs Not Showing Up - Added by Anonymous almost 15 years ago

Legacy ID: #7523858 Legacy Poster: Michael Kay (mhkay)

I would think it's almost certain that the files are being written, but not where you expect them. You haven't shown enough of your code for me to be sure what the Base Output URI is. This is the base URI used for resolving a relative URI in the href attribute of xsl:result-document. If you set FeatureKeys.TIMING to true on the Configuration, Saxon will log the full filenames that it writes to System.err. Alternatively, supply an OutputURIResolver, which is called by xsl:result-document and can be used to monitor or to set the way the file is written.

RE: Some xsl:result-document Docs Not Showing Up - Added by Anonymous almost 15 years ago

Legacy ID: #7524232 Legacy Poster: W. Eliot Kimber (drmacro)

Thanks--I'll try those debug approaches. Cheers, Eliot

RE: Some xsl:result-document Docs Not Showing Up - Added by Anonymous almost 15 years ago

Legacy ID: #7524850 Legacy Poster: W. Eliot Kimber (drmacro)

I turned on the TIMING flag and saw, not surprisingly, that the missing files are being output relative to the JVM dir, rather than relative to the specified destination file, e.g.: Writing to file:/Applications/eclipse/Eclipse.app/Contents/MacOS/topics/topic_d8e705.dita So my question: what should I be doing, either in setting up the transformer object, or in my XSLT, to set the correct base URI for result-document? Thanks, Eliot

RE: Some xsl:result-document Docs Not Showing Up - Added by Anonymous almost 15 years ago

Legacy ID: #7525350 Legacy Poster: Michael Kay (mhkay)

I'm slightly suprised to discover that XsltTransformer doesn't have a setBaseOutputURI() method. In its absence, you can dive into the Controller: trans.getUnderlyingController().setBaseOutputURI(). However, if the Destination that you supply to the XsltTransformer has a URI or system ID associated with it, this should be used automatically as the base output URI. I don't think you've show the part of your code that sets the destination.

RE: Some xsl:result-document Docs Not Showing Up - Added by Anonymous almost 15 years ago

Legacy ID: #7525945 Legacy Poster: W. Eliot Kimber (drmacro)

Ok, here's how I'm setting up and running the transform (error checking omitted for clarity): XsltCompiler compiler = getSaxonXsltCompiler(context, messageListener); XsltTransformer trans = null; XsltExecutable xsltExe = null; XsltExe = compiler.compile(style); trans = xsltExe.load(); Serializer result = new Serializer(); result.setOutputFile(resultFile); trans.setDestination(result); trans.transform(); So I am definitely setting the output file on the Destination, which I would expect to set the output base URI. Thanks, Eliot

RE: Some xsl:result-document Docs Not Showing Up - Added by Anonymous over 14 years ago

Legacy ID: #7553810 Legacy Poster: W. Eliot Kimber (drmacro)

Pinging on this issue. I've been on vacation but I'm back now and resolving this is a high priority for me. I'm sure I can find a workaround but what I'd like to know is what the Saxon code should be doing. Given that knowledge, I can try to dig into the Saxon code more deeply to find any bugs, if the current behavior is in fact not correct per the original intent. But certainly my naive expectation is that setting an output destination that has a file would have the effect of setting the base output URI for xs:result-document and that doesn't appear to be happening. But I'm not 100% sure I'm using the API correctly. Thanks, Eliot

RE: Some xsl:result-document Docs Not Showing Up - Added by Anonymous over 14 years ago

Legacy ID: #7553982 Legacy Poster: W. Eliot Kimber (drmacro)

I traced through the code and I think I have discovered the nature of the bug, although I'm not sure what the right code fix would be. The problem is that the UncommittedResult created from the StreamResult I pass in is not using the systemId of the passed-in Result to set its own systemId value. Thus when the Controller goes to set the principalResultURI value, it gets null. If I manually set the principalResultURI value to match the systemId of the wrapped Result in the debugger, then I get the result I expected (the output files are generated relative to that URI). I think that must be a bug. I was already working around this bug (although I didn't realize it) by passing in the output directory as a parameter--I just wasn't using it in this case because I wasn't thinking clearly at the time. Cheers, Eliot

RE: Some xsl:result-document Docs Not Showing Up - Added by Anonymous over 14 years ago

Legacy ID: #7574839 Legacy Poster: W. Eliot Kimber (drmacro)

Should I log this as a bug in the bug tracker? Cheers, Eliot

    (1-8/8)

    Please register to reply