xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dles...@locus.apache.org
Subject cvs commit: xml-site/targets/xalan extensions.html
Date Wed, 02 Feb 2000 16:04:09 GMT
dleslie     00/02/02 08:04:08

  Modified:    targets/xalan extensions.html
  Log:
  Editorial revisions
  
  Revision  Changes    Path
  1.4       +36 -23    xml-site/targets/xalan/extensions.html
  
  Index: extensions.html
  ===================================================================
  RCS file: /home/cvs/xml-site/targets/xalan/extensions.html,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- extensions.html	2000/02/01 22:12:07	1.3
  +++ extensions.html	2000/02/02 16:04:06	1.4
  @@ -45,7 +45,7 @@
   </FONT></TD></TR></TABLE><BR><A name="supported-lang"><!--anchor--></A>
   <TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="666699"
colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD
bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD
bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD
bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif"
size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0"
width="2"><B>Supported languages</B></FONT></TD><TD bgcolor="#017299"
width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif
" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1"
width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0"
width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0"
height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD
bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD
width="10">&nbsp;</TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
   <P>Xalan uses the Bean Scripting Framework (BSF), an architecture for incorporating
scripting into Java applications and applets. BSF allows an application to take advantage
of scripting while being independent of any specific scripting language. To date, we have
tested extensions implemented in Java and JavaScript. Other languages with BSF support appear
in the table below.</P>
  -<P>BSF requires two JAR files on the classpath: bsf.jar and bsfengines.jar. These
two JAR files are shipped with Xalan, and that is all that is required for Java extensions.
The additional JAR files or DLLs required to support extensions in other languages are listed
in the table below. These files are available from the sources indicated and are not shipped
with Xalan.</P>
  +<P>BSF requires two JAR files on the class path: bsf.jar and bsfengines.jar. These
two JAR files are shipped with Xalan, and that is all that is required for Java extensions.
The additional JAR files or DLLs required to support extensions in other languages are listed
in the table below. These files are available from the sources indicated and are not shipped
with Xalan.</P>
   <TABLE border="0" cellpadding="2" cellspacing="2" width="100%">
     <TR>
       <TD align="left" bgcolor="#a0ddf0" colspan="1" rowspan="1" valign="top"><FONT
color="#000000" face="arial,helvetica,sanserif" size="-1"><B>Language</B>&nbsp;
  @@ -117,10 +117,10 @@
   </TABLE>
   </FONT></TD></TR></TABLE><BR><A name="basic-pattern"><!--anchor--></A>
   <TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="666699"
colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD
bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD
bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD
bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif"
size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0"
width="2"><B>The basic pattern</B></FONT></TD><TD bgcolor="#017299"
width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" 
vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1"
width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0"
width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0"
height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD
bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD
width="10">&nbsp;</TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
  -<P>The stylesheet below uses an extension element and an extension function to transform
each &lt;deadline numdays=&quot;<I>n</I>&quot;/&gt; element in
the XML source into a statement indicating the date by which a customer should receive a response
to an enquiry.</P>
  +<P>Let's examine a simple example. The stylesheet below uses an extension element
and an extension function to transform an element in the XML source into a statement in the
output indicating the date by which a customer can expect to a response to a given enquiry.</P>
   
  -<P>The extension element contains a multiplier attribute, which is used to set a
variable in the extension. The extension function computes the deadline, that is the current
date plus numdays * multiplier. So for &lt;deadline numdays=&quot;3&quot;/&gt;
(in the XML source) and &lt;timelapse multiplier=&quot;2&quot;/&gt; (in the
stylesheet), the extension computes a deadline 6 days from now, and the stylesheet template
 transform the deadline element into a string along the lines of <CODE><FONT face="courier,
monospaced">&lt;p&gt;We have received your enquiry and will respond by April 29,
2000 12:07:16 PM EST.&lt;/p&gt;</FONT></CODE></P>
  -<TABLE border="0" cellpadding="0" cellspacing="3" width="100%"><TR><TD valign="top"
width="20"><IMG alt="Note" border="0" height="24" hspace="0" src="resources/note.gif"
vspace="0" width="20"></TD><TD valign="top"><FONT color="#000000" face="arial,helvetica,sanserif"
size="-1"><I>In case your noticed, the extension function could include both numdays
and multiplier as arguments, thus bypassing the need for the extension element. The purpose
here is to illustrate the usage pattern for both extension elements and extension functions.</I></FONT></TD></TR></TABLE>
  +<P>The source element contains a numdays attribute. The extension element contains
a multiplier attribute, which is used to set a variable in the extension. The extension function
computes the deadline, that is the current date plus numdays * multiplier. So for &lt;deadline
numdays=&quot;3&quot;/&gt; (in the XML source) and &lt;timelapse multiplier=&quot;2&quot;/&gt;
(in the stylesheet), the extension computes a deadline 6 days from now, and the stylesheet
template  transform the deadline element into a string along the lines of <CODE><FONT
face="courier, monospaced">&lt;p&gt;We have received your enquiry and will respond
by April 29, 2000 12:07:16 PM EST.&lt;/p&gt;</FONT></CODE></P>
  +<TABLE border="0" cellpadding="0" cellspacing="3" width="100%"><TR><TD valign="top"
width="20"><IMG alt="Note" border="0" height="24" hspace="0" src="resources/note.gif"
vspace="0" width="20"></TD><TD valign="top"><FONT color="#000000" face="arial,helvetica,sanserif"
size="-1"><I>The extension function could include both numdays and multiplier as
arguments, thus bypassing the need for the extension element, but the purpose here is to illustrate
the usage pattern for both extension elements and extension functions.</I></FONT></TD></TR></TABLE>
   <P>As you review this stylesheet, please note the following:</P>
   <OL>
   	  <LI>The declaration of the Xalan lxslt namespace, which provides support for the
component and
  @@ -177,7 +177,7 @@
   </PRE></FONT></TD><TD bgcolor="#0086b2" width="1"><IMG border="0"
height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD
bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1" width="462"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="462"></TD><TD
bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD></TR></TABLE></DIV>
   </FONT></TD></TR></TABLE><BR><A name="setup-runtime"><!--anchor--></A>
   <TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="666699"
colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD
bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD
bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD
bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif"
size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0"
width="2"><B>Setting up the runtime environment</B></FONT></TD><TD
bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="res
ources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2"
height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD
bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD
width="10">&nbsp;</TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
  -<P>To run the preceding example, bsf.jar, bsfengines.jar, and js.jar must be on the
class path. Remember that bsf.jar and bsfengines.jar must be on the class path to run any
extension. For extensions implemented in a scripting language, see the requirements in <A
href="#supported-lang">Supported languages</A>.</P>
  +<P>To run the preceding example, bsf.jar, bsfengines.jar, and js.jar must be on the
class path. Remember that bsf.jar and bsfengines.jar must be on the class path to run any
extension. For extensions implemented in a scripting language, see the additional requirements
in <A href="#supported-lang">Supported languages</A>.</P>
   </FONT></TD></TR></TABLE><BR><A name="basic-syntax"><!--anchor--></A>
   <TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="666699"
colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD
bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD
bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD
bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif"
size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0"
width="2"><B>Syntax</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" 
width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD
bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD
width="10">&nbsp;</TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
   <P>You can always use the pattern illustrated above to set up and use extension elements
and extension functions. For extension functions implemented in Java, you can also use the
java namespace, described in <A href="#java-namespace">Alternative: using the predefined
java extension namespace</A>. Unless you are using the predefined java extension namespace,
do the following:</P>
  @@ -187,13 +187,17 @@
   <TABLE border="0" cellpadding="0" cellspacing="3" width="100%"><TR><TD valign="top"
width="20"><IMG alt="Note" border="0" height="24" hspace="0" src="resources/note.gif"
vspace="0" width="20"></TD><TD valign="top"><FONT color="#000000" face="arial,helvetica,sanserif"
size="-1"><I>You may also use the LotusXSL alias for this namespace: &quot;http://xsl.lotus.com/&quot;.</I></FONT></TD></TR></TABLE>
   </FONT></TD></TR></TABLE><BR>
   <TABLE border="0" cellpadding="0" cellspacing="0" width="484"><TR><TD bgcolor="666699"
