InnovationQ will be updated on Sunday, Oct. 22, from 10am ET - noon. You may experience brief service interruptions during that time.
Browse Prior Art Database

Accessing Java* objects from inside portable XSLT stylesheets (without XSLT processor specific extensions)

IP.com Disclosure Number: IPCOM000011906D
Original Publication Date: 2003-Mar-25
Included in the Prior Art Database: 2003-Mar-25
Document File: 3 page(s) / 17K

Publishing Venue



Currently there is no standardized way to access Java* objects from inside an XSL transformation. Many XSLT processors like Xalan offer a way to invoke Java* methods, but there is no standard available, which would work with any XSLT processor. Thus stylesheet designers currently must write none portable XSLT stylesheets to access Java* objects in their XSL transformations. The method described here uses only the Java* API for XML Processing (JAXP) 1.1 standard features to invoke the stylesheet and JDK 1.4 features to retrieve the Java* objects. It allows to write XSLT stylesheets that are portable, because they do not need to use XSLT processor specific extensions.

This text was extracted from a PDF file.
At least one non-text object (such as an image or picture) has been suppressed.
This is the abbreviated version, containing approximately 52% of the total text.

Page 1 of 3

  Accessing Java* objects from inside portable XSLT stylesheets (without XSLT processor specific extensions)

  A method is disclosed, which allows you to access Java* objects from inside an XSL transformation, without the need of XSLT processor specific stylesheet extensions.

    The main idea is to combine the XSLT document() function, which allows you to retrieve external XML documents in a stylesheet, with the XMLEncoder functionality of JDK 1.4. The "glue code" is an URIResolver, which resolves the Java* objects and returns them as XML documents:

The XSLT document() function allows you to access further (external) XML documents from inside an XSLT stylesheet. To enhance the XSLT processor's URI resolution mechanism, the JAXP
1.1 standard allows you to register a custom URIResolver that will be used by the XSLT processor to resolve URIs - including the URIs used as arguments in the XSLT document() functions. Thus with an URIResolver that can resolve Java objects and return them as XML documents, it is possible to access Java objects and their properties from normal and portable XSLT stylesheets. The only piece of code needed to implement this idea, is the URIResolver:

    This URIResolver needs only to allow for the registration of Java objects as key-value pairs and to be able to retrieve them using the registration key. The registration key can then be used inside the XSLT stylesheets as argument for the document() function. The resolved Java objects can be transformed into XML documents using the JDK 1.4 XMLEncoder. This way the property "data" of the Java Object "t1", which would be retrieved in Java with t1.getData(), can be retrieved in an XSLT stylesheet with the following expression:

The following sequence diagram illustrates the Java object resolution from inside an XSL transformation:

Page 2 of 3

  First the Java object must be registered with the URIResolver. For example, an object of the following class can be registered:
package javajaxp;
public clas...