xsl:result-document problem in .net
Added by Anonymous over 16 years ago
Legacy ID: #4902107 Legacy Poster: Jesper Tverskov (jesper_tverskov)
I have a href problem for the "Show a transformation using multiple result documents" example in "XsltExamples.aspx.cs", Saxon in .net, C#. In xsl:result-document I use href="test.html". I imagine that the file ought to end up in same dir as xslt stylesheet inside the "website" running the code. I am testing Saxon in .NET with "Visual Web Developer 2008 Express Edition", and the result-document ends up "far away" in "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE". When I try using a real localhost it attempts to put "test.html" inside "C:\WINDOWS\system32" and is denied. How can I get "xsl:result-document href=’test.html’" place the file in same dir as stylesheet? Cheers Jesper Tverskov
Replies (6)
Please register to reply
RE: xsl:result-document problem in .net - Added by Anonymous over 16 years ago
Legacy ID: #4902136 Legacy Poster: Michael Kay (mhkay)
You can achieve this by setting the BaseOutputURI property of the XsltTransformer object to be the same as the URI of the stylesheet. The default value (defined in the spec) is the URI of the primary output document; if that isn't set Saxon defaults to the current directory, which can be anywhere. Michael Kay http://www.saxonica.com/
RE: xsl:result-document problem in .net - Added by Anonymous over 16 years ago
Legacy ID: #4902261 Legacy Poster: Jesper Tverskov (jesper_tverskov)
OK If "transformer" is the XsltTransformer and "saxon" the dir of the stylesheet, I have these two ways of doing it working: option 1: transformer.BaseOutputUri = new Uri("c:\Inetpub\wwwroot\saxon\"); option 2: transformer.BaseOutputUri = new Uri(xsltUri); It took me hours to locate the problem in the first place and I ended up needing some help. I feel that BaseOutputUri should be part of the example in "XsltExamples.aspx.cs" to get it working right away for all of us. Cheers, Jesper
RE: xsl:result-document problem in .net - Added by Anonymous over 16 years ago
Legacy ID: #4902355 Legacy Poster: Michael Kay (mhkay)
I do appreciate the fact that Saxon is now a pretty large and complex product and that finding this kind of information is becoming quite difficult. There's no easy answer to the problem; the more documentation I write, the larger the haystack in which you have to find your needle. You're right that the example apps are a good way of demonstrating things, and I think quite a few users to turn to them for help, but they can't do everything.
RE: xsl:result-document problem in .net - Added by Anonymous over 16 years ago
Legacy ID: #4916034 Legacy Poster: Harald Schmitt (hschmitt)
For me it works when I do this via a global variable: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" > <xsl:variable name="projects-dir" as="xs:anyURI" select="resolve-uri('.')"/> <xsl:template match"/"> <xsl:result-document href=""> </xsl:template> </xsl:stylesheet>
RE: xsl:result-document problem in .net - Added by Anonymous over 16 years ago
Legacy ID: #4916036 Legacy Poster: Harald Schmitt (hschmitt)
Sorry I hit the send button to early: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" > <xsl:variable name="projects-dir" as="xs:anyURI" select="resolve-uri('../data/')"/> <xsl:template match"/"> <xsl:result-document href="{resolve-uri('tmp-result.html',$projects-dir)}"> <whatever/> </xsl:template> </xsl:stylesheet> Don,t forget the slash at the end of your directory.
RE: xsl:result-document problem in .net - Added by Anonymous over 16 years ago
Legacy ID: #4917255 Legacy Poster: Jesper Tverskov (jesper_tverskov)
As I now understand the BaseOutoutUri in the "Saxon API for .NET", http://www.saxonica.com/documentation/dotnetdoc/index.html saying "The base output URI, which acts as the base URI for resolving the href attribute of xsl:result-document.", you can only control the output dir of the href attribute the safe way by using BaseOutputUri. Your solution works, I guess, in the application on the system you tested, but not necessarily in another application or on another system. Cheers, Jesper Tverskov
Please register to reply