colspan="2" width="484"><TABLE border="0" cellpadding="0" cellspacing="0" width="484"><TR><TD
bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="482"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="482"></TD><TD
bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD
bgcolor="#0086b2" width="482"><FONT color="#ffffff" face="arial,helvetica,sanserif"><IMG
border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>2.
Declare a unique namespace for each extension prefix</B></FONT></TD><TD
bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="
0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD
bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="482"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="482"></TD><TD
bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD
width="10">&nbsp;</TD><TD width="474"><FONT color="#000000" face="arial,helvetica,sanserif"
size="-1">
  -<P><BR><CODE><FONT face="courier, monospaced">xmlns:<I>prefix</I>:<I>URI</I></FONT></CODE></P>
  +<P><BR><CODE><FONT face="courier, monospaced">xmlns:<I>prefix</I>=<I>URI</I></FONT></CODE></P>
   <P>The <I>prefix</I> identifies the namespace, and <I>URI</I>
is one of the following:</P>
   <UL>
  -  <LI>An arbitrary (but unique) string.<BR><BR></LI>
  +  <LI>An arbitrary (but unique) string.<BR>
  +  Example: <CODE><FONT face="courier, monospaced">xmlns:ext1=&quot;xyz&quot;</FONT></CODE><BR><BR></LI>
     <LI><CODE><FONT face="courier, monospaced">[class:]<I>FQCN</I></FONT></CODE><BR>
  -  where <I>FQCN</I> is a Java fully qualified class name. If the extension
only involves static class method calls (no instance constructors or instance method calls)
precede the class name with <CODE><FONT face="courier, monospaced">class:</FONT></CODE>.<BR><BR></LI>
  -  <LI>The file name or URL for another document that contains the xslt:component
element.</LI>
  +   where <I>FQCN</I> is a Java fully qualified class name. If the extension
only involves static class method
  +   calls (no instance constructors or instance method calls) precede the class name with
<CODE><FONT face="courier, monospaced">class:</FONT></CODE>.<BR>
  +   Example: <CODE><FONT face="courier, monospaced">xmlns:ext2=&quot;java.util.Hashtable&quot;</FONT></CODE><BR><BR></LI>
  +  <LI>The file name or URL for another document that contains the xslt:component
element.<BR>
  +  Example: <CODE><FONT face="courier, monospaced">xmlns:ext3=&quot;my-component.txt&quot;</FONT></CODE></LI>
   </UL>
   <P>If the stylesheet contains an xslt:component element with a prefix attribute set
to the extension prefix, the only function of the URI is to provide a unique namespace. If
the stylesheet does not contain an xslt:component, the URI must identify a Java class or a
document containing the xslt:component.</P>
   </FONT></TD></TR></TABLE><BR>
  @@ -222,7 +226,9 @@
   <TABLE border="0" cellpadding="0" cellspacing="0" width="484"><TR><TD bgcolor="666699"
colspan="2" width="484"><TABLE border="0" cellpadding="0" cellspacing="0" width="484"><TR><TD
bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="482"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="482"></TD><TD
bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD
bgcolor="#0086b2" width="482"><FONT color="#ffffff" face="arial,helvetica,sanserif"><IMG
border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>5.
Set up the lxslt:script element</B></FONT></TD><TD bgcolor="#017299"
width="1"><IMG border="0" height="1" hspace="0" src="resources/voi
d.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1"
width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0"
width="1"></TD><TD bgcolor="#017299" height="1" width="482"><IMG border="0"
height="1" hspace="0" src="resources/void.gif" vspace="0" width="482"></TD><TD
bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD
width="10">&nbsp;</TD><TD width="474"><FONT color="#000000" face="arial,helvetica,sanserif"
size="-1">
   <P>In each xslt:component, you must include an lxslt:script element. If the extension
is implemented in Java:</P>
   <P><CODE><FONT face="courier, monospaced">&lt;lxslt:script lang=&quot;javaclass&quot;
src=&quot;<I>[class:]FQCN</I>&quot;/&gt;</FONT></CODE></P>
  -<P>where <I>FQCN</I> is the fully qualified class name. If the extension
only involves static class method calls (no instance constructors or instance method calls)
precede the class name with <CODE><FONT face="courier, monospaced">class:</FONT></CODE>.</P>
  +<P>where <I>FQCN</I> is the fully qualified class name. If the extension
only involves static class method calls (no instance constructors or instance method calls)
precede the class name with <CODE><FONT face="courier, monospaced">class:</FONT></CODE>.<BR>
  +Example: <CODE><FONT face="courier, monospaced">&lt;lxslt:script lang=&quot;javaclass&quot;</FONT></CODE><BR>
  +<CODE><FONT face="courier, monospaced">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;src=&quot;java.util.Hashtable&quot;/&gt;</FONT></CODE></P>
   <P>If the extension is implemented in JavaScript:</P>
   <P><CODE><FONT face="courier, monospaced">&lt;lxslt:script lang=&quot;javascript&quot;
