How can I display XSLT transformer errors on a web page ?

Hi,
I have some JSP pages that access DB, create an XML based on DB data and then transform it into HTML through an XSLT stylesheet. Developing the XSL code it's easy to make mistakes and generate errors on trasformation, but what I receive on the web page is only a "Could not compile stylesheet" TransformerConfigurationException, while the real cause of the error is displayed only on tomcat logs. This is the code for transformation:
static public void applyXSLT(Document docXML, InputStream isXSL, PrintWriter pw) throws TransformerException, Exception {
        // instantiate the TransformerFactory.
        TransformerFactory tFactory = TransformerFactory.newInstance();
        // creates an error listener
        XslErrorListener xel = new XslErrorListener();
        // sets the error listener for the factory
        tFactory.setErrorListener(xel);
        // generate the transformer
        Transformer transformer = tFactory.newTransformer(new SAXSource(new InputSource(isXSL)));
        // transforms the XML Source and sends the output to the HTTP response
        transformer.transform(new DOMSource(docXML), new StreamResult(pw));
}If an exception is thrown during the execution of this code, its error message is displayed on the web page.
This is the listener class:
public class XslErrorListener implements ErrorListener {
    public XslErrorListener() {
    public void warning(TransformerException ex) {
        // logs on error log
        System.err.println("\n\nWarning on XEL: " + ex.getMessage());
    public void error(TransformerException ex) throws TransformerException {
        // logs on error log
        System.err.println("\n\nError on XEL: " + ex.getMessage());
        // and throws it
        throw ex;
    public void fatalError(TransformerException ex) throws TransformerException {
        // logs on error log
        System.err.println("\n\nFatal Error on XEL: " + ex.getMessage());
        // and throws it
        throw ex;
}When I have an error in the XSL stylesheet (for examples a missing closing tag), I can find on tomcat logs the real cause of the error:
[Fatal Error] :59:10: The element type "table" must be terminated by the matching end-tag "</table>".
Error on XEL: The element type "table" must be terminated by the matching end-tag "</table>".but on my web page is reported just the TransformerConfigurationException message that is:
"Could not compile stylesheet".
How can I display the real cause of the error directly on the web page?
Thanks,
Andrea

This code is part of a bigger project that let developers edit XSL stylesheets through a file upload on the system and we can't impose the use of any tool for checking the xsl. So, I need to display the transformer error on the web page.I see. This code is part of an editorial/developmental tool for developers to create and edit XSL stylesheets.
As part of the editorial process, XSL errors during editing can be considered a normal condition. In other words, it is normal to expect that the developers will generate XSL errors as they are developing stylesheets.
In this light, handling the XSL transformation errors is a business requirement that you need to handle. Using the Java Exceptions mechanisms, e.g. try / catch are inappropriate to handle business requirements, in my opinion.
I suggest that you look at how you handle the occurence of XSL errors differently than what you currently have. You need to:
(1) capture the Transformation exception on the server;
(2) extract the message from the exception and put it into a message that can be easily understood by the user;
The current error message that you have going to the web browser is not useful.
And you should not have the Transformation exception sent to the web browser either.
What you are attempting to do with the exception is not appropriate.
Handle the Transformation exception on the Business tier and use it to create a useful message that is then sent to the Presentation tier. In other words, do not send Java exceptions to web browser.
/>

Similar Messages

  • How can I change a minus figure on a web page to show in red? Firefox3.6.8 winXP

    How can I change a minus figure on a web page to show in red?

    I would assume that the website sends negative number with a special CSS class code or uses JavaScript to to change the style afterward.
    Did it ever work in Firefox?
    Do you see a error in the Tools > Error Console regarding this problem?
    "Clear the Cache": Tools > Options > Advanced > Network > Offline Storage (Cache): "Clear Now"
    "Remove the Cookies" from sites that cause problems: Tools > Options > Privacy > Cookies: "Show Cookies"
    Start Firefox in [[Safe Mode]] to check if one of your add-ons is causing your problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    See [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]

  • How can i display the login details in the Web Ui

    Hi All,
              How can i display the information regarding the person who logged into the Web Ui and where can i find the seetings regardin this.Please provide your valuable suggestions
    Regrads,
    Lakshman.P

    look at this link https://wiki.sdn.sap.com/wiki/display/CRM/WelcomeUserMessageinWeb+UI and you will solve your problem.
    have a nice day.

  • How can I display labels in the margin on last page

    I would like to display a label and a line (for a signature) on the last page of my report at the bottom of the report. This has to be displayed after all the other report details have been displayed and should appear only on the last page. How can I do it? Please help.

    You can move the label and the line for the signature into a frame and place the frame at the end of your report. Then set the "Print Object On" property for the frame to Last Page.

  • How can I refresh only a section of a web Page

    Hi,
    I am generating a web page using pl/sql. This web page has
    multiple sections in it. Only first ten records of each
    sections are displayed and the user can click on <prev> <next>
    button to display the prev/next 10 records. e.g.,
    Section 1 - Previous Names
    Smith
    Owen
    McDonald
    <<Prev 10 Next 10>>
    Section 2 - Previous Addresses
    111 State St.
    121 Altamont Ave.
    48 Apt 1., Bleeker St.
    <<Prev 10 Next 10>>
    Section 3 and so on ...
    My dilemma is that if a user wants to display the next ten
    records of a Section (e.g. Previous Names), I only want that
    part of the page to refresh instead of the entire page to reload
    again (similar to an ASP using Remote Scripting).
    Can this be done in Oracle using PL/Sql?
    Thanks
    Vic

    Each Section is independent of the other i.e., the change in the
    contents of one section shouldn't affect the contents of another
    section. This works fine. I am able to change the contents of
    a section without affecting the contents of another section. I
    basically keep track of each sections starting position.
    Though this works fine and gets me what I want, it's not very
    efficient. Each time a section's contents change (by clicking
    prev/next) the whole page needs to be reloaded. I want only the
    section that was clicked on to reload.
    In Active Server Pages (asp), a person can use "remote
    scripting" to reload only a part of the page without reloading
    the entire page. I was wondering if this could be done using
    PL/Sql as well?
    I could certainly use frames but that's not an option. Frames
    are a big no no here.
    Vic

  • How can I embed a Keynote presentation on a web page?

    I created a Keynote presentation using Keynote version 6.5 (OS X Yosemite). I found the "export as html" option, which creates an entire web page named index.html. I opened that web page in Dreamweaver, but I'm not talented enough to figure out how to turn that page into a proper index.html page, including the graphics, background, and links (etc.) that I want on my sites home page.
    I have also tried to embed the presentation onto a web page that I've already created, but I can't figure out how to do that, either.
    Can someone tell me if it's possible to embed a custom-sized Keynote presentation onto a web page and, if so, how?
    OR can you tell me how to edit the page that Keynote created when I open it up in Dreamweaver?
    I think the former would be easier, given what I've seen when I try to do the latter.
    I have been using Dreamweaver for many years - since before Adobe bought it - and the site I'm currently updating is already in Dreamweaver. That's why I'm asking about Dreamweaver (if you were curious).
    Of course, I've probably not provided all the information you would need to help me, so please ask questions. I won't be offended if they point out my ignorance!
    Thank you for any help you might provide.

    The only workaround I found was to use the desktop version of Keynote, which allowed me to export the presentation as a set of images to iPhoto. From there, they show up as an album and can be brought back to the iPad, and then played as a looping slide show in the pictures app. It worked perfectly.

  • How can I add a Last Update to a web page with a web app.

    I would like to know how to update a webpage whenever a web app item has been added or updated last.
    I have the tag {tag_lastupdatedate}  but it only works is only for the web app list or details page.
    I want to be able to add the date and time as to when the entire list was last updated. Any suggestions? thanks!

    Hi DLSAgency,
    There is a module called {module_lastupdated} and it will display the date when the web page it's on has been last updated, but there is no module that will display when the web app list inside that page was last updated. There no such functionality in BC.
    Cheers,
    Mario

  • How can I make Firefox go back to same web page position

    How can I set Firefox to go back to same web page position

    Just wait till Firefox ends loading web page. Then it'll be automatically set in to position when you have been leaving web page

  • How can I demo my mobile app on a web page? or standalone

    Is there a way to show my Flex mobile app in a browser?  either on a web page or standalone is ok.
    I'm using Flash Builder 4.6 to build a mobile app for iOs (iphone 4) and when I debug it, it shows the program in a window like the phone,
    Is there a way to wrap this up and give it to someone to run in a Flash-player-browser-like window? 
    thanks!
    steve

    You can do something similar to this by using Export Release Build and instructing FB to Export as "Signed AIR Package for installation on desktop"
    This will create a file that can be installed on a computer and behaves much like a debugger execution.  A few caveats are that the user will need to resize the window manually to match a "phone size" and mobile features (camera, gps, accelerometer, etc) will either be unavailable or behave very differently than on an actual phone (depending on your code implementation).
    Still, for most apps, this will give your audience a good feel of what your app will be like when released on the phone market/store.

  • How can I type over existing text on a web page?

    I would like to be able to type over existing text on a web page. This can be done by hitting the "insert" key in several applications; however, it does not work in Firefox.
    I'm running Firefox 31.0 and Windows 7.

    Unfortunately that is not possible in Firefox.
    The insert key is not supported (i.e. Firefox is always in insert mode), so you will have to delete the old text and type the new text.

  • Can I display the table content of a web page??

    Hi guys I am new to java and here I need to count the words in each table and display the table with largest number of words . This being a part of my huge project. Below is my code where I have succeeded in displaying all the tables present in the web page.But I need to count all the words in the table and display only that table which has largest number of words including all the tags. So java experts please help me with this piece of code...................
    import java.net.*;
    import java.io.*;
    import java.util.*;
    import java.util.regex.*;
    public class findtable{
      public static void main(String[] args) {
        String inputLine = null;
        String wholeHtml = "";
    int trcount=0;
        try{
          URL yahoo = new URL("http://books.google.com/books?q=+subject:%22+Science+Fiction+%22&as_brr=3&rview=1&source=gbs_hplp_fict");
          URLConnection yahooConnection = yahoo.openConnection();
          BufferedReader br = new BufferedReader
            (new InputStreamReader(yahooConnection.getInputStream()));
          int start = 0;
          while ((inputLine = br.readLine()) != null) {
            wholeHtml += inputLine;
            if (inputLine.contains("<table")){
                      ++start;
            if (start != 0) {
              System.out.println(inputLine);
            if (inputLine.contains("</table>")) {
              --start;
        catch (MalformedURLException me) {
           System.out.println("MalformedURLException: " + me);
        catch (IOException ioe) {
          System.out.println("IOException: " + ioe);
        }So any help would be really really appreciated....
    The code should take care of nested tables also..
    So guys looking forward for the generous help....

    I have already parsed the HTML and checked all the closing of tags and corrected the indent using Tidy and then I have applied this code so some other suggestions please

  • How can I get HTML source code of dynamic Web page ?

    Hi,
    I would like to write a program that can get HTML source code of some Web pages, but there are some dynamic Web pages that I can't do it with URL class. For example: http://www.europlex.ch/web/3schedule/showAll.jsp?context=schedule.
    Thank you very much for any solution.

    Thank you for your attention. I'm sorry because I could't describe it clearly. If you don't mind, please follow this step to understand my problem:
    In the browser, enter URL: http://www.europlex.ch/web/main.jsp?locale=_english
    Click on Schedule, you will see the page with Cinema name, Film, Time... I would like to write Java Program to get HTML code of only this Page (Not frame page).
    Do you have any idea ?
    Thanhks,

  • How can i count no.of links on a web page using VBA programmability

    hi,
    could anybody help me in getting the no.of links,no.of images in e-tester using custom programmability test.
    i'm new to e-tester.
    earlier i was using QTP. i know VBScript and how to getitemscount in QTP

    Hi pasumarthi,
    Great question! Try putting the following code in the Private Sub RSWVBAPage_afterPlay(). If you run into problems, please reply to this message. This code can also be copied into a custom vba test if you wanted to test the number of links and images on the page against a specific number.
    'Variable declarations
    Dim images As Collection
    Dim links As Collection
    Dim resultbImages As Boolean
    Dim resultbLinks As Boolean
    Dim item As Object
    'Initialize variables
    resultbImages = False
    resultbLinks = False
    'Get all the elements that have a tag of IMG
    resultbImages = RSWApp.om.FindElements(images, , "IMG")
    'Get all the elements that have a tag of A
    resultbLinks = RSWApp.om.FindElements(links, , "A")
    Call RSWApp.WriteToLog(, , "There are " & images.count & " images on the page")
    Call RSWApp.WriteToLog(, , "There are " & links.count & " links on the page")
    Message was edited by: kgehrke

  • How can I get a clearer Movie for my web page when trying to export a slide show in iPhoto.

    In iPhoto I am exporting a slide show in the display (size) 1280x800, the original images in the slide show are 600 dpi @ 11" x 8.96". I am using iPhoto 11 Version 9.4.2 on my MacBook Pro OSX version 10.8.2. I am using a wipe transition with a total slide show length of about 17 minutes long with about 96 images. The Display.m4v is 543.8 MB. The slide show is crystal clear when played before downloading to a movie, but once it is in a movie format it is no longer clear. What else can I tell you?

    600 dpi @ 11" x 8.96"
    600 x 11 = 66,000 pixels and you're reducing them to 1280...
    What happens if you export without the wipe?

  • How can I put a check out in a web page?

    Im trying to validate a credit card and send money from a credit card to another credit card.
    Now, I know there are a few examples of validating a credit card, but what about transfering money?
    Any help is appresiated. Thanks.

    Validation is very easy, both server side and client side. Check the ColdFusion Exchange section for "credit card validation" -- you should find several server side tags. You can Google "credit card javascript validation" and find many client side methods.
    Now for the second part of your question, transferring money from one card to another: This is forbidden in the credit card regulations and most likely illegal due to various money laundering laws. You can move money from a credit card to a merchant account to pay for goods or services, but you can't move it from credit card to credit card.
    Now you can have a credit card linked to your merchant account (actually a debit card) -- but you need a merchant account.

Maybe you are looking for

  • HP OfficeJet G55xi won't scan in 300x300 dpi

    I've also posted this question over on the Tiger forum 1/30, but to date, no responses. Thought try other G4 users...greatly appreciate any suggestions/recommendations! I'm having a scanning problem with my HP OfficeJet G555xi All-in-One. I've contac

  • Dynamic event multiple loops

    I'm trying to see if I can use one Dynamic User Event to control multiple Event Structures. It seems that sometimes once a dynamic event occurs and its "interrupt" is answered by an event case, other VIs only have a short amount of time (<50ms) to re

  • Dual 1.8Ghz G5 Power Mac support?

    Apple lists that you need a minimum of Dual G5 2.0Ghz processing power, is that just for performance or will it not even install/run on anything slightly less?

  • Not enough power mi

    so i bought a new Forton Blue 500watt a good psu.... everything should be powered sufficiently now... my micro still won't recognize.... anyone else have "power" issues?

  • I think I broke Photoshop CS5

    Greetings and cordial salutations, I wonder if you could help me, yesterday I accessed Photoshop cs5 preferences (windows 7) in order to change image interpolation from bicubic smooth to bicubic sharper and then back again. Memories are blurred but I