[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Translet Stability Issue

Subject: Translet Stability Issue
From: Jeff Harman <jharman@xxxxxxxxxxxxxxx>
Date: Tue, 07 Jan 2003 13:06:22 -0500
translet
I am having some stability problems with translets. On approxamitly 50%
of the translations I receive an error that I know is bogus.  The other 50%
of the time it works fine.  Any suggestions or fixes?

I am using the Xalan 2.4.1

I have precompiled my XSLs into class files using the following:
-----------------------------------------------------------------------
java org.apache.xalan.xsltc.cmdline.Compile -d translets -p
com.websterbank.translets <xslfile>

The latest error is
-----------------------------------------------------------------------
         The element type "br" must be terminated by the matching end-tag
"</br>".
         at 18, 71

I execute the translets with the following code:
-----------------------------------------------------------------------
public class PageBuilder { 

	TransformerFactory tFactory;
	boolean			   useTranslet ;
	
	public PageBuilder() {
		super();
		System.setProperty("javax.xml.transform.TransformerFactory","org.apache.xalan.xsltc.trax.TransformerFactoryImpl");
		Log.write ( "PageBuilder.constructor: Factory" ) ;
		tFactory = TransformerFactory.newInstance();
		cache = new Hashtable();
		useTranslet = true ;
	}
	
	public void handle (PrintWriter out, String stylesheet, Document
doc) {
		Log.write ( "PageBuilder.handle: XML DOM Data" ) ;
		DOMWriter wr = new DOMWriter () ;
		wr.write ( doc, new PrintWriter( Log.getLogStream()));

		if ( useTranslet ) 
			handle_translet ( out, stylesheet, doc ) ;
		else
			handle_translet ( out, stylesheet, doc ) ;
	}

	public void handle_translet (PrintWriter out, String stylesheet,
Document doc) {
		Log.write ( "PageBuilder.handle - translets" ) ;
		Log.write ( "PageBuilder.handle - translets: " + stylesheet  )
;

		String transName = stylesheet.substring(
stylesheet.lastIndexOf("/")+1,stylesheet.lastIndexOf(".")) ;
	    transName = "com.translets." + transName ;
		
		Translet translet = null ;
		
		try {
			Class transClass = Class.forName( transName ) ;
			translet         = (Translet)transClass.newInstance() ;
		} catch ( Exception e ) {
			Log.write ( "PageBuilder.handle - translets: Class
Lookup Failure - " + transName ) ;
		}
		
		if ( translet == null ) {
			handle_basic ( out, stylesheet, doc ) ;
		} else {
			Log.write ( "PageBuilder.handle - translets: Class - "
+ transName ) ;
			
			try {
				// Get the XML input document and the
stylesheet.
				Log.write ( "PageBuilder.handle - translets:
Constructors" ) ;
				DOMImpl dom              = new DOMImpl () ;
				SAXParserFactory factory =
SAXParserFactory.newInstance();
				SAXParser parser         =
factory.newSAXParser();
				XMLReader reader         =
parser.getXMLReader();
				DTDMonitor _dtdMonitor   = new
DTDMonitor();
				StringWriter writer      = new StringWriter () ;
				PrintWriter prWriter     = new PrintWriter (
writer ) ;
				DOMWriter domWriter      = new DOMWriter
() ;
				
				Log.write ( "PageBuilder.handle - translets:
Document Translation" ) ;
				domWriter.write( doc, prWriter ) ;
				String stringDOM = writer.toString() ;
				StringReader strReader = new StringReader
( stringDOM ) ;
				reader.setContentHandler( dom.getBuilder()
);
				reader.parse( new InputSource (strReader)
);
				DefaultSAXOutputHandler saxHandler =
new DefaultSAXOutputHandler(out);
				TextOutput textOut = new
TextOutput(saxHandler) ;
				
				textOut.setType ( TextOutput.HTML ) ;
				textOut.setIndent( false ) ;
				
				Log.write ( "PageBuilder.handle - translets:
Transforming" ) ;
				translet.transform( dom, textOut );
				Log.write ( "PageBuilder.handle - translets:
Done Transforming" ) ;
				
			} catch ( SAXParseException se ) {
				Log.write ( "PageBuilder.handle - translets:
Transform Error" ) ;
				Log.write ( "        " +  se.getMessage() ) ;
				Log.write ( "        at " +  se.getLineNumber()
+ ", " + se.getColumnNumber() ) ;
			} catch ( Exception e ) {
				Log.write ( "PageBuilder.handle - translets:
Transform Error" ) ;
				Log.write ( "        " +  e.toString() ) ;
			}
		}
	}

	public void handle_basic (PrintWriter out, String stylesheet,
Document doc) {
                  basic XSL translation.....
	}

}


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.