Passing Parameter Values using XSLT, JAVA, XML

Posted on 2005-03-02
Medium Priority
Last Modified: 2008-02-26

I am having problems passing parameters using Java.  I am getting the following befuddling error:

javax.xml.transform.TransformerException: java.net.MalformedURLException

In my Java code, I have the following:

    public WOComponent renderXMLAction(){
    WORequest request=request();
    String xmlFile=(String) request().formValueForKey("url");                                <--  this line is causing problems
    SearchResults nextPage=(SearchResults)pageWithName("SearchResults");
    return nextPage;

and in my SearchResults class, I have this function:

    public void appendToResponse(WOResponse response, WOContext context) {
                super.appendToResponse(response, context);
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                try {
                TransformerFactory tFactory = TransformerFactory.newInstance();
                StreamSource xslSource = new StreamSource("http://my.webaddress.to/myFile.xsl");
                Transformer transformer = tFactory.newTransformer(xslSource);

                StreamSource inXML = new StreamSource(getXmlSource());
                StreamResult outXML = new StreamResult(baos);

                transformer.transform(inXML, outXML);
                } catch (TransformerException e) {
                response.setContent(new NSData(baos.toByteArray()));
                response.setHeader("text/html; charset=UTF-8 encoding=UTF-8", "content_type");

I am not certain as to whether it is a problem with my code itself, or with my XSLT and the way parameters are defined... I am relatively inexperienced to XSLT/Java/XML and cannot decipher the error. I read somewhere that "the text of a stylesheet to an interface that was expecting a URI", but I sadly do not know what that means.  Can someone please help?

Any advice or guidance is greatly appreciated!

Best regards,
Question by:jmc430
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 15

Expert Comment

ID: 13443898
so, String xmlFile=(String) request().formValueForKey("url");    - what's the result of xmlFile, after this line is executed

Author Comment

ID: 13444308
Basically I wanted to get the multiple formValueForKey values (I printed out the value of "request" in the line immediately preceding the line you cited):

formValues={SessionID = ("Q3ftncuOduDgpJtI7tA1q0"); x = ("9"); Language = ("Spanish"); y = ("7"); BatchSize = ("20"); BatchIndex = ("1"); }

The result of the xmlFile is an error, even though I modified the aforementioned line:

String xmlFile=(String) request().formValueForKey("Lastname");
javax.xml.transform.TransformerException: java.net.MalformedURLException

(My goal was to first get one parameter returned before aspiring to having all the multiple parameters returned.)

Thanks so much for helping me ..

Best regards,

LVL 15

Accepted Solution

dualsoul earned 2000 total points
ID: 13447271
hm...still can't get it...
what's causing problem exactly?



or (String) cast?

Author Comment

ID: 13451997
i figured it out .. it was formValueForKey


thanks for your help!

Featured Post

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month7 days, 20 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question