Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 23rd, 2013, 05:59 AM
Authorized User
 
Join Date: Mar 2012
Posts: 25
Thanks: 9
Thanked 0 Times in 0 Posts
Default No file created using xsl:result-document

Dear all,

I don't understand why my script is correctly working, but fails to create the output file using the xsl:result-document tag.

Code:
<xsl:template match="/">
	<xsl:variable name="uri" select="concat($output-dir, '/',  '.xml')"/>

	<xsl:result-document href="$uri">
		<xsl:apply-templates select="$main-doc" mode="once" />
	</xsl:result-document>
</xsl:template>
$main-doc is a document-node() variable storing the original XML tree. I use that in order to avoid recalling the template several times (along with the attribute mode). I'm sure the script does what I want, because if I remove xsl:result-document, as showed below, I get the correct output on screen. But the problem is that no file is generated if I keep xsl:result-document.

Is there a way to use xsl:result-document and generate one single output file? (I know I could use the command line to set the output file, but for consistency with other scripts I need to use xsl:result-document)

PS: I'm using XSLT 2.0 and an interpreter that can manage it (I run other scripts generating multiple output files with xsl:result-document without any problems, the only difference is that in those cases I really generate multiple files by nesting xsl:result-document into a xsl:for-each and using "position()" to build the $uri)

Thanks in advance for your help!!!
EastvanAxon
 
Old July 23rd, 2013, 06:24 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Can you tell us exactly which XSLT 2.0 processor you use and post minimal but complete samples allowing us to reproduce the problem?

Do you really want to create an output file named e.g. "C:/dir/.xml"?
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
The Following User Says Thank You to Martin Honnen For This Useful Post:
EastvanAxon (July 23rd, 2013)
 
Old July 23rd, 2013, 06:29 AM
Authorized User
 
Join Date: Mar 2012
Posts: 25
Thanks: 9
Thanked 0 Times in 0 Posts
Default

I'm using "Saxon 9.1.0.8J from Saxonica" the command line I use is "saxonb-xslt -ext:on ... "

No, I don't want to create "/home/user/dir/.xml" I removed too much info, i.e. I want to create "/home/user/dir/file.xml"
 
Old July 23rd, 2013, 06:35 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

The snippet with an 'xsl:template match="/" containing an 'xsl:result-document' is the right approach to create a single result document so based on that snippet I don't see any problems.
Run with the "-t" option to see which file Saxon created.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
The Following User Says Thank You to Martin Honnen For This Useful Post:
EastvanAxon (July 23rd, 2013)
 
Old July 23rd, 2013, 06:49 AM
Authorized User
 
Join Date: Mar 2012
Posts: 25
Thanks: 9
Thanked 0 Times in 0 Posts
Default

Thanks a lot! I discovered the problem:

I had to define a variable with the URI as string and then use it on href="{$uri}" instead of putting directly the string built with concat(...).

Indeed it was trying to write on /home/user/concat(...)

Thanks again for your help!!! -t option is very useful!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I query an XML document as it's created BillMoo XSLT 4 July 7th, 2012 12:30 PM
result-document and filenaming mphare XSLT 1 October 31st, 2011 02:07 PM
Split xml file with result document and javax.xml.transform.Transformer. nisargmca XSLT 3 January 12th, 2010 06:26 AM
Using <XSL:Result-Document> to post to a URL over HTTP ITEpicurean XSLT 1 December 15th, 2009 06:56 PM
xsl:result-document instruction bonekrusher XSLT 3 April 12th, 2007 06:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.