Home arrow XML arrow Page 8 - Using Script Extensions in Xalan-Java
XML

Using Script Extensions in Xalan-Java


This article 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.

Author Info:
By: Seamus Donohue
Rating: 5 stars5 stars5 stars5 stars5 stars / 14
June 16, 2004
TABLE OF CONTENTS:
  1. · Using Script Extensions in Xalan-Java
  2. · Xalan-Java Scripting Extensions, Resources, Requirements
  3. · The Scripting Scenario
  4. · Plugging the Scripts into the XSLT Stylesheet
  5. · Python
  6. · VBScript
  7. · PerlScript
  8. · Running the Stylesheet

print this article
SEARCH DEVARTICLES

Using Script Extensions in Xalan-Java - Running the Stylesheet
(Page 8 of 8 )

The complete stylesheet is available here. The stylesheet contains all four script language implementations and is configured to run the JavaScript functions. To select a different script implementation, set the appropriate variable to 1 in the stylesheet section shown below, and reset all the other use-script variables to 0. The variable settings below will use VBScript function implementations.

<!-- SWITCH ON/OFF SCRIPT LANGUAGES HERE -->
<xsl:variable name="use-javascript" select="0"/>
<xsl:variable name="use-jpython" select="0"/>
<xsl:variable name="use-vbscript" select="1"/>
<xsl:variable name="use-perlscript" select="0"/>

Ant Configuration

The samples are run using the build.xml Ant script. This script uses properties specified in the build.properties file. Ensure that the properties in this file are set correctly for your environment.

#product homes
xalan.home =d:/apps/xalan-j_2_6_0
js.home  =d:/apps/rhino1_5R4
jython.home =d:/apps/jython-2.1

When the properties are correctly set, run the XSLT execute:

ant run

The run target will patch the BSF JAR file if required, build the Java Lookup class used in the scripts as necessary, and then call the Xalan command line tool, which transforms the input file ./xml/ sample_in.xml into ./xml/out.xml using the XSLT file ./xml/ sample_rules.xslt.


DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

blog comments powered by Disqus
XML ARTICLES

- Open XML Finally Supported by MS Office
- XML Features Added to Two Systems
- 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

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials