OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: calling external java functions via XSLT

[ Lists Home | Date Index | Thread Index ]
  • From: "Steve Muench" <smuench@us.oracle.com>
  • To: "Donald Lingle" <ulingdg@lexis-nexis.com>
  • Date: Tue, 25 Apr 2000 09:09:42 -0700

| 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@xml.org&BODY=unsubscribe%20xml-dev
List archives are available at http://xml.org/archives/xml-dev/
***************************************************************************




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS