Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 15th, 2008, 08:59 AM
Registered User
 
Join Date: Aug 2008
Location: , , Germany.
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
Reply With Quote
  #2 (permalink)  
Old December 15th, 2008, 09:48 AM
mhkay's Avatar
Wrox Author
Points: 18,481, Level: 59
Points: 18,481, Level: 59 Points: 18,481, Level: 59 Points: 18,481, Level: 59
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,960
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
Reply With Quote
The Following User Says Thank You to mhkay For This Useful Post:
maikm (December 15th, 2008)
  #3 (permalink)  
Old December 15th, 2008, 10:31 AM
mhkay's Avatar
Wrox Author
Points: 18,481, Level: 59
Points: 18,481, Level: 59 Points: 18,481, Level: 59 Points: 18,481, Level: 59
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,960
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
Reply With Quote
The Following User Says Thank You to mhkay For This Useful Post:
maikm (December 15th, 2008)
  #4 (permalink)  
Old December 15th, 2008, 11:14 AM
Registered User
 
Join Date: Aug 2008
Location: , , Germany.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 04:24 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.