473,661 Members | 2,502 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="documen t('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\gl codes.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.xm l") 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.trans form.Transforme r transformer =
tFactory.newTra nsformer(xslSS) ;
ByteArrayInputS tream baais = new
ByteArrayInputS tream(xmlByteAr ray);
BufferedInputSt ream biis = new BufferedInputSt ream(baais);
StreamSource xmlSource = new StreamSource(bi is);
transformer.tra nsform(xmlSourc e, result);

Thanks
Marty

Nov 28 '06 #1
1 2734
ma**********@im agenow.com wrote:
I may understand what is going on. The document() function loads the
file (in this case "glcodes.xm l") 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 BufferedInputSt ream, 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
4210
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 version="1.0" encoding="UTF-8"?> <!-- edited with XMLSPY v5 rel. 3 U (http://www.xmlspy.com) by Michael Herren (private) -->
4
1618
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: The error msg said "document.ha.re1" is null or not a object and can't transfer to the ldapDeleteUserExec.php My friend told me that may be a DOM(Document Object Model) problem.
1
3603
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 directory within a Sun AppServer and transforms the XML via an XSLT into an HTML file that is served to the user's browser. THE PROBLEM I get a DOM Document from the following line, but when I return the Document from the class which creates it,...
136
9307
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 code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
26
1949
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
3142
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 procedures. It is enabled for SQL stored procedures. It is possible to "Build" and "Run" the Java SPs, it just isn't possible to click on the "Build for Debug" option. Thanks for any help in advance. Michael
0
1159
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 subdirectory. Does anyone know what I have to do to load this directory? I have checked through the User Mail Archive on http://marc.info/?l=xalan-j-users but no one seems to have a similar problem. Have you encountered this issue?
11
7692
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 workplace, office supplies, music CDs, DVD movies, or software). • Create a product class that holds the item number, the name of the product, the number of units in stock, and the price of each unit. • Create a Java application that displays the...
5
6276
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 JDK 6 downloadable from http://java.sun.com/javase/downloads/index.jsp. I will be using JDK 5(update 8)
0
8432
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8855
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8758
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8545
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4179
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4346
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.