&gt;</FONT></CODE><BR>
   <CODE><FONT face="courier, monospaced">&nbsp;&nbsp;&lt;!--The implementation
script--&gt;</FONT></CODE><BR>
  @@ -256,7 +262,11 @@
   <CODE><FONT face="courier, monospaced">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;org.w3c.dom.Element
extensionElement)</FONT></CODE></P>
   <P>where <I>Type</I> designates the return type and <I>element</I>
is the local part of the extension element name (the element name without the namespace prefix).</P>
   <P>If the extension element is implemented in a loosely typed scripting language,
such as JavaScript, the arguments and return value are untyped.</P>
  -<P><B>Caution:</B> The value returned by an extension element is placed
in the transformaiton result. If you are not interested in a return value, use a public void
Java method or return null from a scripting language function.</P>
  +<P><B>Caution:</B> The value returned by an extension element is placed
in the transformation result. If you are not interested in a return value, use a public void
Java method or return null from a scripting language function.</P>
  +<P>Java example: <CODE><FONT face="courier, monospaced">public void myElement</FONT></CODE><BR>
  +<CODE><FONT face="courier, monospaced">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(org.apache.xalan.xslt.XSLProcessorContext,
</FONT></CODE><BR>
  +<CODE><FONT face="courier, monospaced">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;org.w3c.dom.Element
extensionElement)</FONT></CODE></P>
  +<P>JavaScript example: <CODE><FONT face="courier, monospaced">function
myElement(xslProcContext, element)</FONT></CODE></P>
   </FONT></TD></TR></TABLE><BR>
   <TABLE border="0" cellpadding="0" cellspacing="0" width="484"><TR><TD bgcolor="666699"
colspan="2" width="484"><TABLE border="0" cellpadding="0" cellspacing="0" width="484"><TR><TD
bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="482"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="482"></TD><TD
bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD
bgcolor="#0086b2" width="482"><FONT color="#ffffff" face="arial,helvetica,sanserif"><IMG
border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>The
Redirect extension</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspac
e="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD
bgcolor="#017299" height="1" width="482"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="482"></TD><TD bgcolor="#017299" height="1" width="1"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD
width="10">&nbsp;</TD><TD width="474"><FONT color="#000000" face="arial,helvetica,sanserif"
size="-1">
   <P>The Redirect extension (<A href="apidocsorg/apache/xalan/xslt/extensions/Redirect.html">org.apache.xalan.xslt.extensions.Redirect</A>)
is shipped with Xalan (more extensions are on the way!).</P>
  @@ -379,25 +389,28 @@
   <TABLE border="0" cellpadding="0" cellspacing="0" width="484"><TR><TD bgcolor="666699"
colspan="2" width="484"><TABLE border="0" cellpadding="0" cellspacing="0" width="484"><TR><TD
bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="482"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="482"></TD><TD
bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD
bgcolor="#0086b2" width="482"><FONT color="#ffffff" face="arial,helvetica,sanserif"><IMG
border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Extension
function Java calls</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG
border="0" height="1" hspace="0" src="resources/void.gif
" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1"
width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0"
width="1"></TD><TD bgcolor="#017299" height="1" width="482"><IMG border="0"
height="1" hspace="0" src="resources/void.gif" vspace="0" width="482"></TD><TD
bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD
width="10">&nbsp;</TD><TD width="474"><FONT color="#000000" face="arial,helvetica,sanserif"
size="-1">
   <P>Use the following syntax to instantiate Java objects and to call methods:</P>
   <P><CODE><FONT face="courier, monospaced"><I>prefix</I>:<I>FQCN</I>.new
(<I>args</I>)</FONT></CODE></P>
  +<P>where <I>prefix</I> is the extension namespace prefix and <I>FQCN</I>
is the fully qualified class name of which a new instance is to be created with the <I>args</I>
constructor arguments (if any).<BR>
  +Example: <CODE><FONT face="courier, monospaced">variable myHash</FONT></CODE><BR>
  +<CODE><FONT face="courier, monospaced">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;select&quot;my-ext:java.util.Hashtable.new()&quot;</FONT></CODE></P>
   
  -<P>where <I>prefix</I> is the extension namespace prefix and <I>FQCN</I>
is the fully qualified class name of which a new instance is to be created with the <I>args</I>
constructor arguments (if any).</P>
  -
   <P><CODE><FONT face="courier, monospaced"><I>prefix</I>:<I>FQCN.methodName</I>
(<I>args</I>)</FONT></CODE></P>
  -
  -<P>where <I>FQCN</I> is the fully qualified class name whose static method
<I>methodName</I> is to be invoked using the <I>args</I> arguments.
</P>
  +<P>where <I>FQCN</I> is the fully qualified class name whose static method
<I>methodName</I> is to be invoked using the <I>args</I> arguments.<BR>
  +Example: <CODE><FONT face="courier, monospaced">variable new-pop</FONT></CODE><BR>
  +<CODE><FONT face="courier, monospaced">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;select=&quot;my-ext:java.lang.Integer.valueOf(string(@population)&quot;</FONT></CODE></P>
   
   <P><CODE><FONT face="courier, monospaced"><I>prefix</I>:<I>methodName</I>
(<I>object</I>, <I>args</I>)</FONT></CODE></P>
  -
  -<P>where <I>methodName</I> is the name of the method to invoke on <I>object</I>
with the <I>args</I> arguments.</P>
  +<P>where <I>methodName</I> is the name of the method to invoke on <I>object</I>
with the <I>args</I> arguments.<BR>
  +Example: <CODE><FONT face="courier, monospaced">variable old-pop </FONT></CODE><BR>
  +<CODE><FONT face="courier, monospaced">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;select=&quot;my-ext:put($myHash,
string(@region), $new-pop)&quot;</FONT></CODE></P>
   </FONT></TD></TR></TABLE><BR>
   
   <TABLE border="0" cellpadding="0" cellspacing="0" width="484"><TR><TD bgcolor="666699"
colspan="2" width="484"><TABLE border="0" cellpadding="0" cellspacing="0" width="484"><TR><TD
bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="482"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="482"></TD><TD
bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD
bgcolor="#0086b2" width="482"><FONT color="#ffffff" face="arial,helvetica,sanserif"><IMG
border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Passing
Nodes to java</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace
="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD
bgcolor="#017299" height="1" width="482"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="482"></TD><TD bgcolor="#017299" height="1" width="1"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD
width="10">&nbsp;</TD><TD width="474"><FONT color="#000000" face="arial,helvetica,sanserif"
size="-1">
  -<P>Please keep in mind that <B>all</B> LocationPath expressions return
a node-set, even if the expression only returns a single attribute or a text node (node-sets
with one member). You can use the XSLT string() function to convert a node-set value to string,
and the number() function to convert a node-set value to number (a double).</P>
  -<P>If you want to pass a node-list to an extension function, set up a Java method
to accept an 
  +<P>Please keep in mind that <B>all</B> LocationPath expressions return
a node-set, even if the expression only returns a single attribute or a text node (node-sets
with one member). You can use the XSLT string() function (as in the syntax examples above)
to convert a node-set value to string, and the number() function to convert a node-set value
to number (a double).</P>
  +<P>If you want to pass a node-set to an extension function, set up a Java method
to accept an 
   org.w3c.dom.NodeList (or an org.apache.xalan.xpath.MutableNodeList, which extends NodeList,
if you want to modify the nodes).</P>
   <P>Suppose, for example, you have a myExtensions.ProcessNodes class with the following
doSomething method:</P>
   <P><CODE><FONT face="courier, monospaced">public static void doSomething(org.w3c.dom.NodeList
nList)</FONT></CODE></P>
  -<P>Assuming you set up this extension in the node-ext namespace, any of the following
extension calls from a stylesheet are syntatically possible:</P>
  +<P>Assuming you set up this extension in the node-ext namespace, any of the following
extension calls from a stylesheet are syntactically possible:</P>
   <P><CODE><FONT face="courier, monospaced">&lt;!--Process the current
node--&gt;</FONT></CODE><BR>
   <CODE><FONT face="courier, monospaced">node-ext:MyExtensions.ProcessNodes.doSomething(.)</FONT></CODE></P>
   <P><CODE><FONT face="courier, monospaced">&lt;!--Process all nodes
in current context--&gt;</FONT></CODE><BR>
  @@ -426,7 +439,7 @@
   <TABLE border="0" cellpadding="0" cellspacing="0" width="484"><TR><TD bgcolor="666699"
colspan="2" width="484"><TABLE border="0" cellpadding="0" cellspacing="0" width="484"><TR><TD
bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="482"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="482"></TD><TD
bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD
bgcolor="#0086b2" width="482"><FONT color="#ffffff" face="arial,helvetica,sanserif"><IMG
border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Use
the java namespace when you make extension function calls</B></FONT></TD><TD
bgcolor="#017299" width="1"><IMG border="0" height="1" hs
pace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD
bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="482"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="482"></TD><TD
bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD
width="10">&nbsp;</TD><TD width="474"><FONT color="#000000" face="arial,helvetica,sanserif"
size="-1">
   <P>Use &quot;java&quot; as the prefix with the syntax described in <A
href="#ext-func-calls">Extension function Java calls</A>.</P>
   <P>That is all. You do not need to set an extension-element-prefixes attribute, and
you do not include an xslt:component element. Given the absence of the lxslt:component element,
you cannot use the function-available method to determine at runtime whether a Java method
call is actually available. </P>
  -<P>Using the java namespace clearly involves less setup than using your own namespace,
as long as these restrictions are not a probleem. Remember that you always have the option
of setting up your own namespace and extra overhead is really minimal.</P>
  +<P>Using the java namespace clearly involves less setup than using your own namespace,
as long as these restrictions are not a problem. Remember that you always have the option
of setting up your own namespace and extra overhead is really minimal.</P>
   </FONT></TD></TR></TABLE><BR><A name="ex-java-namespace"><!--anchor--></A>

   <TABLE border="0" cellpadding="0" cellspacing="0" width="484"><TR><TD bgcolor="666699"
colspan="2" width="484"><TABLE border="0" cellpadding="0" cellspacing="0" width="484"><TR><TD
bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="482"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="482"></TD><TD
bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD
bgcolor="#0086b2" width="482"><FONT color="#ffffff" face="arial,helvetica,sanserif"><IMG
border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Example:
Formatting a date</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" v
space="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1"
width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0"
width="1"></TD><TD bgcolor="#017299" height="1" width="482"><IMG border="0"
height="1" hspace="0" src="resources/void.gif" vspace="0" width="482"></TD><TD
bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD
width="10">&nbsp;</TD><TD width="474"><FONT color="#000000" face="arial,helvetica,sanserif"
size="-1">
   <P>This example uses extension functions to call the SimpleDateFormat class and the
IntDate class. IntDate uses String arguments to set up a Date object:</P>
  @@ -440,7 +453,7 @@
         // Date(int, int, int) has been deprecated, so use Calendar to
         // set the year, month, and day.
         Calendar c = Calendar.getInstance();
  -      // Cast each argument to int.
  +      // Convert each argument to int.
         c.set(Integer.parseInt(year),Integer.parseInt(month),Integer.parseInt(day));
         return c.getTime();
       }
  @@ -494,7 +507,7 @@
   <A name="ex-java"><!--anchor--></A> 
   <TABLE border="0" cellpadding="0" cellspacing="0" width="484"><TR><TD bgcolor="666699"
