home
NEWS       BLOGS       FORUMS       NEWSLETTERS       RESEARCH       EVENTS       DIGITAL LIBRARY       CAREERS  
Network Computing Network Computing Powered by InformationWeek Business Technology Network

IMMERSE YOURSELF:

SOA

  |

Data Center

  |

802.11n

  |

Data Privacy

  |
APO  |

Virtualization

  |

NAC

  |

Security

  |

Network Mgmt

  |

Enterprise Apps

  |

Storage & Servers



Netdesign Manual

Part 3

Java XML Programmers Reference

Chapter 11: XML Tools for Information Appliances


October 8, 2001


Brought to you by:





Check It Out!

Package org.apache.xalan.xsltc

There are no Javadocs for this package, but let's hope Apache changes this soon. The package contains the interfaces and classes used and implemented by translets. Remember that translets are compiled XSL stylesheets. The primary interfaces and classes in this package are:

  • Translet
  • TransletOutputHandler
  • TransletException

We will discuss each of these in this section.

Interface Translet
org.apache.xalan.xsltc

public interface Translet

A class that implements interface Translet must be able to transform XML input into the output specified by the mapping in the original XSL stylesheet. The XSLTC library creates classes that implement this interface; you shouldn't ever need to write code that implements interface Translet. You will, however, need to call the transform() method to tell the implementing class when to begin the transformation process.

The transform() Method

public void transform(DOM Document,

TransletOutputHandler handler)

throws TransletException

A transformation requires two items: a org.apache.xalan.xsltc.dom.DOMImpl object (which unfortunately carries no documentation!) and an object implementing the org.apache.xalan.xsltc.TransletOutputHandler interface. DOMImpl implements interface org.apache.xalan.xsltc.DOM. These two items are created in your application code and given to the translet.


Arguments

Arguments

Type

Effect

Document

org.apache.
xalan.xsltc.DOM

The parsed XML input document to be transformed. It is a DOM tree implementing the DOM interface, and so is usually an instance of the DOM implementation class org.apache.xalan.xsltc.dom.DOMImpl

handler

org.apache.
xalan.xsltc.
Translet
OutputHandler

The callback handler, which the translet uses to notify your application of transformed elements, attributes, and data. Conceptually very similar to SAX's org.xml.sax.DocumentHandler.

Usage and Examples

To create an instance of a class which implements org.apache.xalan.xsltc.Translet, we use the Java reflection API:

Class cls = Class.forName("MyClass");
Translet xlet = (Translet)cls.newInstance();
xlet.tranform(dom, handler);

"MyClass" is the name of the class generated by XSLTC during compilation (we go over how to compile an XSL stylesheet in the section Example: Compiling and Using a Translet). xlet.transform() method can now be called to perform the transformation.

Interface TransletOutputHandler
org.apache.xalan.xsltc

public interface TransletOutputHandler

This interface contains the callback methods which a translet calls as it transforms XML input to some output. Conceptually, a translet behaves just like a SAX parsing engine, calling back into interface org.apache.xalan.xsltc.TransletOutputHandler instead of interface org.xml.sax.DocumentHandler or org.xml.sax.ContentHandler. However, the designers of XSLTC have chosen natively to support TransletOutputHandler rather than SAX 1.0's DocumentHandler and SAX 2.0's ContentHandler.

Conceptually, a translet behaves just like a SAX parsing engine, calling back into interface org.apache.xalan.xsltc.TransletOutputHandler instead of interface org.xml.sax.DocumentHandler or org.xml.sax.ContentHandler.

SAX 1.0 is supported by wrapping a org.apache.xalan.xsltc.runtime.TextOutput object around an object implementing TransletOutputHandler. Since SAX is the de facto push parser standard, we'll focus on how to use it with translets rather than the proprietary TransletOutputHandler. However, let's briefly examine some of TransletOutputHandler to further understand how translets work.


Callback Methods

public void startDocument()

throws TransletException

public void endDocument()

throws TransletException

public void characters(char[] characters, int offset, int length)

throws TransletException

public void startElement(String elementName)

throws TransletException

public void endElement(String elementName)

throws TransletException

public void attribute(String attributeName, String attributeValue)

throws TransletException

public void comment(String comment)

throws TransletException

public void processingInstruction(String target, String data)

throws TransletException

Although this isn't complete, you should immediately see the similarities between this interface and SAX 1.0's org.xml.sax.DocumentHandler and SAX 2.0's org.xml.sax.ContentHandler.

A helper class is given to us to enable SAX 1.0 support. org.apache.xalan.xsltc.runtime
TextOutput
not only implements interface TransletOutputHandler, but it also maps TransletOutputHandler methods to corresponding org.xml.sax.DocumentHandler methods.


PAGE: 1 | 2 | 3 | 4 | 5 | 6 | NEXT PAGE
 





Ready to take that job and shove it?

Function:

Keyword(s):

State:
SPONSOR
RECENT JOB POSTINGS
CAREER NEWS
Go beyond Google and get vertical. These specialized search sites will help you find the business information you need -- fast.

Ari Balogh was named to the post of chief technology officer as the companys for a "realignment" of employees.










InformationWeek U.S. IT Salary Survey 2008
Salaries for business technology professionals are falling. Here's what you need to know in order to make good hiring decisions and personal career choices. Download Today
 
ROLLING RIGHT ALONG
Follow key Network Computing Reviews from conception to completion. This Week: Holistic APM.



Network Computing Reports Emerging Enterprise Podcast Series: Secrets to Success








TechSearch


Microsite of the Week


Powerful Information at Your Fingertips



InformationWeek Business Technology Network
InformationWeekInformationWeek 500InformationWeek 500 ConferenceInformationWeek AnalyticsInformationWeek CIO
InformationWeek EventsInformationWeek ReportsInformationWeek MagazinebMightyByte and SwitchDark Reading
Digital LibraryIntelligent EnterpriseInternet EvolutionNetwork ComputingNo Jitter
space
Techweb Events Network
InteropVoiceConWeb 2.0 ExpoWeb 2.0 SummitEnterprise 2.0 ConferenceMobile Business ExpoSoftware ConferenceCSI - Computer Security Institute
Black HatGTECEnergy CampMashup CampStartup Camp
space
Light Reading Communications Network
Light ReadingLight Reading EuropeUnstrungLight Reading's Cable Digital NewsConstantinopleInternet Evolution
Heavy ReadingLight Reading Live!Light Reading InsiderEthernet ExpoOptical ExpoTeleco TVTower Technology Summit
space
Financial Technology Network
Advanced TradingBank Systems & TechnologyInsurance & TechnologyWall Street & TechnologyAccelerating Wall StreetBank Systems & Technology Executive SummitBuyside Trading SummitInsurance & Technology Executive Summit
space
Microsoft Technology Network
MSDN MagazineTechNetThe Architecture Journal
space
App Infrastructure   |   Messaging & Collaboration   |   Network & Systems Mgmt   |   Network Infrastructure   |   Security  |   Storage & Servers   |   Wireless   |   Enterprise Apps
About Us  |  Contact Us  |  Site Map  |  Technology Marketing Solutions  |  Advertising Contacts  |   Briefing Centers
Copyright © 2008  United Business Media LLC  |  Privacy Statement  |  Terms of Service  |  Your California Privacy Rights