Skip to Content
Java and XSLT
book

Java and XSLT

by Eric M. Burke
September 2001
Intermediate to advanced
528 pages
13h 46m
English
O'Reilly Media, Inc.
Content preview from Java and XSLT

XSLT as a Code Generator

For performance reasons, EJB components typically return dependent objects rather than many individual fields. These are implemented as read-only classes that encapsulate a group of related fields. Borrowing an example from Enterprise JavaBeans by Richard Monson-Haefel (O’Reilly), Example 8-13 shows a typical dependent object.

Example 8-13. Address.java

public class Address implements java.io.Serializable {

    private String street;
    private String city;
    private String state;
    private String zip;

    /**
     * Construct a new dependent object instance.
     */
    public Address(String street, String city, String state, String zip) {
        this.street = street;
        this.city = city;
        this.state = state;
        this.zip = zip;

    }
    
    public String getStreet(  ) {
        return this.street;
    }
    
    public String getCity(  ) {
        return this.city;
    }
    
    public String getState(  ) {
        return this.state;
    }
    
    public String getZip(  ) {
        return this.zip;
    }
}

Now, rather than containing numerous fine-grained methods, an entity bean can provide a single method to retrieve an instance of Address. This reduces load on the network and database and makes the code somewhat easier to understand. As you can see, the Address class is very straightforward. It has a constructor that initializes all fields and a series of get methods.

Although Address is small, some dependent objects may have dozens of fields. These are tedious to write at best, resulting in a typing exercise rather than programming creativity. XSLT can help by acting as a simple ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning XSLT

Learning XSLT

Michael Fitzgerald
XSLT

XSLT

Doug Tidwell
XSLT and XPATH: A Guide to XML Transformations

XSLT and XPATH: A Guide to XML Transformations

John Robert Gardner, Zarella L. Rendon

Publisher Resources

ISBN: 0596001436Supplemental ContentCatalog PageErrata