colspan="2" width="484"><TABLE border="0" cellpadding="0" cellspacing="0" width="484"><TR><TD
bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="482"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="482"></TD><TD
bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD
bgcolor="#0086b2" width="482"><FONT color="#ffffff" face="arial,helvetica,sanserif"><IMG
border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Java
implementation</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="
0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD
bgcolor="#017299" height="1" width="482"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="482"></TD><TD bgcolor="#017299" height="1" width="1"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD
width="10">&nbsp;</TD><TD width="474"><FONT color="#000000" face="arial,helvetica,sanserif"
size="-1">
   <P>MyCounter.java</P>
  -<DIV align="right"><TABLE border="0" cellpadding="0" cellspacing="4" width="464"><TR><TD
bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1" width="462"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="462"></TD><TD
bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" width="1"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD
bgcolor="#ffffff" width="462"><FONT size="-1"><PRE>mport java.util.*;
  +<DIV align="right"><TABLE border="0" cellpadding="0" cellspacing="4" width="464"><TR><TD
bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD><TD bgcolor="#0086b2" height="1" width="462"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="462"></TD><TD
bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif"
vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" width="1"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD
bgcolor="#ffffff" width="462"><FONT size="-1"><PRE>Import java.util.*;
   
   public class MyCounter {
     Hashtable counters = new Hashtable ();
  
  
  

Mime
View raw message