Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6211067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:16:23+00:00 2026-05-24T06:16:23+00:00

I have 2 strings, an XML string I constructed using Java DOM interface, and

  • 0

I have 2 strings, an XML string I constructed using Java DOM interface, and an external XSL file I want to bind to that XML file. I tried using Java transform methods, but without luck (meaning I can’t seem to find any solution for this on the web).

How do I take an XML file and an XSL file and make an HTML string out of them?

What I’m trying to do is to inject an XML page into my JSP page.

Just to clarify: This is done in a servlet, not in JavaScript.

A little more information:

I create the XML during runtime as a string, the XSL file I’ve got is stored on the server, what I want to do is to display the XML altered by the XSL file to the user when he clicks on a certain link on the site, and I want to embed that inside an existing JSP page (in order to maintain the standard look of the site).

This is what I’ve got so far:

String convertedXML = new String();
TransformerFactory factory1 = 
    TransformerFactory.newInstance();
Source xsl = new StreamSource("my.xsl");
Result result11 = null;
try {
    Templates template = factory1.newTemplates(xsl);
    Transformer transformer1 = template.newTransformer();
    Source xml = new StreamSource(xmlString);
    result11 = new StreamResult(convertedXML);
    transformer1.transform(xml, result11);
} catch(Exception e) {
   System.out.println("Not Good");
}

The last line before the catch throws the next error:

javax.xml.transform.TransformerException:
java.io.FileNotFoundException: at
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getOutputHandler(Unknown
Source) at
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown
Source) at
controllers.UserController.schedulePage(UserController.java:394)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:16:24+00:00Added an answer on May 24, 2026 at 6:16 am

    Could you put your file into WEB-INF and try to use following:

    String path = "/WEB-INF/my.xsl";
    ServletContext context = getServletContext();
    InputStream xslIs = context.getResourceAsStream(filename);
    Source xsl = new StreamSource(xslIs);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

HI, I have some string from XML file, and I I want to replace
I have a string containing XML document using LinqtoXML What is the best way
I have a string in XML format and I want to use this string
I have a function that outputs an XML string: <expensesAC> <cashflow> <month>6</month> <cash>300</cash> <projected>null</projected>
I have to replace the content of this xml string through java <My:tag>value_1 22&#xA;value_2
I have an object that can build itself from an XML string, and write
I have a Java string of XML content. I use Velocity to generate some
I have some Java (5.0) code that constructs a DOM from various (cached) data
I have an xml document that is constructed pretty poorly-- instead of child nodes,
I am trying to generate Java classes to bind xml to objects using castor.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.