JSP xsl/xml Transformer Error

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();            
   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.

Who is Participating?
Question answered by asker or dialog valuable.
Closed, 300 points refunded.
ee_ai_construct (replacement part #xm34)
Community Support Admin
>>JSP xsl/xml Transformer Error
>>50 points
Good luck....you'll need it!
princehyderabadAuthor Commented:
howz that ...
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Could you dump the file that contains <input> tag?
I think there is no matching for this.
princehyderabadAuthor Commented:
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"

Could you paste LiveResourceTree.xsl and this resource?

princehyderabadAuthor Commented:
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...

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();
            .append((exception.getMessage() != null)
                  ? exception.getMessage() : exception.getClass().getName())

      while (exception!=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();
            if (exception.getCause()==null || exception.getCause()==exception)
      return msg.toString();
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... />
<input ...></input>
princehyderabadAuthor Commented:
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 ?????
Can you post your stylesheet?
Would it be possible to post stylesheet since I've never seen it before?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.