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 December 15th, 2008, 08:59 AM
Registered User
 
Join Date: Aug 2008
Posts: 8
Thanks: 2
Thanked 0 Times in 0 Posts
Send a message via AIM to maikm
Default Accessing secondary result documents from Java

Hi folks (Hi Michael ;~)

I have one source XML and several destination XML documents. I'm generating the main result document with Saxon B9, and the XSLT contains something like the following section:

Code:
<xsl:result-document href="secondary.xml">
    (...some code...)
</xsl:result-document>
The calling Java code looks like this:
Code:
    String path = workdir.getAbsolutePath();
    DOMSource domSource = new DOMSource( domDocument, path );
    xslttrans.setSource( domSource );
    Serializer ser = new Serializer();
    ser.setOutputFile( new File( path + "/" + "document.xml" ) );
    xslttrans.setDestination( ser );
    xslttrans.transform();
I get the main result document, but I can't figure out how to access the secondary file. It's not being written at the same directory as the main output, and I can't figure out how to set the base URI that might be needed for it to do that. Any hints anyone?

Thanks
Maik
 
Old December 15th, 2008, 09:48 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

First, an aside: using a DOMSource with Saxon is really inefficient and you should only do it if you already have the source in the form of a DOM. Much better to let Saxon build the tree in its own native format.

Second point: you're asking a question here that's very specific to Saxon. The best place to do that is on the saxon-help mailing list or forum which you can reach via the saxon project on sourceforge. The advantage of doing that is that users can help each other much better if they all meet in the same place.

In theory the output files should be written to the same directory as the principal output. I'll try to run a test similar to your code to see if I can reproduce the problem.

You should be able to see where the files are being written by using

processor.setProperty(FeatureKeys.TIMING, "true")

This is equivalent to the -t option on the command line.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
The Following User Says Thank You to mhkay For This Useful Post:
maikm (December 15th, 2008)
 
Old December 15th, 2008, 10:31 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I've raised a bug for this at https://sourceforge.net/tracker2/?fu...72&atid=397617 and a patch is in Subversion. I can't see an obvious workaround other than setting an absolute URI in the xsl:result-document/@href attribute. The files are actually being written to the current working directory.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
The Following User Says Thank You to mhkay For This Useful Post:
maikm (December 15th, 2008)
 
Old December 15th, 2008, 11:14 AM
Registered User
 
Join Date: Aug 2008
Posts: 8
Thanks: 2
Thanked 0 Times in 0 Posts
Send a message via AIM to maikm
Default

Thanks for the blazingly fast support, Michael!

I made a workaround by supplying an attribute to the root note with the workdir used, and prefixed the href path with that: works.

Quote:
Originally Posted by mhkay View Post
First, an aside: using a DOMSource with Saxon is really inefficient and you should only do it if you already have the source in the form of a DOM. Much better to let Saxon build the tree in its own native format.
I'm not reading an existing xml file, the document is built dynamically. It's there as a org.w3c.dom.Document, so I felt this was the natural way to go. If something other is more efficient, can you give me a two-liner of how to do that?

I'll join the saxon list right away. I didn't really know how saxon-specific the question was, or even whether the problem was in XSLT, Java or Saxon.

Quote:
processor.setProperty(FeatureKeys.TIMING, "true")
I suppose you meant processor.setConfigurationProperty().

Thanks again
Maik





Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing Google search with Java jvlaine Java Basics 3 December 15th, 2007 03:08 AM
Accessing exe in Java pandian Java Basics 1 October 9th, 2006 08:25 PM
[How] Using java to get a result from a php file? MP3 Java Basics 8 July 24th, 2006 05:01 PM
Accessing DLL using Java Script sooraj_iyer Javascript 5 September 17th, 2004 04:45 AM
Accessing Java Servlet thru DotNet r_ganesh76 General .NET 0 June 23rd, 2004 11:45 PM





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