jmc430
asked on
Passing Parameters Using JAVA, XSL, XML
Greetings!
I have a question concerning passing parameters using Java. I have a function that takes the XSL parameters, and is supposed to set them for processing. However, I continue to receive various befuddling errors upon compilation.
Here is the Java function that does the Transformer actions:
public void appendToResponse(WORespons e response, WOContext context) {
response.setContentEncodin g("UTF8");
super.appendToResponse(res ponse, context);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
TransformerFactory tFactory = TransformerFactory.newInst ance();
StreamSource xslSource = new StreamSource("http://here.is.my.fullpath.to/File.xsl");
Transformer transformer = tFactory.newTransformer(xs lSource);
StreamSource inXML = new StreamSource(getXmlSource( ));
StreamResult outXML = new StreamResult(baos);
transformer.setParameter(" BatchIndex ", BatchIndex); < ===== why doesn't this work?
transformer.setParameter(" SessionID" , SessionID); < ===== why doesn't this work?
transformer.setParameter(" Criteria", Criteria); < ===== why doesn't this work?
transformer.setParameter(" BatchCount ", BatchCount); < ===== why doesn't this work?
transformer.transform(inXM L, outXML);
} catch (TransformerException e) {
System.err.println(e);
}
response.setContent(new NSData(baos.toByteArray()) );
response.setHeader("text/h tml; charset=UTF-8 encoding=UTF-8", "content_type");
}
I also have an additional function in another class, that is supposed to take the formValueForKey values.
public WOComponent renderXMLAction(){
WORequest request = request();
String xmlFile=(String)request(). formValueF orKey("Bat chIndex"); < ===== why doesn't this work?
String xmlFile=(String)request(). formValueF orKey("Bat chCount"); < ===== why doesn't this work?
String xmlFile=(String)request(). formValueF orKey("Cri teria"); < ===== why doesn't this work?
String xmlFile=(String)request(). formValueF orKey("Ses sionId"); < ===== why doesn't this work?
SearchResults nextPage=(SearchResults)pa geWithName ("SearchRe sults");
nextPage.setXmlSource(xmlF ile);
return nextPage;
}
Any advice or guidance is greatly appreciated!
Best regards,
Jamie
I have a question concerning passing parameters using Java. I have a function that takes the XSL parameters, and is supposed to set them for processing. However, I continue to receive various befuddling errors upon compilation.
Here is the Java function that does the Transformer actions:
public void appendToResponse(WORespons
response.setContentEncodin
super.appendToResponse(res
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
TransformerFactory tFactory = TransformerFactory.newInst
StreamSource xslSource = new StreamSource("http://here.is.my.fullpath.to/File.xsl");
Transformer transformer = tFactory.newTransformer(xs
StreamSource inXML = new StreamSource(getXmlSource(
StreamResult outXML = new StreamResult(baos);
transformer.setParameter("
transformer.setParameter("
transformer.setParameter("
transformer.setParameter("
transformer.transform(inXM
} catch (TransformerException e) {
System.err.println(e);
}
response.setContent(new NSData(baos.toByteArray())
response.setHeader("text/h
}
I also have an additional function in another class, that is supposed to take the formValueForKey values.
public WOComponent renderXMLAction(){
WORequest request = request();
String xmlFile=(String)request().
String xmlFile=(String)request().
String xmlFile=(String)request().
String xmlFile=(String)request().
SearchResults nextPage=(SearchResults)pa
nextPage.setXmlSource(xmlF
return nextPage;
}
Any advice or guidance is greatly appreciated!
Best regards,
Jamie
If your requests are conditional, you should put them in conditions
String xmlFile=(String)request().
if(xmlFile==null||xmlFile.
{
xmlFile=(String)request().
}
Is that what you are expecting??
Regards
Sudhakar
>>transformer.setParameter ("BatchInd ex", BatchIndex);
>>transformer.setParameter ("SessionI D", SessionID);
Check if BatchIndex,SessionID are null or valid objects. Similarly you should check other objects also
Best Regards
Sudhakar Chavali
>>transformer.setParameter
Check if BatchIndex,SessionID are null or valid objects. Similarly you should check other objects also
Best Regards
Sudhakar Chavali
ASKER
I'm trying to append all those values, (BatchCount, BatchIndex, SessionID, Criteria), into the XSLT transform.
These parameters will not be null in any instances..
These parameters will not be null in any instances..
Ok can you post the compilation errors
Regards
Sudhakar Chavali
Regards
Sudhakar Chavali
ASKER
Hi Sudhakar,
I'm only getting one error:
javax.xml.transform.Transf ormerExcep tion:java. net.Malfor medURLExce ption
I found online that this means the "text of a stylesheet to an interface that was expecting a URI." but I don't know what this means.
Thanks for helping me ...
Best regards,
Jamie
I'm only getting one error:
javax.xml.transform.Transf
I found online that this means the "text of a stylesheet to an interface that was expecting a URI." but I don't know what this means.
Thanks for helping me ...
Best regards,
Jamie
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I don't think the transformation itself is giving me issues ..
Basically my transformation works on the first transform (when I first submit parameters to be processed by the XSL). However, on the second transform, when I want to take all the parameters (plus the newly inputted parameters) I want to pass the new parameters to the same transform.
I want to be able to have a request.setParameter() and a request.getParameter() somewhere (as in JSP) but I do not know how to achieve this.
I'm getting this error as well:
javax.xml.transform.Transf ormer.Exce ption: The declaration for the entity "HTML.Version" must end with '>'.
Thanks for helping me..
Basically my transformation works on the first transform (when I first submit parameters to be processed by the XSL). However, on the second transform, when I want to take all the parameters (plus the newly inputted parameters) I want to pass the new parameters to the same transform.
I want to be able to have a request.setParameter() and a request.getParameter() somewhere (as in JSP) but I do not know how to achieve this.
I'm getting this error as well:
javax.xml.transform.Transf
Thanks for helping me..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks for pointing me in the right direction.
:)
:)
no worries :)
I see same variable name for all the requests
>>String xmlFile=(String)request().
>>String xmlFile=(String)request().
And also check the instance that you are getting from request.
As an example include this debugging statement.
System.err.println(request
If the result is not java.lang.String you need to recheck your code
Best Regards
Sudhakar