?
Solved

Passing Parameter Values using XSLT, JAVA, XML

Posted on 2005-03-02
4
Medium Priority
?
188 Views
Last Modified: 2008-02-26
Greetings!

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");
    nextPage.setXmlSource(xmlFile);  
    return nextPage;
   }

and in my SearchResults class, I have this function:

    public void appendToResponse(WOResponse response, WOContext context) {
                response.setContentEncoding("UTF8");
                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) {
                        System.err.println(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,
Jamie
0
Comment
Question by:jmc430
  • 2
  • 2
4 Comments
 
LVL 15

Expert Comment

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

Author Comment

by:jmc430
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,
Jamie

0
 
LVL 15

Accepted Solution

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

request()

formValueForKey()

or (String) cast?
0
 

Author Comment

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

:)

thanks for your help!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Integration Management Part 2
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

621 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