473,387 Members | 1,476 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

xsl document function - java SimpleTransform cannot find file

I have a xsl file that references a xml file using the document()
function.
I'm having trouble specifying the URI in the document() function of a
xls stylesheet.

I'm using java to transform the stylesheet, and when it evaluates the
document() function, it cannot find the specified file.

This is how I reference the xml file I'm having trouble with
<xsl:value-of select="document('glcodes.xml',//)/glcodes/code"/>

I'm using JRun as the web server and I get the following error

SystemId Unknown; Line 1; Column -1; Can not load requested doc:
C:\JRun4\bin\glcodes.xml (The system cannot find the file specified)

I may understand what is going on. The document() function loads the
file (in this case "glcodes.xml") relative to the xml file used when
the xsl file is transformed. So in my below code, the "xmlSource" is
loaded into memory and used. I guess since JRun is doing the
transformation in memory the relative path is starting at the location
where the Xalan processor has this file in memory which would be
...\JRun4\bin. The question is, how do I modify the URI in the
document() fuction so it's relative to where the xml file is loaded
from.

javax.xml.transform.Transformer transformer =
tFactory.newTransformer(xslSS);
ByteArrayInputStream baais = new
ByteArrayInputStream(xmlByteArray);
BufferedInputStream biis = new BufferedInputStream(baais);
StreamSource xmlSource = new StreamSource(biis);
transformer.transform(xmlSource, result);

Thanks
Marty

Nov 28 '06 #1
1 2710
ma**********@imagenow.com wrote:
I may understand what is going on. The document() function loads the
file (in this case "glcodes.xml") relative to the xml file used when
the xsl file is transformed.
No, it's relative to the URI at execution time. But you constructed a
StreamSource from a BufferedInputStream, which has no obvious base URI
for the StreamSource to use as this starting point. In this situation,
you have to explicitly assert a base URI on the StreamSource before
passing it to the transform() operation. There's a method call for that
purpose.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Nov 28 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Michael | last post by:
Hello I am trying to write a Java-Program which converts a XML-file in a HTML. It should take the Transformation-file from the XML-file itself. Below find a possible XML-file: <?xml...
4
by: jiing.deng | last post by:
I want to transfer a value "re1" to ldapDeleteUserExec.php The "alert(document.ha)" appears a dialog and shows "undefined." The "alert(document)" shows "object" But there seems some problem:...
1
by: davo | last post by:
I've been puzzled by this one for ages. I've tried everything I can think of, and now it is time to ask for help. THE APPLICATION A J2EE application which reads an XML file from the /WEB-INF/xml...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
26
by: _R | last post by:
Given that VS2005 has made an effort to clean up the syntax of VC++ (in C++/CLI), is there any future plans to do away with function protos, ala C#/VB? What are they needed for these days?
2
by: Michael | last post by:
Running DB2 v7 UDB ("DB2 v7.1.0.93", "n031208" and "WR21333") on Windows XP, I am unable to find out why the "Build for Debug" option within Stored Procedure Builder is not enabled on Java stored...
0
by: Mike | last post by:
After installing Xalan-J, I wanted to try out the SimpleTransform described on the following page http://xml.apache.org/xalan-j/getstarted.html but could not find the SimpleTransform...
11
by: hamiltongreg | last post by:
I am new to Java and am having problems getting my program to compile correctly. My assignment is as follows; Choose a product that lends itself to an inventory (for example, products at your...
5
by: r035198x | last post by:
Setting up. Getting started To get started with java, one must download and install a version of Sun's JDK (Java Development Kit). The newest release at the time of writting this article is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.