• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XSLProcessorException : usage of XSLTInputSource

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
i am getting a string as ouptput of java bean method
This string is an xml file.I am applying stylesheet to
this xml file and displaying it in browser window by making
use of output stream of jsp page.
This works fine when i give full file path but when i use http://someurl which is in authenticated realm of webserver
it thorws XSLTProcessorException saying file with given URL
not found but file exists actually
i am attaching jsp page
<%@ page language="java" contentType="text/html; charset=UTF-8"
import = "java.util.*,wt.httpgw.*,wt.util.*,rs.jsp.bean.*,rs.report.*,rs.customization.RSCustomViewHolder,rs.desc.*,rs.jsp.util.*,java.net.URL,org.apache.xalan.xslt.*,java.io.*,rs.jsp.helpe r.*,wt.util.WTMessage,wt.httpgw.EncodingConverter" %>
<jsp:useBean id="wtcontext" class="wt.httpgw.WTContextBean" scope="session"/>
<jsp:setProperty name="wtcontext" property="request" value="<%=request%>"/>
<%
String option = request.getParameter("option_name");
XSLTProcessor xprocessor = null;
Properties prop = WTProperties.getLocalProperties();
String urlname = prop.getProperty("wt.server.codebase");
String wind_home = prop.getProperty("wt.home");
String xml_file_path = wind_home + "\\temp";
File xmlfile = null;
String stylesheet = null;
if (option != null)
{

StringWriter strWriter = new StringWriter();

try{

if (option.equals("Document Hierarchy"))
{
RSReportHelper.getDocumentViewHierarchy(strWriter);
System.out.println("REACHED HERE : 0");
}else
{
RSReportHelper.getSystemViewHierarchy(strWriter);
}

stylesheet = urlname.concat("/rs/jsp/jsp/hierachy.xsl");
System.out.println("The URL generated :" + stylesheet);
try
{
xprocessor = XSLTProcessorFactory.getProcessor();
}catch(Exception e)
{
e.printStackTrace();
System.out.println("################ This gives the SAXPareseException ####################");
}


xprocessor.process(new XSLTInputSource(new StringReader(strWriter.toString())),new XSLTInputSource(stylesheet),new XSLTResultTarget(out));

}catch(Exception e)
{

System.out.println("some kind of error in hierarchy section");
}

}else
{
try{
long templateid = (new Long(request.getParameter("templateid"))).longValue();
System.out.println("Template id " + templateid);
RSReportBean report = new RSReportBean();
report.initialize("rs.report.RSReportTemplate",templateid);
String key = request.getParameter("key");
if (key != null)
{
RSTreeNodeDescriptor desc = (RSTreeNodeDescriptor)( ((RSFolderBean)session.getValue(key)).getDescriptor());
report.setDataDescriptor(desc);
}else
{
RSTreeNodeDescriptor desc = (RSTreeNodeDescriptor)session.getValue("DescForReport");
report.setDataDescriptor(desc);
}

stylesheet = urlname.concat("/rs/jsp/jsp/testingxsl.xsl");
System.out.println("The URL generated :" + stylesheet);
try
{
xprocessor = XSLTProcessorFactory.getProcessor();
}catch(Exception e)
{
e.printStackTrace();
System.out.println("################ This gives the SAXPareseException ####################");
}


xprocessor.process(new XSLTInputSource(new StringReader(report.getReportData())),new XSLTInputSource(stylesheet),new XSLTResultTarget(out));


}catch(Exception e)
{
System.out.println("############################################################");
e.printStackTrace();
System.out.println("####### some kind of error in non-hierarchialsection section #######");

}


}
%>

help needed .
Regards
sharang
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


stylesheet = urlname.concat("/rs/jsp/jsp/hierachy.xsl");
System.out.println("The URL generated :" + stylesheet);
.......
xprocessor
.process(new XSLTInputSource(new StringReader(strWriter.toString())),new XSLTInputSource(stylesheet),new XSLTResultTarget(out));

Couple of things to watch for:
Whats' the output of your System.out.println() stmt.
Then what if the xprocessor is NULL (while this is NOT a
problem in your particular case, I would put a check on this).
Also, what appserver are you using?
pl. let us know when you get a chance.
regds.
- satya
 
Sunglasses. AKA Coolness prosthetic. This tiny ad doesn't need shades:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic