Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

JSP xsl/xml Transformer Error

Posted on 2004-09-09
13
361 Views
Last Modified: 2013-11-19
<%  
Hello all,

This JSP was working fine for weeks, now all of sudden this code is nto working. This is the Error:
*******
javax.xml.transform.TransformerException: The element type "input" must be terminated by the matching end-tag "</input>".  ********
When I'm seeing XML output without stylesheet its showing fine. But when I try this transform its not working. my XSL is still same which worked all this weekssss I checked my xsl its fine no error.


My JSP code:

<%@ page import="javax.xml.transform.*, javax.xml.transform.stream.*, java.net.*, java.io.*, org.apache.xpath.*, org.apache.xpath.objects.XObject,org.w3c.dom.*, com.mid.mm.servlet.*"%>

try {    
   StringBuffer reqURL = request.getRequestURL();
   String contextURL = reqURL.substring(0,reqURL.lastIndexOf(request.getServletPath()));    
   URL url = new URL(contextURL + "/resource/GetResourceHierarchy");        
   HttpURLConnection conn = (HttpURLConnection)url.openConnection();            
   conn.setDoInput(true);                
   TransformerFactory tFactory = TransformerFactory.newInstance();
      ServletContext context = getServletContext();
   InputStream is = context.getResourceAsStream("/stylesheets/LiveResourceTree.xsl");
   Transformer transformer = tFactory.newTransformer(new StreamSource(is) );
   transformer.transform(new StreamSource(conn.getInputStream()), new StreamResult(out));

} catch (Exception ex) {out.println( ex.toString() );}
%>

Any other way to improve my code.

Regards,
H
0
Comment
Question by:princehyderabad
  • 4
  • 3
  • 3
  • +2
13 Comments
 
LVL 2

Expert Comment

by:Paullkha
ID: 12021016
>>JSP xsl/xml Transformer Error
>>50 points
Good luck....you'll need it!
0
 

Author Comment

by:princehyderabad
ID: 12021194
howz that ...
0
 
LVL 11

Expert Comment

by:sompol_kiatkamolchai
ID: 12023257
Could you dump the file that contains <input> tag?
I think there is no matching for this.
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:princehyderabad
ID: 12023523
hi sompol,

I hv no idea where is the <input> tag. I cant see this tag in jps nor in xsl.
Just in JSP i can find only "InputStream"

Thx
Hyd
0
 
LVL 11

Expert Comment

by:sompol_kiatkamolchai
ID: 12023553
Could you paste LiveResourceTree.xsl and this resource?

/resource/GetResourceHierarchy
0
 

Author Comment

by:princehyderabad
ID: 12023636
Right now I 'm at home cant paste you that code. But 1 thing, /resource/GetResourceHierarchy is working fine with not error. I mean when I try on browse without xsl, that GetResourceHierarchy servlet is giving correct xml output. I dont know why all of sudden this is happening, I mean this jsp, xsl stuff was working fine for weekssss...

0
 
LVL 21

Expert Comment

by:MogalManic
ID: 12025040
One way to improve your code is to have better error handling.  JAXP exceptions are notorious for nesting their exceptions and the file/line information can be imbedded inside the stack history.  This is my exception handler for transformations:
      SourceLocator loc = null;
      StringBuffer msg = new StringBuffer();
      msg.append("<li>")
            .append((exception.getMessage() != null)
                  ? exception.getMessage() : exception.getClass().getName())
            .append("</li>");

      while (exception!=null)
      {
            loc=null;
            String locMsg="";
            if (exception instanceof TransformerException) {
                  loc = ((TransformerException) exception).getLocator();
            }
            if (exception instanceof SAXParseException) {
                  loc = new SAXSourceLocator((SAXParseException) exception);
            }
            if (loc != null) {
                  locMsg = ":Error occured at line "+ loc.getLineNumber()
                                    + " and column "
                                    + loc.getColumnNumber()
                                    + " from file "
                                    + loc.getSystemId();
            }
            msg.append("<li>").append(exception.getClass().getName()).append(':')
                  .append(exception.getMessage())
                  .append(locMsg)
                  .append("</li>");
            if (exception.getCause()==null || exception.getCause()==exception)
                  break;
            exception=exception.getCause();
      }
      return msg.toString();
0
 
LVL 21

Expert Comment

by:MogalManic
ID: 12025052
the exception
javax.xml.transform.TransformerException: The element type "input" must be terminated by the matching end-tag "</input>".  
says it all.  The error is in the XSL (not XML).  All of you <input> tags must be well formed XML.  So they must be closed like this:
<input type...name... />
   OR
<input ...></input>
0
 

Author Comment

by:princehyderabad
ID: 12046524
Morning Everyone,
I'm Back from weekend, well guys as I told u earlier my servlet is giving correct output ie (/resource/GetResourceHierarchy) when i tried on browser. But seems like only error with transform. And I'm tellikng you I worked with same stylesheet and it has been working for last weeks and all of sudden last week I gotthis error and today also same error unable to figure out.
javax.xml.transform.TransformerException: The element type "input" must be terminated by the matching end-tag "</input>".
      at org.apache.xalan.transformer.TransformerImpl.fatalError(Unknown Source)
      at org.apache.xalan.transformer.TransformerImpl.transform(Unknown Source)
      at org.apache.xalan.transformer.TransformerImpl.transform(Unknown Source)
      at org.apache.xalan.transformer.TransformerImpl.transform(Unknown Source)

My JSP code is already above. And there is no <input> tag in stylesheet dont know from where it is getting <input> unterminated ?????
0
 
LVL 21

Expert Comment

by:MogalManic
ID: 12051013
Can you post your stylesheet?
0
 
LVL 11

Expert Comment

by:sompol_kiatkamolchai
ID: 12056532
Would it be possible to post stylesheet since I've never seen it before?
0
 

Accepted Solution

by:
ee_ai_construct earned 0 total points
ID: 12414667
Question answered by asker or dialog valuable.
Closed, 300 points refunded.
ee_ai_construct (replacement part #xm34)
Community Support Admin
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Title # Comments Views Activity
Create 4 <div> below each other in php 2 69
jdbc error in jsp application 20 63
tomcat startup error 5 104
iterator/ListIterator approach 17 39
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

829 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