XML
  Home arrow XML arrow Page 2 - Using Script Extensions in Xalan-Java
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
XML

Using Script Extensions in Xalan-Java
By: Seamus Donohue
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 9
    2004-06-16

    Table of Contents:
  • Using Script Extensions in Xalan-Java
  • Xalan-Java Scripting Extensions, Resources, Requirements
  • The Scripting Scenario
  • Plugging the Scripts into the XSLT Stylesheet
  • Python
  • VBScript
  • PerlScript
  • Running the Stylesheet

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Using Script Extensions in Xalan-Java - Xalan-Java Scripting Extensions, Resources, Requirements


    (Page 2 of 8 )

    Xalan-Java (Xalan-J) supports extension elements and functions written in scripting languages supported by the Bean Scripting Framework (BSF). A complete explanation of this support is available in the Xalan-Java documentation at http://xml.apache.org/xalan-j/extensions.html.

    This article looks only at function extensions, that is, calling script functions from XSLT. We will look at scripting languages that are not covered in the Xalan documentation, in particular, Python, VBScript, and PerlScript. In addition, we will show how Java Object instances, created in XSLT as part of the Java language extensions mechanism, are passed to these scripts and utilized by them. These samples will provide a solid foundation on which to build more complicated script-based extensions.

    Resources Provided with this Article

    The resources listed in the following table are provided with this article:

    Resource Description
    build.xmlAnt build script used to build and run the sample XSLT script.
    build.propertiesProperties used by the Ant script.
    xml/bonus_plan_table.txtThe data used by the Java lookup bean used in the XSLT script.
    xml/sample_in.xmlSample input XML file.
    xml/sample_in.xsdInput XML document schema.
    xml/sample_out.xsdOutput document schema.
    xml/sample_rules.xsltThe XSLT stylesheet used in this article.
    src/../LookupTable.javaThe LookupTable Bean class used in the stylesheet.
    src/../ActiveScriptEngine.javaThe patched BSF Java code required to support ActiveScripts.

    Software Requirements to Run the Example Provided with this Article

    The script extensions described in this article are based on Xalan-J version 2.6.0, which is available from http://xml.apache.org/xalan-j. You will also need a recent version of Ant to run the sample XSLT provided. The sample XSLT uses JavaScript, Jython, PerlScript, and VBScript. The requirements for each scripting language are listed in the following table:

    ScriptRequirements
    JavaScriptRequire js.jar, which is available from
    ftp://ftp.mozilla.org/pub/js/rhino15R4.zip.
    PythonRequires jython.jar, which is available from http://www.jython.org/download.html.
    VBScript (Win32 only)Requires bsfactivescriptengine.dll, bsfactivescriptengine_g.dll, and msvcp60.dll, which are available in the BSF 2.2 download from http://oss.software.ibm.com/developerworks/projects/bsf.
    PerlScript (Win32 only)Requires the same DLLs as above for VBScript and the installation of PerlScript from http://www.activestate.com/.

    The required JAR files must be in the classpath used by the Xalan processor. The active script DLL libraries directory must be added to the PATH environment variable. The directory containing the DLL may also be specified as a property passed to the JVM java.library.path property, for example:

    java -Djava.library.path=D:/apps/bsf-2_2/lib/win32 etc.

    BSF Requirements

    BSF version 2.2 is supplied with Xalan-J (see http://oss.software.ibm.com/developerworks/projects/bsf). This code is now superseded by BSF 2.3 (see http://jakarta.apache.org/bsf/index.html); however, Xalan continues to integrate with the BSF 2.2 code base. It is not possible to replace the BSF 2.2 JAR file with the BSF 2.3 JAR file, because package names and APIs have changed. The BSF 2.2 jar is sufficient to run JavaScript and Python scripts; however, it will not correctly run the Win32 ActiveScripts (VBScript, PerlScript, and so on). To run these scripts correctly, it is necessary to patch the BSF 2.2 JAR file supplied with Xalan. The patch procedure is described in the appendix at the end of this article.

    More XML Articles
    More By Seamus Donohue


     

    XML ARTICLES

    - Using Regions with XSL Formatting Objects
    - Using XSL Formatting Objects
    - More Schematron Features
    - Schematron Patterns and Validation
    - Using Schematron
    - Datatypes and More in RELAX NG
    - Providing Options in RELAX NG
    - An Introduction to RELAX NG
    - Path, Predicates, and XQuery
    - Using Predicates with XQuery
    - Navigating Input Documents Using Paths
    - XML Basics
    - Introduction to XPath
    - Simple Web Syndication with RSS 2.0
    - Java UI Design with an IDE







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek