[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: calling external java functions via XSLT
| Currently the ability to call java external functions within XSLT is not | a part of the initial XSLT spec. Does anyone out there wish it was | or realize a need for this type of thing. Don, XSLT 1.0 defines both an extension function and extension element mechanism. Many vendors' XSLT 1.0 implementations support this feature in one or more programming languages, Java included. The XSLT 1.0 specification does not specify the *implementation* details for implementing the extension functions -- or put any limit on what kind of languages can be used to write extensions -- but you'll find a great similarity in the way that engines like XT, Saxon, LotusXSL/Xalan, OracleXSL do their java extension functions (mostly an XML namespace is the difference). Here's a simple example that shows creating a new Date using java.util.Date using the extension namespace for java extension functions that the Oracle XSLT Processor recognizes. For other processors, it should be similar. <!-- Enrollment.xsl --> <xsl:stylesheet version="1.0" exclude-result-prefixes="date" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:date="http://www.oracle.com/XSL/Transform/java/java.util.Date"> <xsl:output indent="yes" doctype-system="Enrollment.dtd"/> <xsl:param name="School"/> <xsl:template match="/"> <enrollment institution-id="{$School}" date = "{date:toString(date:new())}"> <xsl:for-each select="courses/row"> <class id = "{course}"> <xsl:for-each select="students/students_row"> <attendee> <first-name><xsl:value-of select="name"/></first-name> <age><xsl:value-of select="age"/></age> </attendee> </xsl:for-each> </class> </xsl:for-each> </enrollment> </xsl:template> </xsl:stylesheet> ______________________________________________________________ Steve Muench, Lead XML Evangelist & Consulting Product Manager Business Components for Java & XSQL Servlet Development Teams Oracle Rep to the W3C XSL Working Group *************************************************************************** This is xml-dev, the mailing list for XML developers. To unsubscribe, mailto:majordomo@x...&BODY=unsubscribe%20xml-dev List archives are available at http://xml.org/archives/xml-dev/ ***************************************************************************
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|