dleslie 01/05/23 06:56:36
Added: targets/xalan-j/xsltc index.html todo.html
xsl_comment_design.html xsl_key_design.html
xsl_lang_design.html xsl_sort_design.html
xsl_unparsed_design.html xsl_whitespace_design.html
xsltc_compiler.html xsltc_dom.html
xsltc_namespace.html xsltc_runtime.html
xsltc_trax.html
targets/xalan-j/xsltc/graphics ext-40-label-1.jpg
ext-40-label-2.jpg ext-40-label-3.jpg
index-header.jpg index-label-1.jpg
index-label-2.jpg index-label-3.jpg
xsl_comment_design-header.jpg
xsl_comment_design-label-1.jpg
xsl_comment_design-label-2.jpg
xsl_comment_design-label-3.jpg
xsl_key_design-header.jpg
xsl_key_design-label-1.jpg
xsl_key_design-label-2.jpg
xsl_key_design-label-3.jpg
xsl_lang_design-header.jpg
xsl_lang_design-label-1.jpg
xsl_lang_design-label-2.jpg
xsl_lang_design-label-3.jpg
xsl_sort_design-header.jpg
xsl_sort_design-label-1.jpg
xsl_sort_design-label-2.jpg
xsl_sort_design-label-3.jpg
xsl_unparsed_design-header.jpg
xsl_unparsed_design-label-1.jpg
xsl_unparsed_design-label-2.jpg
xsl_unparsed_design-label-3.jpg
xsl_whitespace_design-header.jpg
xsl_whitespace_design-label-1.jpg
xsl_whitespace_design-label-2.jpg
xsl_whitespace_design-label-3.jpg
xsltc_compiler-header.jpg
xsltc_compiler-label-1.jpg
xsltc_compiler-label-2.jpg
xsltc_compiler-label-3.jpg xsltc_dom-header.jpg
xsltc_dom-label-1.jpg xsltc_dom-label-2.jpg
xsltc_dom-label-3.jpg xsltc_namespace-header.jpg
xsltc_namespace-label-1.jpg
xsltc_namespace-label-2.jpg
xsltc_namespace-label-3.jpg
xsltc_runtime-header.jpg xsltc_runtime-label-1.jpg
xsltc_runtime-label-2.jpg xsltc_runtime-label-3.jpg
xsltc_trax-header.jpg xsltc_trax-label-1.jpg
xsltc_trax-label-2.jpg xsltc_trax-label-3.jpg
targets/xalan-j/xsltc/images DOMInterface.gif
all_namespaces.gif cast_expression.gif
compiler_AST.gif compiler_DOM.gif
compiler_architecture.gif dom_namespace1.gif
dom_namespace2.gif dom_namespace3.gif
key_relations.gif match_namespace1.gif
match_namespace2.gif namespace_stack.gif
output_namespaces1.gif output_namespaces2.gif
runtime_architecture.gif runtime_type_mapping.gif
sort_objects.gif type_mappings.gif typecast.gif
targets/xalan-j/xsltc/resources bottom.gif button-asf-hi.gif
button-asf-lo.gif button-w3c-hi.gif
button-w3c-lo.gif button-xml-hi.gif
button-xml-lo.gif close.gif dot.gif join.gif
line.gif logo.gif note.gif right.gif script.js
separator.gif void.gif
Log:
XSLTC design documentation
Revision Changes Path
1.1 xml-site/targets/xalan-j/xsltc/index.html
Index: index.html
===================================================================
<HTML><HEAD><SCRIPT language="JavaScript" src="resources/script.js"
type="text/javascript"></SCRIPT><TITLE>Introduction to
XSLTC</TITLE></HEAD><BODY alink="#ff0000" bgcolor="#ffffff" leftmargin="4"
link="#0000ff" marginheight="4" marginwidth="4" text="#000000" topmargin="4"
vlink="#0000aa"><TABLE border="0" cellpadding="0" cellspacing="0"
width="620"><TR><TD align="left" height="60" rowspan="3" valign="top"
width="135"><IMG border="0" height="60" hspace="0" src="resources/logo.gif"
vspace="0" width="135"></TD><TD align="left" colspan="4" height="5"
valign="top" width="456"><IMG border="0" height="5" hspace="0"
src="resources/line.gif" vspace="0" width="456"></TD><TD align="left"
height="60" rowspan="3" valign="top" width="29"><IMG border="0" height="60"
hspace="0" src="resources/right.gif" vspace="0" width="29"></TD></TR><TR><TD
align="left" bgcolor="#0086b2" colspan="4" height="35" valign="top"
width="456"><IMG alt="" border="0" height="35" hspace="0"
src="graphics/index-header.jpg" vspace="0" width="456"></TD></TR><TR><TD
align="left" height="20" valign="top" width="168"><IMG border="0" height="20"
hspace="0" src="resources/bottom.gif" vspace="0" width="168"></TD><TD
align="left" height="20" valign="top" width="96"><A
href="http://xml.apache.org/" onMouseOut="rolloverOff('xml');"
onMouseOver="rolloverOn('xml');" target="new"><IMG alt="http://xml.apache.org/"
border="0" height="20" hspace="0" name="xml"
onLoad="rolloverLoad('xml','resources/button-xml-hi.gif','resources/button-xml-lo.gif');"
src="resources/button-xml-lo.gif" vspace="0" width="96"></A></TD><TD
align="left" height="20" valign="top" width="96"><A
href="http://www.apache.org/" onMouseOut="rolloverOff('asf');"
onMouseOver="rolloverOn('asf');" target="new"><IMG alt="http://www.apache.org/"
border="0" height="20" hspace="0" name="asf"
onLoad="rolloverLoad('asf','resources/button-asf-hi.gif','resources/button-asf-lo.gif');"
src="resources/button-asf-lo.gif" vspace="0" width="96"></A></TD><TD
align="left" height="20" valign="top" width="96"><A href="http://www.w3.org/"
onMouseOut="rolloverOff('w3c');" onMouseOver="rolloverOn('w3c');"
target="new"><IMG alt="http://www.w3.org/" border="0" height="20" hspace="0"
name="w3c"
onLoad="rolloverLoad('w3c','resources/button-w3c-hi.gif','resources/button-w3c-lo.gif');"
src="resources/button-w3c-lo.gif" vspace="0"
width="96"></A></TD></TR></TABLE><TABLE border="0" cellpadding="0"
cellspacing="0" width="620"><TR><TD align="left" valign="top" width="120"><IMG
border="0" height="14" hspace="0" src="resources/join.gif" vspace="0"
width="120"><BR>
<IMG alt="Overview" border="0" height="12" hspace="0"
src="graphics/index-label-1.jpg" vspace="0" width="120"><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_compiler.html"
onMouseOut="rolloverOff('side-xsltc_compiler');"
onMouseOver="rolloverOn('side-xsltc_compiler');"><IMG alt="Compiler design"
border="0" height="12" hspace="0" name="side-xsltc_compiler"
onLoad="rolloverLoad('side-xsltc_compiler','graphics/xsltc_compiler-label-2.jpg','graphics/xsltc_compiler-label-3.jpg');"
src="graphics/xsltc_compiler-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsl_whitespace_design.html"
onMouseOut="rolloverOff('side-xsl_whitespace_design');"
onMouseOver="rolloverOn('side-xsl_whitespace_design');"><IMG alt="Whitespace"
border="0" height="12" hspace="0" name="side-xsl_whitespace_design"
onLoad="rolloverLoad('side-xsl_whitespace_design','graphics/xsl_whitespace_design-label-2.jpg','graphics/xsl_whitespace_design-label-3.jpg');"
src="graphics/xsl_whitespace_design-label-3.jpg" vspace="0"
width="120"></A><BR>
<A href="xsl_sort_design.html"
onMouseOut="rolloverOff('side-xsl_sort_design');"
onMouseOver="rolloverOn('side-xsl_sort_design');"><IMG alt="xsl:sort"
border="0" height="12" hspace="0" name="side-xsl_sort_design"
onLoad="rolloverLoad('side-xsl_sort_design','graphics/xsl_sort_design-label-2.jpg','graphics/xsl_sort_design-label-3.jpg');"
src="graphics/xsl_sort_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_key_design.html"
onMouseOut="rolloverOff('side-xsl_key_design');"
onMouseOver="rolloverOn('side-xsl_key_design');"><IMG alt="Keys" border="0"
height="12" hspace="0" name="side-xsl_key_design"
onLoad="rolloverLoad('side-xsl_key_design','graphics/xsl_key_design-label-2.jpg','graphics/xsl_key_design-label-3.jpg');"
src="graphics/xsl_key_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_comment_design.html"
onMouseOut="rolloverOff('side-xsl_comment_design');"
onMouseOver="rolloverOn('side-xsl_comment_design');"><IMG alt="Comment design"
border="0" height="12" hspace="0" name="side-xsl_comment_design"
onLoad="rolloverLoad('side-xsl_comment_design','graphics/xsl_comment_design-label-2.jpg','graphics/xsl_comment_design-label-3.jpg');"
src="graphics/xsl_comment_design-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsl_lang_design.html"
onMouseOut="rolloverOff('side-xsl_lang_design');"
onMouseOver="rolloverOn('side-xsl_lang_design');"><IMG alt="lang()" border="0"
height="12" hspace="0" name="side-xsl_lang_design"
onLoad="rolloverLoad('side-xsl_lang_design','graphics/xsl_lang_design-label-2.jpg','graphics/xsl_lang_design-label-3.jpg');"
src="graphics/xsl_lang_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_unparsed_design.html"
onMouseOut="rolloverOff('side-xsl_unparsed_design');"
onMouseOver="rolloverOn('side-xsl_unparsed_design');"><IMG alt="Unparsed
entities" border="0" height="12" hspace="0" name="side-xsl_unparsed_design"
onLoad="rolloverLoad('side-xsl_unparsed_design','graphics/xsl_unparsed_design-label-2.jpg','graphics/xsl_unparsed_design-label-3.jpg');"
src="graphics/xsl_unparsed_design-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_runtime.html"
onMouseOut="rolloverOff('side-xsltc_runtime');"
onMouseOver="rolloverOn('side-xsltc_runtime');"><IMG alt="Runtime" border="0"
height="12" hspace="0" name="side-xsltc_runtime"
onLoad="rolloverLoad('side-xsltc_runtime','graphics/xsltc_runtime-label-2.jpg','graphics/xsltc_runtime-label-3.jpg');"
src="graphics/xsltc_runtime-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_dom.html" onMouseOut="rolloverOff('side-xsltc_dom');"
onMouseOver="rolloverOn('side-xsltc_dom');"><IMG alt="Internal DOM" border="0"
height="12" hspace="0" name="side-xsltc_dom"
onLoad="rolloverLoad('side-xsltc_dom','graphics/xsltc_dom-label-2.jpg','graphics/xsltc_dom-label-3.jpg');"
src="graphics/xsltc_dom-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsltc_namespace.html"
onMouseOut="rolloverOff('side-xsltc_namespace');"
onMouseOver="rolloverOn('side-xsltc_namespace');"><IMG alt="Namespaces"
border="0" height="12" hspace="0" name="side-xsltc_namespace"
onLoad="rolloverLoad('side-xsltc_namespace','graphics/xsltc_namespace-label-2.jpg','graphics/xsltc_namespace-label-3.jpg');"
src="graphics/xsltc_namespace-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_trax.html" onMouseOut="rolloverOff('side-xsltc_trax');"
onMouseOver="rolloverOn('side-xsltc_trax');"><IMG alt="Translet & TrAX"
border="0" height="12" hspace="0" name="side-xsltc_trax"
onLoad="rolloverLoad('side-xsltc_trax','graphics/xsltc_trax-label-2.jpg','graphics/xsltc_trax-label-3.jpg');"
src="graphics/xsltc_trax-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="todo.html" onMouseOut="rolloverOff('side-ext-40');"
onMouseOver="rolloverOn('side-ext-40');"><IMG alt="To-do list" border="0"
height="12" hspace="0" name="side-ext-40"
onLoad="rolloverLoad('side-ext-40','graphics/ext-40-label-2.jpg','graphics/ext-40-label-3.jpg');"
src="graphics/ext-40-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="14" hspace="0" src="resources/close.gif" vspace="0"
width="120"><BR></TD><TD align="left" valign="top" width="500"><TABLE
border="0" cellpadding="3" cellspacing="0"><TR><TD>
<P><I>Design documents by <A href="mailto:[EMAIL PROTECTED]">Morten
Jørgensen</A>
- updated 06.03.2001</I></P>
<UL>
<LI><A href="#compiler">Compiler design</A></LI>
<LI><A href="#runtime">Runtime library/DOM design</A></LI>
<LI><A href="xsltc_trax.html">Integration of the Translet API and TrAX</A>
(by G Todd Miller)</LI>
</UL>
<P>See also <A href="../xsltc_usage.html">Using XSLTC</A>.</P>
<A name="compiler"><!--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>Compiler design</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P><A href="xsltc_compiler.html"><IMG align="right" border="0" hspace="4"
src="images/compiler_architecture.gif" vspace="4"><BR clear="all"></A></P>
<P><I>Figure 1: Compiler architecture overview</I></P>
<P>Click on the picture to jump to the overall design document for the
compiler.</P>
<P>Each XSL element/function and XPath expression/pattern is represented
by
its own class in the Abstract Syntax Tree (AST). Some of these classes have
their own design documents (I am working on the rest of them):</P>
<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>XSL elements</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<UL>
<LI>
<A
href="xsl_whitespace_design.html"><xsl:preserve-space>/<xsl:strip-space></A>
</LI>
<LI>
<A href="xsl_sort_design.html"><xsl:sort></A>
</LI>
<LI>
<A href="xsl_key_design.html"><xsl:key></A>
</LI>
<LI>
<A
href="xsl_comment_design.html"><xsl:comment>/<xsl:message></A>
</LI>
</UL>
</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>XSL functions</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<UL>
<LI>
<A href="xsl_key_design.html">key()</A>
</LI>
<LI>
<A href="xsl_lang_design.html">lang()</A>
</LI>
<LI>
<A href="xsl_unparsed_design.html">unparsed-entity-uri()</A>
</LI>
</UL>
</FONT></TD></TR></TABLE><BR>
</FONT></TD></TR></TABLE><BR><A name="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>Runtime library/DOM design</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P><A href="xsltc_runtime.html"><IMG align="right" border="0" hspace="4"
src="images/runtime_architecture.gif" vspace="4"><BR clear="all"></A></P>
<P><I>Figure 2: Runtime library architecture overview</I></P>
<P>Click on the picture to jump to the overall design document for the XSLTC
runtime library. This document describes the structure of the compiled
translet as well as the translet runtime library.</P>
<P>The <A href="xsltc_dom.html">Internal DOM</A> describes the components
and structure of the internal DOM,
support for DOM2 navigation, the DOM adapter, DOM multiplexer, and DOM
builder.</P>
<P><A href="xsltc_namespace.html">Namespaces</A> explains how XSLTC
(including the compiler) handles
namespaces.</P>
</FONT></TD></TR></TABLE><BR>
</TD></TR></TABLE></TD></TR></TABLE><BR><TABLE border="0" cellpadding="0"
cellspacing="0" width="620"><TR><TD bgcolor="#0086b2"><IMG height="1"
src="images/dot.gif" width="1"></TD></TR><TR><TD align="center"><FONT
color="#0086b2" size="-1"><I>
Copyright © 2001 The Apache Software Foundation.
All Rights Reserved.
</I></FONT></TD></TR></TABLE></BODY></HTML>
1.1 xml-site/targets/xalan-j/xsltc/todo.html
Index: todo.html
===================================================================
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE>XCLTC 1</TITLE>
</HEAD>
<BODY>
<H2>XCLTC 1: Things To Do</H2>
<p>
<font size="-1">See a
<a href="#developer-list">list of developers/initials.</a></font>
</p>
<font size="-1">
<p>Planned releases:
<BR>
<a href="#release-date-00/00/00">00/00/00</a> <a
href="#release-date-completed">Completed</a>
</p>
</font>
<p>
<a name="release-date-00/00/00"><b>For release: 00/00/00</b></a>
, beta
<BR>
<b>Goal </b>[conformance]: XSLT 1.0 compliant 100%.
<BR>
<b>Goal </b>[performance]: Maintain current level.
<BR>
<b>Goal </b>[stability]: Stable, reasonable.
<BR>
<b>Goal </b>[api]: API Complete.
<BR>
<b>Goal </b>[documentation]: Documentation functionally complete.
</p>
<p>1)
Replace all Project X components and APIs with
JAXP equivalents (this includes updating compiler's parser
to use SAX2/DOM2).
<BR>
<b>context:</b> code, packages: org.apache.xalan.xsltc, <b>category:</b>
feature, <b>who:</b> <a href="#personref-MJ,%20TM">MJ, TM</a>, <b>priority:</b>
high</p>
<p>2)
Produce documentation on architecture of XSLTC so the larger developer
community can contribute to the development of XSLT.
<BR>
<b>context:</b> doc, <b>category:</b> documentation, <b>who:</b> <a
href="#personref-MJ">MJ</a>, <b>priority:</b> high</p>
<p>3)
Integrate tests not already there into the Xalan test suite and begin
using the Xalan test suite to test XSLTC as a component of XalanJ2.
(This should wait until #1 is done.)
<BR>
<b>context:</b> test, packages:org.apache.xalan.xsltc, <b>category:</b>
tests, <b>who:</b> <a href="#personref-TA,%20Shane">TA, Shane</a>,
<b>priority:</b> high</p>
<p>4)
Finish the implementation of id() and key() in patterns.
<BR>
<b>context:</b> code, packages:org.apache.xalan.xsltc, <b>category:</b>
feature, <b>who:</b> <a href="#personref-??">??</a>, <b>priority:</b> high</p>
<p>5)
Continue to improve the handling of name spaces. There are a number of
bugs that are independent of the lack of namespace nodes.
(bugzilla 1411, 1472, 1473, 1506, 1517, 1518)
<BR>
<b>context:</b> code, packages:org.apache.xalan.xsltc, <b>category:</b> bug,
<b>who:</b> <a href="#personref-??">??</a>, <b>priority:</b> high</p>
<p>6)
Fix bugs that impact the XSLTMark performance benchmark.
(bugzilla 1498, 1532).
<BR>
<b>context:</b> code, packages:org.apache.xalan.xsltc, <b>category:</b> bug,
<b>who:</b> <a href="#personref-??">??</a>, <b>priority:</b> high</p>
<p>7)
Fix bugs that impact the use of XSLT with DocBook (1404, 1487).
<BR>
<b>context:</b> code, packages:org.apache.xalan.xsltc, <b>category:</b>
feature, <b>who:</b> <a href="#personref-??">??</a>, <b>priority:</b> high</p>
<p>8)
Fix bugs with the handling of variables and parameters (1487, 1408)
<BR>
<b>context:</b> code, packages:org.apache.xalan.xsltc, <b>category:</b>
feature, <b>who:</b> <a href="#personref-MJ">MJ</a>, <b>priority:</b> high</p>
<p>9)
Fix bugs reflecting positional problems (1409, 1410, 1412, 1532).
<BR>
<b>context:</b> code, packages:org.apache.xalan.xsltc, <b>category:</b>
feature, <b>who:</b> <a href="#personref-TM">TM</a>, <b>priority:</b> high</p>
<p>10)
Fix bugs on dealing with XPATH expressions (1407, 1511).
<BR>
<b>context:</b> code, packages:org.apache.xalan.xsltc, <b>category:</b>
feature, <b>who:</b> <a href="#personref-TM">TM</a>, <b>priority:</b> high</p>
<p>11)
Fix bugs involving template selection (1503, 1397).
<BR>
<b>context:</b> code, packages:org.apache.xalan.xsltc, <b>category:</b>
feature, <b>who:</b> <a href="#personref-who">who</a>, <b>priority:</b>
medium</p>
<p>12)
Implement name space nodes (bugzilla 1379).
<BR>
<b>context:</b> code, packages:org.apache.xalan.xsltc, <b>category:</b>
feature, <b>who:</b> <a href="#personref-MJ">MJ</a>, <b>priority:</b> low</p>
<p>13)
Look into proper caching algorithms and improve the example given in
DocumentCache.java accordingly.
<BR>
<b>context:</b> code, packages:org.apache.xalan.xsltc, <b>category:</b>
feature, <b>who:</b> <a href="#personref-??">??</a>, <b>priority:</b> low</p>
<p>14)
Implement an extension to support the redirection of output to multiple
output files from within a stylesheet (equivalent to xalan:redirect or
saxon:output). Note: Task may be implemented as a result of integrating
Xsltc and Xalan
and using shared code.
<BR>
<b>context:</b> code, packages:????, <b>category:</b> feature, integration
with Xalan, <b>who:</b> <a href="#personref-??">??</a>, <b>priority:</b>
medium</p>
<p>15)
Implement a node-set extension to convert result tree fragments to
node-sets. This enables sorting and grouping of nodes assigned to a tree
variable. Note: Task may be implemented as a result of integrating Xsltc
and Xalan
and using shared code.
<BR>
<b>context:</b> code, packages:????, <b>category:</b> feature, integration
with Xalan, <b>who:</b> <a href="#personref-??">??</a>, <b>priority:</b>
medium</p>
<p>16)
Add support for nonstatic external Java functions. Note: Task may be
implemented as a result of integrating Xsltc and Xalan
and using shared code.
<BR>
<b>context:</b> code, packages:????, <b>category:</b> feature, integration
with Xalan, <b>who:</b> <a href="#personref-??">??</a>, <b>priority:</b>
medium</p>
<p>17)
Fix bugs affecting the correctness of ouput
(1403, 1406, 1441, 1489, 1429, 1504,
1508, 1512, 1513, 1516, 1520, 1521, 1525). Note: Task may be
implemented as a result of integrating Xsltc and Xalan
and using shared code.
<BR>
<b>context:</b> code, packages:????, <b>category:</b> feature, integration
with Xalan, <b>who:</b> <a href="#personref-??">??</a>, <b>priority:</b>
medium</p>
<p>18)
Use SAX to build the AST. The DOM builder
(the real DOM builder, not our quasi-DOM builder) receives SAX
events when it builds the DOM. The compiler.Parser class could
possible receive these SAX events directly, and thereby eliminating
the need for a DOM (saves loads of time and memory).
<BR>
<b>context:</b> code, AST, <b>category:</b> architecture, <b>who:</b> <a
href="#personref-??">??</a>, <b>priority:</b> medium</p>
<p>19)
Consider building a DOM-2-'DOM' converter, perhaps by adding
a second DOM builder inner class to our DOM. Then we would have
one SAX DOM builder and one DOM DOM builder. I don't know if
JAXP lets you supply the stylesheet as a DOM. If it doesn't,
we should assign this task a very low priority. There is no
point in spending a lot of time on this if JAXP users will
never be able to use this functionality.
<BR>
<b>context:</b> code, DOM, <b>category:</b> architecture, <b>who:</b> <a
href="#personref-??">??</a>, <b>priority:</b> medium</p>
<HR>
<a name="release-date-completed">
<H3>Completed: </H3>
</a>
<HR>
<H3>
<a name="developer-list">Developers:</a>
</H3>
<p>A list of some of people currently working on working on XCLTC:</p>
<ul>
<li>
<a href="mailto:[EMAIL PROTECTED]">Tom Amiro</a><a name="personref-TA">
(TA)</a>
<BR>
Details to be added.
</li>
<li>
<a href="mailto:[EMAIL PROTECTED]">Morten JØrgensen</a><a
name="personref-MJ"> (MJ)</a>
<BR>
Details to be added.
</li>
<li>
<a href="mailto:[EMAIL PROTECTED]">G. Todd Miller</a><a name="personref-TM">
(TM)</a>
<BR>
Details to be added.
</li>
</ul>
</BODY>
</HTML>
1.1 xml-site/targets/xalan-j/xsltc/xsl_comment_design.html
Index: xsl_comment_design.html
===================================================================
<HTML><HEAD><SCRIPT language="JavaScript" src="resources/script.js"
type="text/javascript"></SCRIPT><TITLE><xsl:comment> /
<xsl:message></TITLE></HEAD><BODY alink="#ff0000" bgcolor="#ffffff"
leftmargin="4" link="#0000ff" marginheight="4" marginwidth="4" text="#000000"
topmargin="4" vlink="#0000aa"><TABLE border="0" cellpadding="0" cellspacing="0"
width="620"><TR><TD align="left" height="60" rowspan="3" valign="top"
width="135"><IMG border="0" height="60" hspace="0" src="resources/logo.gif"
vspace="0" width="135"></TD><TD align="left" colspan="4" height="5"
valign="top" width="456"><IMG border="0" height="5" hspace="0"
src="resources/line.gif" vspace="0" width="456"></TD><TD align="left"
height="60" rowspan="3" valign="top" width="29"><IMG border="0" height="60"
hspace="0" src="resources/right.gif" vspace="0" width="29"></TD></TR><TR><TD
align="left" bgcolor="#0086b2" colspan="4" height="35" valign="top"
width="456"><IMG alt="" border="0" height="35" hspace="0"
src="graphics/xsl_comment_design-header.jpg" vspace="0"
width="456"></TD></TR><TR><TD align="left" height="20" valign="top"
width="168"><IMG border="0" height="20" hspace="0" src="resources/bottom.gif"
vspace="0" width="168"></TD><TD align="left" height="20" valign="top"
width="96"><A href="http://xml.apache.org/" onMouseOut="rolloverOff('xml');"
onMouseOver="rolloverOn('xml');" target="new"><IMG alt="http://xml.apache.org/"
border="0" height="20" hspace="0" name="xml"
onLoad="rolloverLoad('xml','resources/button-xml-hi.gif','resources/button-xml-lo.gif');"
src="resources/button-xml-lo.gif" vspace="0" width="96"></A></TD><TD
align="left" height="20" valign="top" width="96"><A
href="http://www.apache.org/" onMouseOut="rolloverOff('asf');"
onMouseOver="rolloverOn('asf');" target="new"><IMG alt="http://www.apache.org/"
border="0" height="20" hspace="0" name="asf"
onLoad="rolloverLoad('asf','resources/button-asf-hi.gif','resources/button-asf-lo.gif');"
src="resources/button-asf-lo.gif" vspace="0" width="96"></A></TD><TD
align="left" height="20" valign="top" width="96"><A href="http://www.w3.org/"
onMouseOut="rolloverOff('w3c');" onMouseOver="rolloverOn('w3c');"
target="new"><IMG alt="http://www.w3.org/" border="0" height="20" hspace="0"
name="w3c"
onLoad="rolloverLoad('w3c','resources/button-w3c-hi.gif','resources/button-w3c-lo.gif');"
src="resources/button-w3c-lo.gif" vspace="0"
width="96"></A></TD></TR></TABLE><TABLE border="0" cellpadding="0"
cellspacing="0" width="620"><TR><TD align="left" valign="top" width="120"><IMG
border="0" height="14" hspace="0" src="resources/join.gif" vspace="0"
width="120"><BR>
<A href="index.html" onMouseOut="rolloverOff('side-index');"
onMouseOver="rolloverOn('side-index');"><IMG alt="Overview" border="0"
height="12" hspace="0" name="side-index"
onLoad="rolloverLoad('side-index','graphics/index-label-2.jpg','graphics/index-label-3.jpg');"
src="graphics/index-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_compiler.html"
onMouseOut="rolloverOff('side-xsltc_compiler');"
onMouseOver="rolloverOn('side-xsltc_compiler');"><IMG alt="Compiler design"
border="0" height="12" hspace="0" name="side-xsltc_compiler"
onLoad="rolloverLoad('side-xsltc_compiler','graphics/xsltc_compiler-label-2.jpg','graphics/xsltc_compiler-label-3.jpg');"
src="graphics/xsltc_compiler-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsl_whitespace_design.html"
onMouseOut="rolloverOff('side-xsl_whitespace_design');"
onMouseOver="rolloverOn('side-xsl_whitespace_design');"><IMG alt="Whitespace"
border="0" height="12" hspace="0" name="side-xsl_whitespace_design"
onLoad="rolloverLoad('side-xsl_whitespace_design','graphics/xsl_whitespace_design-label-2.jpg','graphics/xsl_whitespace_design-label-3.jpg');"
src="graphics/xsl_whitespace_design-label-3.jpg" vspace="0"
width="120"></A><BR>
<A href="xsl_sort_design.html"
onMouseOut="rolloverOff('side-xsl_sort_design');"
onMouseOver="rolloverOn('side-xsl_sort_design');"><IMG alt="xsl:sort"
border="0" height="12" hspace="0" name="side-xsl_sort_design"
onLoad="rolloverLoad('side-xsl_sort_design','graphics/xsl_sort_design-label-2.jpg','graphics/xsl_sort_design-label-3.jpg');"
src="graphics/xsl_sort_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_key_design.html"
onMouseOut="rolloverOff('side-xsl_key_design');"
onMouseOver="rolloverOn('side-xsl_key_design');"><IMG alt="Keys" border="0"
height="12" hspace="0" name="side-xsl_key_design"
onLoad="rolloverLoad('side-xsl_key_design','graphics/xsl_key_design-label-2.jpg','graphics/xsl_key_design-label-3.jpg');"
src="graphics/xsl_key_design-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG alt="Comment design" border="0" height="12" hspace="0"
src="graphics/xsl_comment_design-label-1.jpg" vspace="0" width="120"><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsl_lang_design.html"
onMouseOut="rolloverOff('side-xsl_lang_design');"
onMouseOver="rolloverOn('side-xsl_lang_design');"><IMG alt="lang()" border="0"
height="12" hspace="0" name="side-xsl_lang_design"
onLoad="rolloverLoad('side-xsl_lang_design','graphics/xsl_lang_design-label-2.jpg','graphics/xsl_lang_design-label-3.jpg');"
src="graphics/xsl_lang_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_unparsed_design.html"
onMouseOut="rolloverOff('side-xsl_unparsed_design');"
onMouseOver="rolloverOn('side-xsl_unparsed_design');"><IMG alt="Unparsed
entities" border="0" height="12" hspace="0" name="side-xsl_unparsed_design"
onLoad="rolloverLoad('side-xsl_unparsed_design','graphics/xsl_unparsed_design-label-2.jpg','graphics/xsl_unparsed_design-label-3.jpg');"
src="graphics/xsl_unparsed_design-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_runtime.html"
onMouseOut="rolloverOff('side-xsltc_runtime');"
onMouseOver="rolloverOn('side-xsltc_runtime');"><IMG alt="Runtime" border="0"
height="12" hspace="0" name="side-xsltc_runtime"
onLoad="rolloverLoad('side-xsltc_runtime','graphics/xsltc_runtime-label-2.jpg','graphics/xsltc_runtime-label-3.jpg');"
src="graphics/xsltc_runtime-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_dom.html" onMouseOut="rolloverOff('side-xsltc_dom');"
onMouseOver="rolloverOn('side-xsltc_dom');"><IMG alt="Internal DOM" border="0"
height="12" hspace="0" name="side-xsltc_dom"
onLoad="rolloverLoad('side-xsltc_dom','graphics/xsltc_dom-label-2.jpg','graphics/xsltc_dom-label-3.jpg');"
src="graphics/xsltc_dom-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsltc_namespace.html"
onMouseOut="rolloverOff('side-xsltc_namespace');"
onMouseOver="rolloverOn('side-xsltc_namespace');"><IMG alt="Namespaces"
border="0" height="12" hspace="0" name="side-xsltc_namespace"
onLoad="rolloverLoad('side-xsltc_namespace','graphics/xsltc_namespace-label-2.jpg','graphics/xsltc_namespace-label-3.jpg');"
src="graphics/xsltc_namespace-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_trax.html" onMouseOut="rolloverOff('side-xsltc_trax');"
onMouseOver="rolloverOn('side-xsltc_trax');"><IMG alt="Translet & TrAX"
border="0" height="12" hspace="0" name="side-xsltc_trax"
onLoad="rolloverLoad('side-xsltc_trax','graphics/xsltc_trax-label-2.jpg','graphics/xsltc_trax-label-3.jpg');"
src="graphics/xsltc_trax-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="todo.html" onMouseOut="rolloverOff('side-ext-40');"
onMouseOver="rolloverOn('side-ext-40');"><IMG alt="To-do list" border="0"
height="12" hspace="0" name="side-ext-40"
onLoad="rolloverLoad('side-ext-40','graphics/ext-40-label-2.jpg','graphics/ext-40-label-3.jpg');"
src="graphics/ext-40-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="14" hspace="0" src="resources/close.gif" vspace="0"
width="120"><BR></TD><TD align="left" valign="top" width="500"><TABLE
border="0" cellpadding="3" cellspacing="0"><TR><TD>
<UL>
<LI><A href="#functionality">Functionality</A></LI>
<LI><A href="#implementation">Implementation</A></LI>
</UL>
<A name="functionality"><!--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>Functionality</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>The <CODE><FONT face="courier,
monospaced"><xsl:comment></FONT></CODE> element is used to insert XML
comments
into the result document. The comment is inserted as follows in the XSL
stylesheet:</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> <element>
<xsl:comment>This is a comment!</xsl:comment>
</element></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>
<P>and it will be output in the result document as follows:</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> <element>
<!-- This is a comment! -->
</element></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>
<P>The <CODE><FONT face="courier,
monospaced"><xsl:message></FONT></CODE> element is used to send messages
to
who/whatever is performing the transformation. The message can be displayed
in a terminal, a dialog box, etc. The <CODE><FONT face="courier,
monospaced"><xsl:message></FONT></CODE> element
is used in the same way as the <CODE><FONT face="courier,
monospaced"><xsl:comment></FONT></CODE> element,
however the message is <B>not</B> output in the result document.</P>
<P>The <CODE><FONT face="courier,
monospaced"><xsl:message></FONT></CODE> element has an attribute
<CODE><FONT face="courier, monospaced">"terminate"</FONT></CODE>
which can be used to terminate the transformation at any
given stage. This is useful when using message to give information about
illegal values in the input document.</P>
</FONT></TD></TR></TABLE><BR><A name="implementation"><!--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>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="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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>The output handler class has a method for outputting comments in the
output document and messages to the operator. The code compiled for a
comment gathers all text that goes into the comment in a StringValueHandler
object, retrieves the full text string from this handler, and then finally
sends it to the output handler. Similarly the code compiled for a message
will simply send the message to the output handler in use.</P>
<P>Messages will be output to the terminal (stdout) when a transformation
is run in a terminal. The message will be output before the beginning of the
output document. Messages will be shown in a dialog box if a transformation
is run in an applet.</P>
<P><CODE><FONT face="courier, monospaced"><xsl:message></FONT></CODE>
elements that use the <CODE><FONT face="courier,
monospaced">"terminate"</FONT></CODE>
attribute to abort transformations cause an exception to be thrown. A
RuntimeException is used for this, and the exception text is:</P>
<P><CODE><FONT face="courier, monospaced">Termination forced by an
xsl:message instruction</FONT></CODE></P>
</FONT></TD></TR></TABLE><BR>
</TD></TR></TABLE></TD></TR></TABLE><BR><TABLE border="0" cellpadding="0"
cellspacing="0" width="620"><TR><TD bgcolor="#0086b2"><IMG height="1"
src="images/dot.gif" width="1"></TD></TR><TR><TD align="center"><FONT
color="#0086b2" size="-1"><I>
Copyright © 2001 The Apache Software Foundation.
All Rights Reserved.
</I></FONT></TD></TR></TABLE></BODY></HTML>
1.1 xml-site/targets/xalan-j/xsltc/xsl_key_design.html
Index: xsl_key_design.html
===================================================================
<HTML><HEAD><SCRIPT language="JavaScript" src="resources/script.js"
type="text/javascript"></SCRIPT><TITLE><xsl:key> / key() /
KeyPattern</TITLE></HEAD><BODY alink="#ff0000" bgcolor="#ffffff" leftmargin="4"
link="#0000ff" marginheight="4" marginwidth="4" text="#000000" topmargin="4"
vlink="#0000aa"><TABLE border="0" cellpadding="0" cellspacing="0"
width="620"><TR><TD align="left" height="60" rowspan="3" valign="top"
width="135"><IMG border="0" height="60" hspace="0" src="resources/logo.gif"
vspace="0" width="135"></TD><TD align="left" colspan="4" height="5"
valign="top" width="456"><IMG border="0" height="5" hspace="0"
src="resources/line.gif" vspace="0" width="456"></TD><TD align="left"
height="60" rowspan="3" valign="top" width="29"><IMG border="0" height="60"
hspace="0" src="resources/right.gif" vspace="0" width="29"></TD></TR><TR><TD
align="left" bgcolor="#0086b2" colspan="4" height="35" valign="top"
width="456"><IMG alt="" border="0" height="35" hspace="0"
src="graphics/xsl_key_design-header.jpg" vspace="0"
width="456"></TD></TR><TR><TD align="left" height="20" valign="top"
width="168"><IMG border="0" height="20" hspace="0" src="resources/bottom.gif"
vspace="0" width="168"></TD><TD align="left" height="20" valign="top"
width="96"><A href="http://xml.apache.org/" onMouseOut="rolloverOff('xml');"
onMouseOver="rolloverOn('xml');" target="new"><IMG alt="http://xml.apache.org/"
border="0" height="20" hspace="0" name="xml"
onLoad="rolloverLoad('xml','resources/button-xml-hi.gif','resources/button-xml-lo.gif');"
src="resources/button-xml-lo.gif" vspace="0" width="96"></A></TD><TD
align="left" height="20" valign="top" width="96"><A
href="http://www.apache.org/" onMouseOut="rolloverOff('asf');"
onMouseOver="rolloverOn('asf');" target="new"><IMG alt="http://www.apache.org/"
border="0" height="20" hspace="0" name="asf"
onLoad="rolloverLoad('asf','resources/button-asf-hi.gif','resources/button-asf-lo.gif');"
src="resources/button-asf-lo.gif" vspace="0" width="96"></A></TD><TD
align="left" height="20" valign="top" width="96"><A href="http://www.w3.org/"
onMouseOut="rolloverOff('w3c');" onMouseOver="rolloverOn('w3c');"
target="new"><IMG alt="http://www.w3.org/" border="0" height="20" hspace="0"
name="w3c"
onLoad="rolloverLoad('w3c','resources/button-w3c-hi.gif','resources/button-w3c-lo.gif');"
src="resources/button-w3c-lo.gif" vspace="0"
width="96"></A></TD></TR></TABLE><TABLE border="0" cellpadding="0"
cellspacing="0" width="620"><TR><TD align="left" valign="top" width="120"><IMG
border="0" height="14" hspace="0" src="resources/join.gif" vspace="0"
width="120"><BR>
<A href="index.html" onMouseOut="rolloverOff('side-index');"
onMouseOver="rolloverOn('side-index');"><IMG alt="Overview" border="0"
height="12" hspace="0" name="side-index"
onLoad="rolloverLoad('side-index','graphics/index-label-2.jpg','graphics/index-label-3.jpg');"
src="graphics/index-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_compiler.html"
onMouseOut="rolloverOff('side-xsltc_compiler');"
onMouseOver="rolloverOn('side-xsltc_compiler');"><IMG alt="Compiler design"
border="0" height="12" hspace="0" name="side-xsltc_compiler"
onLoad="rolloverLoad('side-xsltc_compiler','graphics/xsltc_compiler-label-2.jpg','graphics/xsltc_compiler-label-3.jpg');"
src="graphics/xsltc_compiler-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsl_whitespace_design.html"
onMouseOut="rolloverOff('side-xsl_whitespace_design');"
onMouseOver="rolloverOn('side-xsl_whitespace_design');"><IMG alt="Whitespace"
border="0" height="12" hspace="0" name="side-xsl_whitespace_design"
onLoad="rolloverLoad('side-xsl_whitespace_design','graphics/xsl_whitespace_design-label-2.jpg','graphics/xsl_whitespace_design-label-3.jpg');"
src="graphics/xsl_whitespace_design-label-3.jpg" vspace="0"
width="120"></A><BR>
<A href="xsl_sort_design.html"
onMouseOut="rolloverOff('side-xsl_sort_design');"
onMouseOver="rolloverOn('side-xsl_sort_design');"><IMG alt="xsl:sort"
border="0" height="12" hspace="0" name="side-xsl_sort_design"
onLoad="rolloverLoad('side-xsl_sort_design','graphics/xsl_sort_design-label-2.jpg','graphics/xsl_sort_design-label-3.jpg');"
src="graphics/xsl_sort_design-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG alt="Keys" border="0" height="12" hspace="0"
src="graphics/xsl_key_design-label-1.jpg" vspace="0" width="120"><BR>
<A href="xsl_comment_design.html"
onMouseOut="rolloverOff('side-xsl_comment_design');"
onMouseOver="rolloverOn('side-xsl_comment_design');"><IMG alt="Comment design"
border="0" height="12" hspace="0" name="side-xsl_comment_design"
onLoad="rolloverLoad('side-xsl_comment_design','graphics/xsl_comment_design-label-2.jpg','graphics/xsl_comment_design-label-3.jpg');"
src="graphics/xsl_comment_design-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsl_lang_design.html"
onMouseOut="rolloverOff('side-xsl_lang_design');"
onMouseOver="rolloverOn('side-xsl_lang_design');"><IMG alt="lang()" border="0"
height="12" hspace="0" name="side-xsl_lang_design"
onLoad="rolloverLoad('side-xsl_lang_design','graphics/xsl_lang_design-label-2.jpg','graphics/xsl_lang_design-label-3.jpg');"
src="graphics/xsl_lang_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_unparsed_design.html"
onMouseOut="rolloverOff('side-xsl_unparsed_design');"
onMouseOver="rolloverOn('side-xsl_unparsed_design');"><IMG alt="Unparsed
entities" border="0" height="12" hspace="0" name="side-xsl_unparsed_design"
onLoad="rolloverLoad('side-xsl_unparsed_design','graphics/xsl_unparsed_design-label-2.jpg','graphics/xsl_unparsed_design-label-3.jpg');"
src="graphics/xsl_unparsed_design-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_runtime.html"
onMouseOut="rolloverOff('side-xsltc_runtime');"
onMouseOver="rolloverOn('side-xsltc_runtime');"><IMG alt="Runtime" border="0"
height="12" hspace="0" name="side-xsltc_runtime"
onLoad="rolloverLoad('side-xsltc_runtime','graphics/xsltc_runtime-label-2.jpg','graphics/xsltc_runtime-label-3.jpg');"
src="graphics/xsltc_runtime-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_dom.html" onMouseOut="rolloverOff('side-xsltc_dom');"
onMouseOver="rolloverOn('side-xsltc_dom');"><IMG alt="Internal DOM" border="0"
height="12" hspace="0" name="side-xsltc_dom"
onLoad="rolloverLoad('side-xsltc_dom','graphics/xsltc_dom-label-2.jpg','graphics/xsltc_dom-label-3.jpg');"
src="graphics/xsltc_dom-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsltc_namespace.html"
onMouseOut="rolloverOff('side-xsltc_namespace');"
onMouseOver="rolloverOn('side-xsltc_namespace');"><IMG alt="Namespaces"
border="0" height="12" hspace="0" name="side-xsltc_namespace"
onLoad="rolloverLoad('side-xsltc_namespace','graphics/xsltc_namespace-label-2.jpg','graphics/xsltc_namespace-label-3.jpg');"
src="graphics/xsltc_namespace-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_trax.html" onMouseOut="rolloverOff('side-xsltc_trax');"
onMouseOver="rolloverOn('side-xsltc_trax');"><IMG alt="Translet & TrAX"
border="0" height="12" hspace="0" name="side-xsltc_trax"
onLoad="rolloverLoad('side-xsltc_trax','graphics/xsltc_trax-label-2.jpg','graphics/xsltc_trax-label-3.jpg');"
src="graphics/xsltc_trax-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="todo.html" onMouseOut="rolloverOff('side-ext-40');"
onMouseOver="rolloverOn('side-ext-40');"><IMG alt="To-do list" border="0"
height="12" hspace="0" name="side-ext-40"
onLoad="rolloverLoad('side-ext-40','graphics/ext-40-label-2.jpg','graphics/ext-40-label-3.jpg');"
src="graphics/ext-40-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="14" hspace="0" src="resources/close.gif" vspace="0"
width="120"><BR></TD><TD align="left" valign="top" width="500"><TABLE
border="0" cellpadding="3" cellspacing="0"><TR><TD>
<UL>
<LI><A href="#functionality">Functionality</A></LI>
<LI><A href="#implementation">Implementation</A></LI>
</UL>
<A name="functionality"><!--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>Functionality</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>The <CODE><FONT face="courier, monospaced"><xsl:key></FONT></CODE>
element is a top-level element that can be
used to define a named index of nodes from the source XML tree(s). The
element has three attributes:</P>
<UL>
<LI>
<CODE><FONT face="courier, monospaced">name</FONT></CODE> - the name of
the index
</LI>
<LI>
<CODE><FONT face="courier, monospaced">match</FONT></CODE> - a pattern
that defines the nodeset we want
indexed
</LI>
<LI>
<CODE><FONT face="courier, monospaced">use</FONT></CODE> - an
expression that defines the value to be used
as the index key value.
</LI>
</UL>
<P>A named index can be accessed using either the <CODE><FONT
face="courier, monospaced">key()</FONT></CODE> function or
a KeyPattern. Both these methods address the index using its defined name
(the "name" attribute above) and a parameter defining one or more
lookup
values for the index. The function or pattern returns a node set containing
all nodes in the index whose key value match the parameter's value(s):</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>
<xsl:key name="book-author" match="book"
use="author"/>
:
:
<xsl:for-each select="key('book-author', 'Mikhail
Bulgakov')">
<xsl:value-of select="author"/>
<xsl:text>: </xsl:text>
<xsl:value-of select="author"/>
<xsl:text>&#xa;</xsl:text>
</xsl:for-each>
</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>
<P>The KeyPattern can be used within an index definition to create unions
and intersections of node sets:</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>
<xsl:key name="cultcies" match="farmer |
fisherman" use="name"/>
</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>
<P>This could of course be done using regular <CODE><FONT face="courier,
monospaced"><xsl:for-each></FONT></CODE>
and <CODE><FONT face="courier, monospaced"><xsl:select></FONT></CODE>
elements. However, if your stylesheet
accesses the same selection of nodes over and over again, the transformation
will be much more efficient using pre-indexed keys as shown above.</P>
</FONT></TD></TR></TABLE><BR><A name="implementation"><!--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>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="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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>AbstractTranslet has a global hashtable that holds an index for each
named
key in the stylesheet (hashing on the "name" attribute of
xsl:key).
AbstractTranslet has a couple of public methods for inserting and retrieving
data from this hashtable:</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>
public void buildKeyIndex(String name, int nodeID, String value);
public KeyIndex KeyIndex getKeyIndex(String name);
</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>
<P>The Key class compiles code that traverses the input DOM and extracts
nodes that match some given parameters (the <CODE><FONT face="courier,
monospaced">"match"</FONT></CODE> attribute of the
<CODE><FONT face="courier, monospaced"><xsl:key></FONT></CODE>
element). A new element is inserted into the named
key's index. The nodes' DOM index and the value translated from the
<CODE><FONT face="courier, monospaced">"use"</FONT></CODE>
attribute of the <CODE><FONT face="courier,
monospaced"><xsl:key></FONT></CODE> element are stored
in the new entry in the index.</P>
<P>The index itself is implemented in the <CODE><FONT face="courier,
monospaced">KeyIndex</FONT></CODE> class.
The index has an hashtable with all the values from the matching nodes (the
part of the node used to generate this value is the one specified in the
<CODE><FONT face="courier, monospaced">"use"</FONT></CODE>
attribute). For every matching value there is a Vector
holding a list of all node indexes for which this value gives a match:</P>
<P><IMG align="right" border="0" hspace="4" src="images/key_relations.gif"
vspace="4"><BR clear="all"></P>
<P><I>Figure 1: Indexing tables</I></P>
<P>The <CODE><FONT face="courier, monospaced">KeyIndex</FONT></CODE> class
implements the <CODE><FONT face="courier, monospaced">NodeIterator</FONT></CODE>
interface, so that it can be returned directly by the implementation of the
<CODE><FONT face="courier, monospaced">key()</FONT></CODE> function. This
is how the index generated by
<CODE><FONT face="courier, monospaced"><xsl:key></FONT></CODE> and
the node-set returned by the <CODE><FONT face="courier,
monospaced">key()</FONT></CODE> and
KeyPattern are tied together. You can see how this is done in the
<CODE><FONT face="courier, monospaced">translate()</FONT></CODE> method of
the <CODE><FONT face="courier, monospaced">KeyCall</FONT></CODE> class.</P>
<P>The <CODE><FONT face="courier, monospaced">key()</FONT></CODE> function
can be called in two ways:</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>
key('key-name','value')
key('key-name','node-set')
</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>
<P>The first parameter is always the name of the key. We use this value to
lookup our index from the _keyIndexes hashtable in AbstractTranslet:</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>
il.append(classGen.aloadThis());
_name.translate(classGen, methodGen);
il.append(new INVOKEVIRTUAL(getKeyIndex));
</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>
<P>This compiles into a call to
<CODE><FONT face="courier, monospaced">AbstractTranslet.getKeyIndex(String
name)</FONT></CODE>, and it leaves a
<CODE><FONT face="courier, monospaced">KeyIndex</FONT></CODE> object on the
stack. What we then need to do it to
initialise the <CODE><FONT face="courier,
monospaced">KeyIndex</FONT></CODE> to give us nodes with the requested value.
This is done by leaving the <CODE><FONT face="courier,
monospaced">KeyIndex</FONT></CODE> object on the stack and pushing
the <CODE><FONT face="courier, monospaced">"value"</FONT></CODE>
parameter to <CODE><FONT face="courier, monospaced">key()</FONT></CODE>, before
calling
<CODE><FONT face="courier, monospaced">lookup()</FONT></CODE> on the
index:</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>
il.append(DUP); // duplicate the KeyIndex obejct before return
_value.translate(classGen, methodGen);
il.append(new INVOKEVIRTUAL(lookup));
</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>
<P>This compiles into a call to <CODE><FONT face="courier,
monospaced">KeyIndex.lookup(String value)</FONT></CODE>. This
will initialise the <CODE><FONT face="courier,
monospaced">KeyIndex</FONT></CODE> object to return nodes that match the
given value, so the <CODE><FONT face="courier,
monospaced">KeyIndex</FONT></CODE> object can be left on the stack when
we return. This because the <CODE><FONT face="courier,
monospaced">KeyIndex</FONT></CODE> object implements the
<CODE><FONT face="courier, monospaced">NodeIterator</FONT></CODE>
interface.</P>
<P>This matter is a bit more complex when the second parameter of
<CODE><FONT face="courier, monospaced">key()</FONT></CODE> is a node-set.
In this case we need to traverse the nodes in
the set and do a lookup for each node in the set. What I do is this:</P>
<UL>
<LI>
construct a <CODE><FONT face="courier,
monospaced">KeyIndex</FONT></CODE> object that will hold the return node-set
</LI>
<LI>
find the named <CODE><FONT face="courier,
monospaced">KeyIndex</FONT></CODE> object from the hashtable in
AbstractTranslet
</LI>
<LI>
get an iterator for the node-set and do the folowing loop:</LI>
<UL>
<LI>get string value for current node</LI>
<LI>do lookup in KeyIndex object for the named index</LI>
<LI>merge the resulting node-set into the return node-set</LI>
</UL>
<LI>
leave the return node-set on stack when done
</LI>
</UL>
<P>The only work that remains is to update the <CODE><FONT face="courier,
monospaced">merge()</FONT></CODE> method of
the <CODE><FONT face="courier, monospaced">KeyIndex</FONT></CODE> class so
that it eliminates duplicate nodes in the
resulting node-set.</P>
</FONT></TD></TR></TABLE><BR>
</TD></TR></TABLE></TD></TR></TABLE><BR><TABLE border="0" cellpadding="0"
cellspacing="0" width="620"><TR><TD bgcolor="#0086b2"><IMG height="1"
src="images/dot.gif" width="1"></TD></TR><TR><TD align="center"><FONT
color="#0086b2" size="-1"><I>
Copyright © 2001 The Apache Software Foundation.
All Rights Reserved.
</I></FONT></TD></TR></TABLE></BODY></HTML>
1.1 xml-site/targets/xalan-j/xsltc/xsl_lang_design.html
Index: xsl_lang_design.html
===================================================================
<HTML><HEAD><SCRIPT language="JavaScript" src="resources/script.js"
type="text/javascript"></SCRIPT><TITLE>lang() function</TITLE></HEAD><BODY
alink="#ff0000" bgcolor="#ffffff" leftmargin="4" link="#0000ff"
marginheight="4" marginwidth="4" text="#000000" topmargin="4"
vlink="#0000aa"><TABLE border="0" cellpadding="0" cellspacing="0"
width="620"><TR><TD align="left" height="60" rowspan="3" valign="top"
width="135"><IMG border="0" height="60" hspace="0" src="resources/logo.gif"
vspace="0" width="135"></TD><TD align="left" colspan="4" height="5"
valign="top" width="456"><IMG border="0" height="5" hspace="0"
src="resources/line.gif" vspace="0" width="456"></TD><TD align="left"
height="60" rowspan="3" valign="top" width="29"><IMG border="0" height="60"
hspace="0" src="resources/right.gif" vspace="0" width="29"></TD></TR><TR><TD
align="left" bgcolor="#0086b2" colspan="4" height="35" valign="top"
width="456"><IMG alt="" border="0" height="35" hspace="0"
src="graphics/xsl_lang_design-header.jpg" vspace="0"
width="456"></TD></TR><TR><TD align="left" height="20" valign="top"
width="168"><IMG border="0" height="20" hspace="0" src="resources/bottom.gif"
vspace="0" width="168"></TD><TD align="left" height="20" valign="top"
width="96"><A href="http://xml.apache.org/" onMouseOut="rolloverOff('xml');"
onMouseOver="rolloverOn('xml');" target="new"><IMG alt="http://xml.apache.org/"
border="0" height="20" hspace="0" name="xml"
onLoad="rolloverLoad('xml','resources/button-xml-hi.gif','resources/button-xml-lo.gif');"
src="resources/button-xml-lo.gif" vspace="0" width="96"></A></TD><TD
align="left" height="20" valign="top" width="96"><A
href="http://www.apache.org/" onMouseOut="rolloverOff('asf');"
onMouseOver="rolloverOn('asf');" target="new"><IMG alt="http://www.apache.org/"
border="0" height="20" hspace="0" name="asf"
onLoad="rolloverLoad('asf','resources/button-asf-hi.gif','resources/button-asf-lo.gif');"
src="resources/button-asf-lo.gif" vspace="0" width="96"></A></TD><TD
align="left" height="20" valign="top" width="96"><A href="http://www.w3.org/"
onMouseOut="rolloverOff('w3c');" onMouseOver="rolloverOn('w3c');"
target="new"><IMG alt="http://www.w3.org/" border="0" height="20" hspace="0"
name="w3c"
onLoad="rolloverLoad('w3c','resources/button-w3c-hi.gif','resources/button-w3c-lo.gif');"
src="resources/button-w3c-lo.gif" vspace="0"
width="96"></A></TD></TR></TABLE><TABLE border="0" cellpadding="0"
cellspacing="0" width="620"><TR><TD align="left" valign="top" width="120"><IMG
border="0" height="14" hspace="0" src="resources/join.gif" vspace="0"
width="120"><BR>
<A href="index.html" onMouseOut="rolloverOff('side-index');"
onMouseOver="rolloverOn('side-index');"><IMG alt="Overview" border="0"
height="12" hspace="0" name="side-index"
onLoad="rolloverLoad('side-index','graphics/index-label-2.jpg','graphics/index-label-3.jpg');"
src="graphics/index-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_compiler.html"
onMouseOut="rolloverOff('side-xsltc_compiler');"
onMouseOver="rolloverOn('side-xsltc_compiler');"><IMG alt="Compiler design"
border="0" height="12" hspace="0" name="side-xsltc_compiler"
onLoad="rolloverLoad('side-xsltc_compiler','graphics/xsltc_compiler-label-2.jpg','graphics/xsltc_compiler-label-3.jpg');"
src="graphics/xsltc_compiler-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsl_whitespace_design.html"
onMouseOut="rolloverOff('side-xsl_whitespace_design');"
onMouseOver="rolloverOn('side-xsl_whitespace_design');"><IMG alt="Whitespace"
border="0" height="12" hspace="0" name="side-xsl_whitespace_design"
onLoad="rolloverLoad('side-xsl_whitespace_design','graphics/xsl_whitespace_design-label-2.jpg','graphics/xsl_whitespace_design-label-3.jpg');"
src="graphics/xsl_whitespace_design-label-3.jpg" vspace="0"
width="120"></A><BR>
<A href="xsl_sort_design.html"
onMouseOut="rolloverOff('side-xsl_sort_design');"
onMouseOver="rolloverOn('side-xsl_sort_design');"><IMG alt="xsl:sort"
border="0" height="12" hspace="0" name="side-xsl_sort_design"
onLoad="rolloverLoad('side-xsl_sort_design','graphics/xsl_sort_design-label-2.jpg','graphics/xsl_sort_design-label-3.jpg');"
src="graphics/xsl_sort_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_key_design.html"
onMouseOut="rolloverOff('side-xsl_key_design');"
onMouseOver="rolloverOn('side-xsl_key_design');"><IMG alt="Keys" border="0"
height="12" hspace="0" name="side-xsl_key_design"
onLoad="rolloverLoad('side-xsl_key_design','graphics/xsl_key_design-label-2.jpg','graphics/xsl_key_design-label-3.jpg');"
src="graphics/xsl_key_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_comment_design.html"
onMouseOut="rolloverOff('side-xsl_comment_design');"
onMouseOver="rolloverOn('side-xsl_comment_design');"><IMG alt="Comment design"
border="0" height="12" hspace="0" name="side-xsl_comment_design"
onLoad="rolloverLoad('side-xsl_comment_design','graphics/xsl_comment_design-label-2.jpg','graphics/xsl_comment_design-label-3.jpg');"
src="graphics/xsl_comment_design-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<IMG alt="lang()" border="0" height="12" hspace="0"
src="graphics/xsl_lang_design-label-1.jpg" vspace="0" width="120"><BR>
<A href="xsl_unparsed_design.html"
onMouseOut="rolloverOff('side-xsl_unparsed_design');"
onMouseOver="rolloverOn('side-xsl_unparsed_design');"><IMG alt="Unparsed
entities" border="0" height="12" hspace="0" name="side-xsl_unparsed_design"
onLoad="rolloverLoad('side-xsl_unparsed_design','graphics/xsl_unparsed_design-label-2.jpg','graphics/xsl_unparsed_design-label-3.jpg');"
src="graphics/xsl_unparsed_design-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_runtime.html"
onMouseOut="rolloverOff('side-xsltc_runtime');"
onMouseOver="rolloverOn('side-xsltc_runtime');"><IMG alt="Runtime" border="0"
height="12" hspace="0" name="side-xsltc_runtime"
onLoad="rolloverLoad('side-xsltc_runtime','graphics/xsltc_runtime-label-2.jpg','graphics/xsltc_runtime-label-3.jpg');"
src="graphics/xsltc_runtime-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_dom.html" onMouseOut="rolloverOff('side-xsltc_dom');"
onMouseOver="rolloverOn('side-xsltc_dom');"><IMG alt="Internal DOM" border="0"
height="12" hspace="0" name="side-xsltc_dom"
onLoad="rolloverLoad('side-xsltc_dom','graphics/xsltc_dom-label-2.jpg','graphics/xsltc_dom-label-3.jpg');"
src="graphics/xsltc_dom-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsltc_namespace.html"
onMouseOut="rolloverOff('side-xsltc_namespace');"
onMouseOver="rolloverOn('side-xsltc_namespace');"><IMG alt="Namespaces"
border="0" height="12" hspace="0" name="side-xsltc_namespace"
onLoad="rolloverLoad('side-xsltc_namespace','graphics/xsltc_namespace-label-2.jpg','graphics/xsltc_namespace-label-3.jpg');"
src="graphics/xsltc_namespace-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_trax.html" onMouseOut="rolloverOff('side-xsltc_trax');"
onMouseOver="rolloverOn('side-xsltc_trax');"><IMG alt="Translet & TrAX"
border="0" height="12" hspace="0" name="side-xsltc_trax"
onLoad="rolloverLoad('side-xsltc_trax','graphics/xsltc_trax-label-2.jpg','graphics/xsltc_trax-label-3.jpg');"
src="graphics/xsltc_trax-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="todo.html" onMouseOut="rolloverOff('side-ext-40');"
onMouseOver="rolloverOn('side-ext-40');"><IMG alt="To-do list" border="0"
height="12" hspace="0" name="side-ext-40"
onLoad="rolloverLoad('side-ext-40','graphics/ext-40-label-2.jpg','graphics/ext-40-label-3.jpg');"
src="graphics/ext-40-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="14" hspace="0" src="resources/close.gif" vspace="0"
width="120"><BR></TD><TD align="left" valign="top" width="500"><TABLE
border="0" cellpadding="3" cellspacing="0"><TR><TD>
<UL>
<LI><A href="#functionality">Functionality</A></LI>
<LI><A href="#implementation">Implementation</A></LI>
</UL>
<A name="functionality"><!--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>Functionality</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>The <CODE><FONT face="courier, monospaced">xml:lang</FONT></CODE> can be
used to determine the language for a node or
a node-set. The attribute can be used to store language-specific data in an
XML document:</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>
<phrases>
<greeting xml:lang="en">Hello!</greeting>
<greeting xml:lang="no">Hei!</greeting>
<greeting xml:lang="fr">Salut!</greeting>
<greeting xml:lang="es">Hola!</greeting>
<greeting xml:lang="de">Sweinhund!</greeting>
</phrases>
</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>
<P>The XSL stylesheet can use the <CODE><FONT face="courier,
monospaced">lang()</FONT></CODE> function to select the
element with the desired language:</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>
<xsl:template match="greeting">
<xsl:if test="lang("de")>
<xsl:value-of select="."/>
<xsl:text> Grossglucklicher wunche!</xsl:text>
</xsl:if>
</xsl:template>
</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="implementation"><!--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>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="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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>The DOM interface has been given a method that returns the language for
a given node. The language is returned as a string (on whatever format is
used in the XML document - should be iso), and may be null if no language is
defined.</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>
public String DOM.getLanguage(int node);
</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>
<P>The BasisLibrary class has a static method that will compare the language
of the context node with some other language and return the result as a
boolean.</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>
public static boolean BasisLibrary.testLanguage(String language, DOM dom,
int node);
</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>
<P>The compiled code for the <CODE><FONT face="courier,
monospaced">lang()</FONT></CODE> method calls this method in the
BasisLibrary and leaves the result on the stack for the calling element.</P>
</FONT></TD></TR></TABLE><BR>
</TD></TR></TABLE></TD></TR></TABLE><BR><TABLE border="0" cellpadding="0"
cellspacing="0" width="620"><TR><TD bgcolor="#0086b2"><IMG height="1"
src="images/dot.gif" width="1"></TD></TR><TR><TD align="center"><FONT
color="#0086b2" size="-1"><I>
Copyright © 2001 The Apache Software Foundation.
All Rights Reserved.
</I></FONT></TD></TR></TABLE></BODY></HTML>
1.1 xml-site/targets/xalan-j/xsltc/xsl_sort_design.html
Index: xsl_sort_design.html
===================================================================
<HTML><HEAD><SCRIPT language="JavaScript" src="resources/script.js"
type="text/javascript"></SCRIPT><TITLE><xsl:sort></TITLE></HEAD><BODY
alink="#ff0000" bgcolor="#ffffff" leftmargin="4" link="#0000ff"
marginheight="4" marginwidth="4" text="#000000" topmargin="4"
vlink="#0000aa"><TABLE border="0" cellpadding="0" cellspacing="0"
width="620"><TR><TD align="left" height="60" rowspan="3" valign="top"
width="135"><IMG border="0" height="60" hspace="0" src="resources/logo.gif"
vspace="0" width="135"></TD><TD align="left" colspan="4" height="5"
valign="top" width="456"><IMG border="0" height="5" hspace="0"
src="resources/line.gif" vspace="0" width="456"></TD><TD align="left"
height="60" rowspan="3" valign="top" width="29"><IMG border="0" height="60"
hspace="0" src="resources/right.gif" vspace="0" width="29"></TD></TR><TR><TD
align="left" bgcolor="#0086b2" colspan="4" height="35" valign="top"
width="456"><IMG alt="" border="0" height="35" hspace="0"
src="graphics/xsl_sort_design-header.jpg" vspace="0"
width="456"></TD></TR><TR><TD align="left" height="20" valign="top"
width="168"><IMG border="0" height="20" hspace="0" src="resources/bottom.gif"
vspace="0" width="168"></TD><TD align="left" height="20" valign="top"
width="96"><A href="http://xml.apache.org/" onMouseOut="rolloverOff('xml');"
onMouseOver="rolloverOn('xml');" target="new"><IMG alt="http://xml.apache.org/"
border="0" height="20" hspace="0" name="xml"
onLoad="rolloverLoad('xml','resources/button-xml-hi.gif','resources/button-xml-lo.gif');"
src="resources/button-xml-lo.gif" vspace="0" width="96"></A></TD><TD
align="left" height="20" valign="top" width="96"><A
href="http://www.apache.org/" onMouseOut="rolloverOff('asf');"
onMouseOver="rolloverOn('asf');" target="new"><IMG alt="http://www.apache.org/"
border="0" height="20" hspace="0" name="asf"
onLoad="rolloverLoad('asf','resources/button-asf-hi.gif','resources/button-asf-lo.gif');"
src="resources/button-asf-lo.gif" vspace="0" width="96"></A></TD><TD
align="left" height="20" valign="top" width="96"><A href="http://www.w3.org/"
onMouseOut="rolloverOff('w3c');" onMouseOver="rolloverOn('w3c');"
target="new"><IMG alt="http://www.w3.org/" border="0" height="20" hspace="0"
name="w3c"
onLoad="rolloverLoad('w3c','resources/button-w3c-hi.gif','resources/button-w3c-lo.gif');"
src="resources/button-w3c-lo.gif" vspace="0"
width="96"></A></TD></TR></TABLE><TABLE border="0" cellpadding="0"
cellspacing="0" width="620"><TR><TD align="left" valign="top" width="120"><IMG
border="0" height="14" hspace="0" src="resources/join.gif" vspace="0"
width="120"><BR>
<A href="index.html" onMouseOut="rolloverOff('side-index');"
onMouseOver="rolloverOn('side-index');"><IMG alt="Overview" border="0"
height="12" hspace="0" name="side-index"
onLoad="rolloverLoad('side-index','graphics/index-label-2.jpg','graphics/index-label-3.jpg');"
src="graphics/index-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_compiler.html"
onMouseOut="rolloverOff('side-xsltc_compiler');"
onMouseOver="rolloverOn('side-xsltc_compiler');"><IMG alt="Compiler design"
border="0" height="12" hspace="0" name="side-xsltc_compiler"
onLoad="rolloverLoad('side-xsltc_compiler','graphics/xsltc_compiler-label-2.jpg','graphics/xsltc_compiler-label-3.jpg');"
src="graphics/xsltc_compiler-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsl_whitespace_design.html"
onMouseOut="rolloverOff('side-xsl_whitespace_design');"
onMouseOver="rolloverOn('side-xsl_whitespace_design');"><IMG alt="Whitespace"
border="0" height="12" hspace="0" name="side-xsl_whitespace_design"
onLoad="rolloverLoad('side-xsl_whitespace_design','graphics/xsl_whitespace_design-label-2.jpg','graphics/xsl_whitespace_design-label-3.jpg');"
src="graphics/xsl_whitespace_design-label-3.jpg" vspace="0"
width="120"></A><BR>
<IMG alt="xsl:sort" border="0" height="12" hspace="0"
src="graphics/xsl_sort_design-label-1.jpg" vspace="0" width="120"><BR>
<A href="xsl_key_design.html"
onMouseOut="rolloverOff('side-xsl_key_design');"
onMouseOver="rolloverOn('side-xsl_key_design');"><IMG alt="Keys" border="0"
height="12" hspace="0" name="side-xsl_key_design"
onLoad="rolloverLoad('side-xsl_key_design','graphics/xsl_key_design-label-2.jpg','graphics/xsl_key_design-label-3.jpg');"
src="graphics/xsl_key_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_comment_design.html"
onMouseOut="rolloverOff('side-xsl_comment_design');"
onMouseOver="rolloverOn('side-xsl_comment_design');"><IMG alt="Comment design"
border="0" height="12" hspace="0" name="side-xsl_comment_design"
onLoad="rolloverLoad('side-xsl_comment_design','graphics/xsl_comment_design-label-2.jpg','graphics/xsl_comment_design-label-3.jpg');"
src="graphics/xsl_comment_design-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsl_lang_design.html"
onMouseOut="rolloverOff('side-xsl_lang_design');"
onMouseOver="rolloverOn('side-xsl_lang_design');"><IMG alt="lang()" border="0"
height="12" hspace="0" name="side-xsl_lang_design"
onLoad="rolloverLoad('side-xsl_lang_design','graphics/xsl_lang_design-label-2.jpg','graphics/xsl_lang_design-label-3.jpg');"
src="graphics/xsl_lang_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_unparsed_design.html"
onMouseOut="rolloverOff('side-xsl_unparsed_design');"
onMouseOver="rolloverOn('side-xsl_unparsed_design');"><IMG alt="Unparsed
entities" border="0" height="12" hspace="0" name="side-xsl_unparsed_design"
onLoad="rolloverLoad('side-xsl_unparsed_design','graphics/xsl_unparsed_design-label-2.jpg','graphics/xsl_unparsed_design-label-3.jpg');"
src="graphics/xsl_unparsed_design-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_runtime.html"
onMouseOut="rolloverOff('side-xsltc_runtime');"
onMouseOver="rolloverOn('side-xsltc_runtime');"><IMG alt="Runtime" border="0"
height="12" hspace="0" name="side-xsltc_runtime"
onLoad="rolloverLoad('side-xsltc_runtime','graphics/xsltc_runtime-label-2.jpg','graphics/xsltc_runtime-label-3.jpg');"
src="graphics/xsltc_runtime-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_dom.html" onMouseOut="rolloverOff('side-xsltc_dom');"
onMouseOver="rolloverOn('side-xsltc_dom');"><IMG alt="Internal DOM" border="0"
height="12" hspace="0" name="side-xsltc_dom"
onLoad="rolloverLoad('side-xsltc_dom','graphics/xsltc_dom-label-2.jpg','graphics/xsltc_dom-label-3.jpg');"
src="graphics/xsltc_dom-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsltc_namespace.html"
onMouseOut="rolloverOff('side-xsltc_namespace');"
onMouseOver="rolloverOn('side-xsltc_namespace');"><IMG alt="Namespaces"
border="0" height="12" hspace="0" name="side-xsltc_namespace"
onLoad="rolloverLoad('side-xsltc_namespace','graphics/xsltc_namespace-label-2.jpg','graphics/xsltc_namespace-label-3.jpg');"
src="graphics/xsltc_namespace-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_trax.html" onMouseOut="rolloverOff('side-xsltc_trax');"
onMouseOver="rolloverOn('side-xsltc_trax');"><IMG alt="Translet & TrAX"
border="0" height="12" hspace="0" name="side-xsltc_trax"
onLoad="rolloverLoad('side-xsltc_trax','graphics/xsltc_trax-label-2.jpg','graphics/xsltc_trax-label-3.jpg');"
src="graphics/xsltc_trax-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="todo.html" onMouseOut="rolloverOff('side-ext-40');"
onMouseOver="rolloverOn('side-ext-40');"><IMG alt="To-do list" border="0"
height="12" hspace="0" name="side-ext-40"
onLoad="rolloverLoad('side-ext-40','graphics/ext-40-label-2.jpg','graphics/ext-40-label-3.jpg');"
src="graphics/ext-40-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="14" hspace="0" src="resources/close.gif" vspace="0"
width="120"><BR></TD><TD align="left" valign="top" width="500"><TABLE
border="0" cellpadding="3" cellspacing="0"><TR><TD>
<UL>
<LI><A href="#functionality">Functionality</A></LI>
<LI><A href="#sort-class">The Sort class</A></LI>
<LI><A href="#sortingiterator-class">The SortingIterator class</A></LI>
<LI><A href="#nodesortrecord-class">The NodeSortRecord class</A></LI>
<LI><A href="#nodesortrecordfactory-class">The NodeSortRecordFactory
class</A></LI>
</UL>
<A name="functionality"><!--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>Functionality</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>The <CODE><FONT face="courier,
monospaced"><xsl:sort></FONT></CODE> element is used to define a sort key
which
specifies the order in which nodes selected by either
<CODE><FONT face="courier,
monospaced"><xsl:apply-templates></FONT></CODE> or <CODE><FONT
face="courier, monospaced"><xsl:for-each></FONT></CODE> are
processed. The nodes can be sorted either in numerical or alphabetic order,
and the alphabetic order may vary depeinding on the language in use. The
nodes can be sorted either in ascending or descending order.</P>
</FONT></TD></TR></TABLE><BR><A name="sort-class"><!--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 Sort class</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>Static methods of the Sort class is responsible for generating the
necessary code for invoking SortingIterators under
<CODE><FONT face="courier,
monospaced"><xsl:apply-templates></FONT></CODE> and <CODE><FONT
face="courier, monospaced"><xsl:for-each></FONT></CODE>
elements. Both these elements can have several <CODE><FONT face="courier,
monospaced"><xsl:sort></FONT></CODE>
child nodes defining primary, secondary, teriary, etc. keys. The code for
<CODE><FONT face="courier,
monospaced"><xsl:apply-templates></FONT></CODE> and <CODE><FONT
face="courier, monospaced"><xsl:for-each></FONT></CODE>
create vectors containg a Sort object for each sort key. The object methods
of the Sort object encapsulate a container for key-specific data (such as
the
sort key itself, sort order, sort type, and such) while the static methods
take a vector of Sort objects and generate the actual code.</P>
<P>The <CODE><FONT face="courier, monospaced">translate()</FONT></CODE>
method of the Sort object is never called. The
vectors containing the Sort objects for a <CODE><FONT face="courier,
monospaced"><xsl:apply-templates></FONT></CODE>
or <CODE><FONT face="courier,
monospaced"><xsl:for-each></FONT></CODE> element are instead passed to
the static
<CODE><FONT face="courier,
monospaced">translateSortIterator()</FONT></CODE> method. This method compiles
code that
instanciates a SortingIterator object that will pass on a node-set in a
specific order to the code handling the <CODE><FONT face="courier,
monospaced"><xsl:apply-templates></FONT></CODE>
or <CODE><FONT face="courier,
monospaced"><xsl:for-each></FONT></CODE> element.</P>
</FONT></TD></TR></TABLE><BR><A
name="sortingiterator-class"><!--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 SortingIterator class</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>The SortingIterator class is responsible for sorting nodes encapsulated
in
sort obects. These sort objects must be of a class inheriting from
NodeSortRecord, a the SortingIterator object needs a factory object
providing
it with the correct type of objects:</P>
<P><IMG align="right" border="0" hspace="4" src="images/sort_objects.gif"
vspace="4"><BR clear="all"></P>
<P><I>Figure 1: SortingIterator</I></P>
<P>The SortingIterator class is fairly dumb and leaves much of the work to
the
NodeSortRecord class. The iterator gets the NodeSortRecords from the factory
object and sorts them using quicksort and calling <CODE><FONT
face="courier, monospaced">compareTo()</FONT></CODE> on
pairs of NodeSortRecord objects.</P>
</FONT></TD></TR></TABLE><BR><A
name="nodesortrecord-class"><!--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 NodeSortRecord class</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>The static methods in the Sort class generates a class inheriting from
NodeSortRecord, with the following overloaded methods:</P>
<UL>
<LI><B>Class Constructor</B></LI>
<UL><LI>The class constructor is overloaded to create sort-key global
tables, such as an array containing the sort order for all the sort keys
and another array containg all the sort types. Different sort
order/types
can be specified for the different levels of sort keys, but we assume
that
the same language is used for all levels.</LI></UL>
<LI><CODE><FONT face="courier, monospaced">extractValueFromDOM(int
level)</FONT></CODE></LI>
<UL><LI>This method is called by the SortingIterator object to extract
the
value for a specific sort key for a node. The SortingIterator will only
use this method once and will cache the returned value for later use.
The
method will only be called if absultely necessary.</LI></UL>
<LI><CODE><FONT face="courier, monospaced">compareType(int
level)</FONT></CODE></LI>
<UL><LI>This method returns the sort type for one sort key level.
Returns
either <CODE><FONT face="courier,
monospaced">COMPARE_STRING</FONT></CODE> or <CODE><FONT face="courier,
monospaced">COMPARE_NUMERIC</FONT></CODE>.</LI></UL>
<LI><CODE><FONT face="courier, monospaced">sortOrder(int
level)</FONT></CODE></LI>
<UL><LI>This method returns the sort order for one sort key level.
Returns
either <CODE><FONT face="courier,
monospaced">COMPARE_ASCENDING</FONT></CODE> or <CODE><FONT face="courier,
monospaced">COMPARE_DESCENDING</FONT></CODE></LI></UL>
<LI><CODE><FONT face="courier, monospaced">getCollator(int
level)</FONT></CODE></LI>
<UL><LI>This method returns a Collator object for language-specific
string comparisons. The same Collator is used for all levels of the key.
</LI></UL>
</UL>
<P>The <CODE><FONT face="courier, monospaced">compareTo()</FONT></CODE>
method of the NodeSortRecord base class deserves
a bit of attention. It takes its own node (from the this pointer) and
another
node and compares, if necessary, the values for all sort keys:</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>
/**
* Compare this sort element to another. The first level is checked first,
* and we proceed to the next level only if the first level keys are
* identical (and so the key values may not even be extracted from the
DOM)
*/
public int compareTo(NodeSortRecord other) {
int cmp;
for (int level=0; level<_levels; level++) {
// Compare the two nodes either as numeric or text values
if (compareType(level) == COMPARE_NUMERIC) {
final Double our = numericValue(level);
final Double their = other.numericValue(level);
if (our == null) return(-1);
if (their == null) return(1);
cmp = our.compareTo(their);
}
else {
String our = stringValue(level);
String their = other.stringValue(level);
if (our == null) return(-1);
if (their == null) return(1);
cmp = getCollator().compare(our,their);
}
// Return inverse compare value if inverse sort order
if (cmp != 0) {
if (sortOrder(level) == COMPARE_DESCENDING)
return(0 - cmp);
else
return(cmp);
}
}
return(0);
}
</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>
<P>The two methods <CODE><FONT face="courier, monospaced">stringValue(int
level)</FONT></CODE> and
<CODE><FONT face="courier, monospaced">numericValue(int
level)</FONT></CODE> return values for one level of the sort key
of a node. These methods cache these values after they are first read so
that
the <CODE><FONT face="courier, monospaced">DOM.getNodeValue()</FONT></CODE>
is only called once. Also, the algorithm
used for these two methods assure that <CODE><FONT face="courier,
monospaced">DOM.getNodeValue()</FONT></CODE> is only
called when needed. The value for a node's secondary sort key is never
retrieved if the node can be uniquely identified by its primary key.</P>
</FONT></TD></TR></TABLE><BR><A
name="nodesortrecordfactory-class"><!--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 NodeSortRecordFactory class</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>After the static methods of the Sort class has generated the new class
for
sort objects it generates code that instanciates a new NodeSortRecordFactory
object. This object is passed as a parameter to SortingIterators constructor
and is used by the iterator to generate the necessary sort objects.</P>
</FONT></TD></TR></TABLE><BR>
</TD></TR></TABLE></TD></TR></TABLE><BR><TABLE border="0" cellpadding="0"
cellspacing="0" width="620"><TR><TD bgcolor="#0086b2"><IMG height="1"
src="images/dot.gif" width="1"></TD></TR><TR><TD align="center"><FONT
color="#0086b2" size="-1"><I>
Copyright © 2001 The Apache Software Foundation.
All Rights Reserved.
</I></FONT></TD></TR></TABLE></BODY></HTML>
1.1 xml-site/targets/xalan-j/xsltc/xsl_unparsed_design.html
Index: xsl_unparsed_design.html
===================================================================
<HTML><HEAD><SCRIPT language="JavaScript" src="resources/script.js"
type="text/javascript"></SCRIPT><TITLE>unparsed-entity-uri()</TITLE></HEAD><BODY
alink="#ff0000" bgcolor="#ffffff" leftmargin="4" link="#0000ff"
marginheight="4" marginwidth="4" text="#000000" topmargin="4"
vlink="#0000aa"><TABLE border="0" cellpadding="0" cellspacing="0"
width="620"><TR><TD align="left" height="60" rowspan="3" valign="top"
width="135"><IMG border="0" height="60" hspace="0" src="resources/logo.gif"
vspace="0" width="135"></TD><TD align="left" colspan="4" height="5"
valign="top" width="456"><IMG border="0" height="5" hspace="0"
src="resources/line.gif" vspace="0" width="456"></TD><TD align="left"
height="60" rowspan="3" valign="top" width="29"><IMG border="0" height="60"
hspace="0" src="resources/right.gif" vspace="0" width="29"></TD></TR><TR><TD
align="left" bgcolor="#0086b2" colspan="4" height="35" valign="top"
width="456"><IMG alt="" border="0" height="35" hspace="0"
src="graphics/xsl_unparsed_design-header.jpg" vspace="0"
width="456"></TD></TR><TR><TD align="left" height="20" valign="top"
width="168"><IMG border="0" height="20" hspace="0" src="resources/bottom.gif"
vspace="0" width="168"></TD><TD align="left" height="20" valign="top"
width="96"><A href="http://xml.apache.org/" onMouseOut="rolloverOff('xml');"
onMouseOver="rolloverOn('xml');" target="new"><IMG alt="http://xml.apache.org/"
border="0" height="20" hspace="0" name="xml"
onLoad="rolloverLoad('xml','resources/button-xml-hi.gif','resources/button-xml-lo.gif');"
src="resources/button-xml-lo.gif" vspace="0" width="96"></A></TD><TD
align="left" height="20" valign="top" width="96"><A
href="http://www.apache.org/" onMouseOut="rolloverOff('asf');"
onMouseOver="rolloverOn('asf');" target="new"><IMG alt="http://www.apache.org/"
border="0" height="20" hspace="0" name="asf"
onLoad="rolloverLoad('asf','resources/button-asf-hi.gif','resources/button-asf-lo.gif');"
src="resources/button-asf-lo.gif" vspace="0" width="96"></A></TD><TD
align="left" height="20" valign="top" width="96"><A href="http://www.w3.org/"
onMouseOut="rolloverOff('w3c');" onMouseOver="rolloverOn('w3c');"
target="new"><IMG alt="http://www.w3.org/" border="0" height="20" hspace="0"
name="w3c"
onLoad="rolloverLoad('w3c','resources/button-w3c-hi.gif','resources/button-w3c-lo.gif');"
src="resources/button-w3c-lo.gif" vspace="0"
width="96"></A></TD></TR></TABLE><TABLE border="0" cellpadding="0"
cellspacing="0" width="620"><TR><TD align="left" valign="top" width="120"><IMG
border="0" height="14" hspace="0" src="resources/join.gif" vspace="0"
width="120"><BR>
<A href="index.html" onMouseOut="rolloverOff('side-index');"
onMouseOver="rolloverOn('side-index');"><IMG alt="Overview" border="0"
height="12" hspace="0" name="side-index"
onLoad="rolloverLoad('side-index','graphics/index-label-2.jpg','graphics/index-label-3.jpg');"
src="graphics/index-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_compiler.html"
onMouseOut="rolloverOff('side-xsltc_compiler');"
onMouseOver="rolloverOn('side-xsltc_compiler');"><IMG alt="Compiler design"
border="0" height="12" hspace="0" name="side-xsltc_compiler"
onLoad="rolloverLoad('side-xsltc_compiler','graphics/xsltc_compiler-label-2.jpg','graphics/xsltc_compiler-label-3.jpg');"
src="graphics/xsltc_compiler-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsl_whitespace_design.html"
onMouseOut="rolloverOff('side-xsl_whitespace_design');"
onMouseOver="rolloverOn('side-xsl_whitespace_design');"><IMG alt="Whitespace"
border="0" height="12" hspace="0" name="side-xsl_whitespace_design"
onLoad="rolloverLoad('side-xsl_whitespace_design','graphics/xsl_whitespace_design-label-2.jpg','graphics/xsl_whitespace_design-label-3.jpg');"
src="graphics/xsl_whitespace_design-label-3.jpg" vspace="0"
width="120"></A><BR>
<A href="xsl_sort_design.html"
onMouseOut="rolloverOff('side-xsl_sort_design');"
onMouseOver="rolloverOn('side-xsl_sort_design');"><IMG alt="xsl:sort"
border="0" height="12" hspace="0" name="side-xsl_sort_design"
onLoad="rolloverLoad('side-xsl_sort_design','graphics/xsl_sort_design-label-2.jpg','graphics/xsl_sort_design-label-3.jpg');"
src="graphics/xsl_sort_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_key_design.html"
onMouseOut="rolloverOff('side-xsl_key_design');"
onMouseOver="rolloverOn('side-xsl_key_design');"><IMG alt="Keys" border="0"
height="12" hspace="0" name="side-xsl_key_design"
onLoad="rolloverLoad('side-xsl_key_design','graphics/xsl_key_design-label-2.jpg','graphics/xsl_key_design-label-3.jpg');"
src="graphics/xsl_key_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_comment_design.html"
onMouseOut="rolloverOff('side-xsl_comment_design');"
onMouseOver="rolloverOn('side-xsl_comment_design');"><IMG alt="Comment design"
border="0" height="12" hspace="0" name="side-xsl_comment_design"
onLoad="rolloverLoad('side-xsl_comment_design','graphics/xsl_comment_design-label-2.jpg','graphics/xsl_comment_design-label-3.jpg');"
src="graphics/xsl_comment_design-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsl_lang_design.html"
onMouseOut="rolloverOff('side-xsl_lang_design');"
onMouseOver="rolloverOn('side-xsl_lang_design');"><IMG alt="lang()" border="0"
height="12" hspace="0" name="side-xsl_lang_design"
onLoad="rolloverLoad('side-xsl_lang_design','graphics/xsl_lang_design-label-2.jpg','graphics/xsl_lang_design-label-3.jpg');"
src="graphics/xsl_lang_design-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG alt="Unparsed entities" border="0" height="12" hspace="0"
src="graphics/xsl_unparsed_design-label-1.jpg" vspace="0" width="120"><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_runtime.html"
onMouseOut="rolloverOff('side-xsltc_runtime');"
onMouseOver="rolloverOn('side-xsltc_runtime');"><IMG alt="Runtime" border="0"
height="12" hspace="0" name="side-xsltc_runtime"
onLoad="rolloverLoad('side-xsltc_runtime','graphics/xsltc_runtime-label-2.jpg','graphics/xsltc_runtime-label-3.jpg');"
src="graphics/xsltc_runtime-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_dom.html" onMouseOut="rolloverOff('side-xsltc_dom');"
onMouseOver="rolloverOn('side-xsltc_dom');"><IMG alt="Internal DOM" border="0"
height="12" hspace="0" name="side-xsltc_dom"
onLoad="rolloverLoad('side-xsltc_dom','graphics/xsltc_dom-label-2.jpg','graphics/xsltc_dom-label-3.jpg');"
src="graphics/xsltc_dom-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsltc_namespace.html"
onMouseOut="rolloverOff('side-xsltc_namespace');"
onMouseOver="rolloverOn('side-xsltc_namespace');"><IMG alt="Namespaces"
border="0" height="12" hspace="0" name="side-xsltc_namespace"
onLoad="rolloverLoad('side-xsltc_namespace','graphics/xsltc_namespace-label-2.jpg','graphics/xsltc_namespace-label-3.jpg');"
src="graphics/xsltc_namespace-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_trax.html" onMouseOut="rolloverOff('side-xsltc_trax');"
onMouseOver="rolloverOn('side-xsltc_trax');"><IMG alt="Translet & TrAX"
border="0" height="12" hspace="0" name="side-xsltc_trax"
onLoad="rolloverLoad('side-xsltc_trax','graphics/xsltc_trax-label-2.jpg','graphics/xsltc_trax-label-3.jpg');"
src="graphics/xsltc_trax-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="todo.html" onMouseOut="rolloverOff('side-ext-40');"
onMouseOver="rolloverOn('side-ext-40');"><IMG alt="To-do list" border="0"
height="12" hspace="0" name="side-ext-40"
onLoad="rolloverLoad('side-ext-40','graphics/ext-40-label-2.jpg','graphics/ext-40-label-3.jpg');"
src="graphics/ext-40-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="14" hspace="0" src="resources/close.gif" vspace="0"
width="120"><BR></TD><TD align="left" valign="top" width="500"><TABLE
border="0" cellpadding="3" cellspacing="0"><TR><TD>
<UL>
<LI><A href="#functionality">Functionality</A></LI>
<LI><A href="#implementation">Implementation</A></LI>
</UL>
<A name="functionality"><!--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>Functionality</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>The <CODE><FONT face="courier,
monospaced">unparsed-entity-uri()</FONT></CODE> function gives access to
declarations
of unparsed entities in the DTD of the source document. If the DTD contains
the declaration:</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>
<!ENTITY mom-picture SYSTEM "http://www.home.com/mom.jpg"
NDATA JPEG>
</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>
<P>the expression <CODE><FONT face="courier,
monospaced">unparsed-entity-uri('mom-picture')</FONT></CODE> returns an
URI for the file <CODE><FONT face="courier,
monospaced">mom.jpg</FONT></CODE>.</P>
</FONT></TD></TR></TABLE><BR><A name="implementation"><!--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>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="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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>Unparsed entities must be gathered from the XML input document at the
time
when the DOM is built. To achieve this our parser must parse the document
DTD
(if any) and store all data of type NDATA (not XML data) in a
hashtable in the AbstractTranslet object. All the compiled code for this
function needs to do is call a method in the translet for retrieving the
value for the requested element:</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>
public String AbstractTranslet.getUnparsedEntity(String entityName);
</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>
<P>The translet will use the supplied <CODE><FONT face="courier,
monospaced">entityName</FONT></CODE> to look up the
value in the hashtable and then leave the string value on the stack for the
element that called <CODE><FONT face="courier,
monospaced">lang()</FONT></CODE>.</P>
</FONT></TD></TR></TABLE><BR>
</TD></TR></TABLE></TD></TR></TABLE><BR><TABLE border="0" cellpadding="0"
cellspacing="0" width="620"><TR><TD bgcolor="#0086b2"><IMG height="1"
src="images/dot.gif" width="1"></TD></TR><TR><TD align="center"><FONT
color="#0086b2" size="-1"><I>
Copyright © 2001 The Apache Software Foundation.
All Rights Reserved.
</I></FONT></TD></TR></TABLE></BODY></HTML>
1.1 xml-site/targets/xalan-j/xsltc/xsl_whitespace_design.html
Index: xsl_whitespace_design.html
===================================================================
<HTML><HEAD><SCRIPT language="JavaScript" src="resources/script.js"
type="text/javascript"></SCRIPT><TITLE><xsl:strip/preserve-space></TITLE></HEAD><BODY
alink="#ff0000" bgcolor="#ffffff" leftmargin="4" link="#0000ff"
marginheight="4" marginwidth="4" text="#000000" topmargin="4"
vlink="#0000aa"><TABLE border="0" cellpadding="0" cellspacing="0"
width="620"><TR><TD align="left" height="60" rowspan="3" valign="top"
width="135"><IMG border="0" height="60" hspace="0" src="resources/logo.gif"
vspace="0" width="135"></TD><TD align="left" colspan="4" height="5"
valign="top" width="456"><IMG border="0" height="5" hspace="0"
src="resources/line.gif" vspace="0" width="456"></TD><TD align="left"
height="60" rowspan="3" valign="top" width="29"><IMG border="0" height="60"
hspace="0" src="resources/right.gif" vspace="0" width="29"></TD></TR><TR><TD
align="left" bgcolor="#0086b2" colspan="4" height="35" valign="top"
width="456"><IMG alt="" border="0" height="35" hspace="0"
src="graphics/xsl_whitespace_design-header.jpg" vspace="0"
width="456"></TD></TR><TR><TD align="left" height="20" valign="top"
width="168"><IMG border="0" height="20" hspace="0" src="resources/bottom.gif"
vspace="0" width="168"></TD><TD align="left" height="20" valign="top"
width="96"><A href="http://xml.apache.org/" onMouseOut="rolloverOff('xml');"
onMouseOver="rolloverOn('xml');" target="new"><IMG alt="http://xml.apache.org/"
border="0" height="20" hspace="0" name="xml"
onLoad="rolloverLoad('xml','resources/button-xml-hi.gif','resources/button-xml-lo.gif');"
src="resources/button-xml-lo.gif" vspace="0" width="96"></A></TD><TD
align="left" height="20" valign="top" width="96"><A
href="http://www.apache.org/" onMouseOut="rolloverOff('asf');"
onMouseOver="rolloverOn('asf');" target="new"><IMG alt="http://www.apache.org/"
border="0" height="20" hspace="0" name="asf"
onLoad="rolloverLoad('asf','resources/button-asf-hi.gif','resources/button-asf-lo.gif');"
src="resources/button-asf-lo.gif" vspace="0" width="96"></A></TD><TD
align="left" height="20" valign="top" width="96"><A href="http://www.w3.org/"
onMouseOut="rolloverOff('w3c');" onMouseOver="rolloverOn('w3c');"
target="new"><IMG alt="http://www.w3.org/" border="0" height="20" hspace="0"
name="w3c"
onLoad="rolloverLoad('w3c','resources/button-w3c-hi.gif','resources/button-w3c-lo.gif');"
src="resources/button-w3c-lo.gif" vspace="0"
width="96"></A></TD></TR></TABLE><TABLE border="0" cellpadding="0"
cellspacing="0" width="620"><TR><TD align="left" valign="top" width="120"><IMG
border="0" height="14" hspace="0" src="resources/join.gif" vspace="0"
width="120"><BR>
<A href="index.html" onMouseOut="rolloverOff('side-index');"
onMouseOver="rolloverOn('side-index');"><IMG alt="Overview" border="0"
height="12" hspace="0" name="side-index"
onLoad="rolloverLoad('side-index','graphics/index-label-2.jpg','graphics/index-label-3.jpg');"
src="graphics/index-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_compiler.html"
onMouseOut="rolloverOff('side-xsltc_compiler');"
onMouseOver="rolloverOn('side-xsltc_compiler');"><IMG alt="Compiler design"
border="0" height="12" hspace="0" name="side-xsltc_compiler"
onLoad="rolloverLoad('side-xsltc_compiler','graphics/xsltc_compiler-label-2.jpg','graphics/xsltc_compiler-label-3.jpg');"
src="graphics/xsltc_compiler-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<IMG alt="Whitespace" border="0" height="12" hspace="0"
src="graphics/xsl_whitespace_design-label-1.jpg" vspace="0" width="120"><BR>
<A href="xsl_sort_design.html"
onMouseOut="rolloverOff('side-xsl_sort_design');"
onMouseOver="rolloverOn('side-xsl_sort_design');"><IMG alt="xsl:sort"
border="0" height="12" hspace="0" name="side-xsl_sort_design"
onLoad="rolloverLoad('side-xsl_sort_design','graphics/xsl_sort_design-label-2.jpg','graphics/xsl_sort_design-label-3.jpg');"
src="graphics/xsl_sort_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_key_design.html"
onMouseOut="rolloverOff('side-xsl_key_design');"
onMouseOver="rolloverOn('side-xsl_key_design');"><IMG alt="Keys" border="0"
height="12" hspace="0" name="side-xsl_key_design"
onLoad="rolloverLoad('side-xsl_key_design','graphics/xsl_key_design-label-2.jpg','graphics/xsl_key_design-label-3.jpg');"
src="graphics/xsl_key_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_comment_design.html"
onMouseOut="rolloverOff('side-xsl_comment_design');"
onMouseOver="rolloverOn('side-xsl_comment_design');"><IMG alt="Comment design"
border="0" height="12" hspace="0" name="side-xsl_comment_design"
onLoad="rolloverLoad('side-xsl_comment_design','graphics/xsl_comment_design-label-2.jpg','graphics/xsl_comment_design-label-3.jpg');"
src="graphics/xsl_comment_design-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsl_lang_design.html"
onMouseOut="rolloverOff('side-xsl_lang_design');"
onMouseOver="rolloverOn('side-xsl_lang_design');"><IMG alt="lang()" border="0"
height="12" hspace="0" name="side-xsl_lang_design"
onLoad="rolloverLoad('side-xsl_lang_design','graphics/xsl_lang_design-label-2.jpg','graphics/xsl_lang_design-label-3.jpg');"
src="graphics/xsl_lang_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_unparsed_design.html"
onMouseOut="rolloverOff('side-xsl_unparsed_design');"
onMouseOver="rolloverOn('side-xsl_unparsed_design');"><IMG alt="Unparsed
entities" border="0" height="12" hspace="0" name="side-xsl_unparsed_design"
onLoad="rolloverLoad('side-xsl_unparsed_design','graphics/xsl_unparsed_design-label-2.jpg','graphics/xsl_unparsed_design-label-3.jpg');"
src="graphics/xsl_unparsed_design-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_runtime.html"
onMouseOut="rolloverOff('side-xsltc_runtime');"
onMouseOver="rolloverOn('side-xsltc_runtime');"><IMG alt="Runtime" border="0"
height="12" hspace="0" name="side-xsltc_runtime"
onLoad="rolloverLoad('side-xsltc_runtime','graphics/xsltc_runtime-label-2.jpg','graphics/xsltc_runtime-label-3.jpg');"
src="graphics/xsltc_runtime-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_dom.html" onMouseOut="rolloverOff('side-xsltc_dom');"
onMouseOver="rolloverOn('side-xsltc_dom');"><IMG alt="Internal DOM" border="0"
height="12" hspace="0" name="side-xsltc_dom"
onLoad="rolloverLoad('side-xsltc_dom','graphics/xsltc_dom-label-2.jpg','graphics/xsltc_dom-label-3.jpg');"
src="graphics/xsltc_dom-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsltc_namespace.html"
onMouseOut="rolloverOff('side-xsltc_namespace');"
onMouseOver="rolloverOn('side-xsltc_namespace');"><IMG alt="Namespaces"
border="0" height="12" hspace="0" name="side-xsltc_namespace"
onLoad="rolloverLoad('side-xsltc_namespace','graphics/xsltc_namespace-label-2.jpg','graphics/xsltc_namespace-label-3.jpg');"
src="graphics/xsltc_namespace-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_trax.html" onMouseOut="rolloverOff('side-xsltc_trax');"
onMouseOver="rolloverOn('side-xsltc_trax');"><IMG alt="Translet & TrAX"
border="0" height="12" hspace="0" name="side-xsltc_trax"
onLoad="rolloverLoad('side-xsltc_trax','graphics/xsltc_trax-label-2.jpg','graphics/xsltc_trax-label-3.jpg');"
src="graphics/xsltc_trax-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="todo.html" onMouseOut="rolloverOff('side-ext-40');"
onMouseOver="rolloverOn('side-ext-40');"><IMG alt="To-do list" border="0"
height="12" hspace="0" name="side-ext-40"
onLoad="rolloverLoad('side-ext-40','graphics/ext-40-label-2.jpg','graphics/ext-40-label-3.jpg');"
src="graphics/ext-40-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="14" hspace="0" src="resources/close.gif" vspace="0"
width="120"><BR></TD><TD align="left" valign="top" width="500"><TABLE
border="0" cellpadding="3" cellspacing="0"><TR><TD>
<UL>
<LI><A href="#functionality">Functionality</A></LI>
<LI><A href="#identify">Identifying strippable whitespace nodes</A></LI>
<LI><A href="#which">Determining which nodes to strip</A></LI>
<LI><A href="#strip">Stripping nodes</A></LI>
<LI><A href="#filter">Filtering whitespace nodes</A></LI>
</UL>
<A name="functionality"><!--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>Functionality</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>The <CODE><FONT face="courier,
monospaced"><xsl:strip-space></FONT></CODE> and <CODE><FONT
face="courier, monospaced"><xsl:preserve-space></FONT></CODE>
elements are used to control the way whitespace nodes in the source XML
document are handled. These elements have no impact on whitespace in the
XSLT
stylesheet. Both elements can occur only as top-level elements, possible
more
than once, and the elements are always empty</P>
<P>Both elements take one attribute "elements" which contains a
whitespace separated list of named nodes which should be or preserved
stripped from the source document. These names can be on one of these three
formats (NameTest format):</P>
<UL>
<LI>
All whitespace nodes:
<CODE><FONT face="courier,
monospaced">elements="*"</FONT></CODE>
</LI>
<LI>
All whitespace nodes with a namespace:
<CODE><FONT face="courier,
monospaced">elements="<namespace>:*"</FONT></CODE>
</LI>
<LI>
Specific whitespace nodes: <CODE><FONT face="courier,
monospaced">elements="<qname>"</FONT></CODE>
</LI>
</UL>
</FONT></TD></TR></TABLE><BR><A name="identify"><!--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>Identifying strippable whitespace
nodes</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>The DOM detects all text nodes and assigns them the type <CODE><FONT
face="courier, monospaced">TEXT</FONT></CODE>.
All text nodes are scanned to detect whitespace-only nodes. A text-node is
considered a whitespace node only if it consist entirely of characters from
the set { 0x09, 0x0a, 0x0d, 0x20 }. The DOM implementation class has a
static
method used to detect such nodes:</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>
private static final boolean isWhitespaceChar(char c) {
return c == 0x20 || c == 0x0A || c == 0x0D || c == 0x09;
}
</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>
<P>The characters are checked in probable order.</P>
<P> The DOM has a bit-array that is used to tag text-nodes as strippable
whitespace nodes:</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>private int[]
_whitespace;</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>
<P>There are two methods in the DOM implementation class for accessing this
bit-array: <CODE><FONT face="courier,
monospaced">markWhitespace(node)</FONT></CODE> and <CODE><FONT face="courier,
monospaced">isWhitespace(node)</FONT></CODE>.
The array is resized together with all other arrays in the DOM by the
<CODE><FONT face="courier, monospaced">DOM.resizeArrays()</FONT></CODE>
method. The bits in the array are set in the
<CODE><FONT face="courier,
monospaced">DOM.maybeCreateTextNode()</FONT></CODE> method. This method must
know whether
the current node is a located under an element with an
<CODE><FONT face="courier,
monospaced">xml:space="<value>"</FONT></CODE> attribute in the
DOM, in which
case it is not a strippable whitespace node.</P>
<P>An auxillary class, WhitespaceHandler, is used for this purpose. The
class
works in a way as a stack, where you "push" a new strip/preserve
setting
together with the node in which this setting was determined. This means that
for every time the DOM builder encounters an <CODE><FONT face="courier,
monospaced">xml:space</FONT></CODE> attribute
it will invoke a method on an instance of the WhitespaceHandler class to
signal that a new preserve/strip setting has been encountered. This is done
in the <CODE><FONT face="courier,
monospaced">makeAttributeNode()</FONT></CODE> method. The whitespace handler
stores the
new setting and pushes the current element node on its stack. When the
DOM builder closes up an element (in <CODE><FONT face="courier,
monospaced">endElement()</FONT></CODE>), it invokes
another method of the whitespace handler to check if the strip/preserve
setting is still valid. If the setting is now invalid (we're closing the
element whose node id is on the top of the stack) the handler inverts the
setting and pops the element node id off the stack. The previous
strip/preserve setting is then valid, and the id of node where this setting
was defined is on the top of the stack.</P>
</FONT></TD></TR></TABLE><BR><A name="which"><!--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>Determining which nodes to strip</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>A text node is never stripped unless it contains only whitespace
characters (Unicode characters 0x09, 0x0A, 0x0D and 0x20). Stripping a text
node means that the node disappears from the DOM; so that it is never
included in the output and that it is ignored by all functions such as
<CODE><FONT face="courier, monospaced">count()</FONT></CODE>. A text node
is preserved if any of the following apply:</P>
<UL>
<LI>
the element name of the parent of the text node is in the set of
elements listed in <CODE><FONT face="courier,
monospaced"><xsl:preserve-space></FONT></CODE>
</LI>
<LI>
the text node contains at least one non-whitespace character
</LI>
<LI>
an ancenstor of the whitespace text node has an attribute of
<CODE><FONT face="courier,
monospaced">xsl:space="preserve"</FONT></CODE>, and no close ancestor
has and
attribute of <CODE><FONT face="courier,
monospaced">xsl:space="default"</FONT></CODE>.
</LI>
</UL>
<P>Otherwise, the text node is stripped. Initially the set of
whitespace-preserving element names contains all element names, so the
default behaviour is to preserve all whitespace text nodes.</P>
<P>This seems simple enough, but resolving conflicts between matching
<CODE><FONT face="courier,
monospaced"><xsl:strip-space></FONT></CODE> and <CODE><FONT
face="courier, monospaced"><xsl:preserve-space></FONT></CODE>
elements requires a lot of thought. Our first consideration is import
precedence; the match with the highest import precedence is always chosen.
Import precedence is determined by the order in which the compared elements
are visited. (In this case those elements are the top-level
<CODE><FONT face="courier,
monospaced"><xsl:strip-space></FONT></CODE> and <CODE><FONT
face="courier, monospaced"><xsl:preserve-space></FONT></CODE>
elements.) This example is taken from the XSLT recommendation:</P>
<UL>
<LI>stylesheet A imports stylesheets B and C in that order;</LI>
<LI>stylesheet B imports stylesheet D;</LI>
<LI>stylesheet C imports stylesheet E.</LI>
</UL>
<P>Then the order of import precedence (lowest first) is D, B, E, C, A.</P>
<P>Our next consideration is the priority of NameTests (XPath spec):</P>
<UL>
<LI>
<CODE><FONT face="courier,
monospaced">elements="<qname>"</FONT></CODE> has priority 0
</LI>
<LI>
<CODE><FONT face="courier,
monospaced">elements="<namespace>:*"</FONT></CODE> has priority
-0.25
</LI>
<LI>
<CODE><FONT face="courier,
monospaced">elements="*"</FONT></CODE> has priority -0.5
</LI>
</UL>
<P>It is considered an error if the desicion is still ambiguous after this,
and it is up to the implementors to decide what the apropriate action
is.</P>
<P>With all this complexity, the normal usage for these elements is quite
smiple; either preserve all whitespace nodes but one type:</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><xsl:strip-space
elements="foo"/></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>
<P>or strip all whitespace nodes but one type:</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>
<xsl:strip-space elements="*"/>
<xsl:preserve-space elements="foo"/></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="strip"><!--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>Stripping nodes</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>The ultimate goal of our design would be to totally screen all stripped
nodes from the translet; to either physically remove them from the DOM or to
make it appear as if they are not there. The first approach will cause
problems in cases where multiple translets access the same DOM. In the
future
we wish to let translets run within servlets / JSPs with a common DOM cache.
This DOM cache will keep copies of DOMs in memory to prevent the same XML
file from being downloaded and parsed several times. This is a scenarios we
might see:</P>
<P><IMG align="right" border="0" hspace="4" src="images/DOMInterface.gif"
vspace="4"><BR clear="all"></P>
<P><I>Figure 1: Multiple translets accessing a common pool of DOMs</I></P>
<P>The three translets running on this host access a common pool of 4 DOMs.
The DOMs are accessed through a common DOM interface. Translets accessing
a single DOM will have a DOMAdapter and a single DOMImpl object behind this
interface, while translets accessing several DOMs will be given a MultiDOM
and a set of DOMImpl objects.</P>
<P>The translet to the left may want to strip some nodes from the shared DOM
in the cache, while the other translets may want to preserve all whitespace
nodes. Our initial thought then is to keep the DOM as it is and somehow
screen the left-hand translet of all the whitespace nodes it does not want
to
process. There are a few ways in which we can accomplish this:</P>
<UL>
<LI>
The translet can, prior to starting to traverse the DOM, send a
reference
to the tables containing information on which nodes we want stripped to
the DOM interface. The DOM interface is then responsible for hiding all
stripped whitespace nodes from the iterators and the translet. A problem
with this approach is that we want to omit the DOM interface layer if
the translet is only accessing a single DOM. The DOM interface layer
will
only be instanciated by the translet if the stylesheet contained a call
to the <CODE><FONT face="courier, monospaced">document()</FONT></CODE>
function.<BR><BR>
</LI>
<LI>
The translet can provide its iterators with information on which nodes
it
does not want to see. The translet is still shielded from unwanted
whitespace nodes, but it has the hassle of passing extra information
over
to most iterators it ever instanciates. Note that all iterators do not
need be aware of whitepspace nodes in this case. If you have a look at
the figure again you will see that only the first level iterator (that
is
the one closest to the DOM or DOM interface) will have to strip off
whitespace nodes. But, there may be several iterators that operate
directly on the DOM ( invoked by code handling XSL functions such as
<CODE><FONT face="courier, monospaced">count()</FONT></CODE>) and every
single one of those will need to be told
which whitespace nodes the translet does not want to see.<BR><BR>
</LI>
<LI>
The third approach will take advantage of the fact that not all
translets will want to strip whitespace nodes. The most effective way of
removing unwanted whitespace nodes is to do it once and for all, before
the actual traversal of the DOM starts. This can be done by making a
clone of the DOM with exlusive-access rights for this translet only. We
still gain performance from the cache because we do not have to pay the
cost of the delay caused by downloading and parsing the XML source file.
The cost we have to pay is the time needed for the actual cloning and
the
extra memory we use.<BR><BR>
Normally one would imagine the translet (or the wrapper class that
invokes the translet) calls the DOM cache with just an URL and receives
a reference to an instanciated DOM. The cache will either have built
this DOM on-demand or just passed back a reference to an existing tree.
In this case the DOM would need an extra call that a translet would use
to clone a DOM, passing the existing DOM reference to the cache and
recieving a new reference to the cloned DOM. The translet can then do
whatever it wants with this DOM (the cache need not even keep a
reference
to this tree).
</LI>
</UL>
<P>We are lucky enough to be able to combine the first two approaches. All
iterators that directly access the DOM (axis iterators) are instanciated by
calls to the DOM interface layer (the DOM class). The actual iterators are
created in the DOM implementation layer (the DOMImpl class). So, we can pass
references to the preserve/strip whitespace tables to the DOM, and the DOM
will make sure that all axis iterators return node sets with respect to
these
tables.</P>
</FONT></TD></TR></TABLE><BR><A name="filter"><!--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>Filtering whitespace nodes</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>For each axis iterator and for <CODE><FONT face="courier,
monospaced">DOM.makeStringValue()</FONT></CODE> and
<CODE><FONT face="courier, monospaced">DOM.stringValueAux()</FONT></CODE>
we must apply a filter for eliminating all
unwanted whitespace nodes. To achive this we must build a very efficient
predicate for determining if the current node should be stripped or not.
This
predicate is built by <CODE><FONT face="courier,
monospaced">Whitespace.compilePredicate()</FONT></CODE>. This method is
static and builds a predicate for a vector of WhitespaceRule objects. (The
WhitespaceRule class is defined within the Whitespace class.) Each
WhitespaceRule object contains information for a single element listed
in an <CODE><FONT face="courier,
monospaced"><xsl:strip/preserve-space></FONT></CODE> element, and is
broken down
into the following information:</P>
<UL>
<LI>the namespace (can be the default namespace)</LI>
<LI>the element name or "<CODE><FONT face="courier,
monospaced">*</FONT></CODE>"</LI>
<LI>the type of rule; NS:EL, NS:<CODE><FONT face="courier,
monospaced">*</FONT></CODE> or <CODE><FONT face="courier,
monospaced">*</FONT></CODE></LI>
<LI>the priority of the rule (based on import precedence and type)</LI>
<LI>the action; either strip or preserver</LI>
</UL>
<P>The Vector of WhitespaceRules is arranged in order of priority and
redundant rules are removed. A predicate method is then compiled into the
translet as:</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>
public boolean stripSpace(int node);
</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>
<P>Unfortunately this method cannot be declared static.</P>
<P>When the Stylesheet objectcompiles the <CODE><FONT face="courier,
monospaced">topLevel()</FONT></CODE> method of the
translet it checks for the existance of the <CODE><FONT face="courier,
monospaced">stripSpace()</FONT></CODE> method. If
this method exists the <CODE><FONT face="courier,
monospaced">topLevel()</FONT></CODE> will be compiled to pass the
translet to the DOM as a StripWhitespaceFilter (the translet implements this
interface when the <CODE><FONT face="courier,
monospaced">stripSpace()</FONT></CODE> method is compiled).</P>
<P>All axis iterators and the <CODE><FONT face="courier,
monospaced">DOM.makeStringValue()</FONT></CODE> and
<CODE><FONT face="courier, monospaced">DOM.stringValueAux()</FONT></CODE>
methods check for the existance of this filter
(it is kept in a global variable in the DOM implementation class) and takes
the appropriate actions. The methods in the DOM for returning axis iterators
will place a StrippingIterator on top of the axis iterator if the filter is
present, and the two methods just mentioned will return empty strings for
whitespace nodes that should be stripped.</P>
</FONT></TD></TR></TABLE><BR>
</TD></TR></TABLE></TD></TR></TABLE><BR><TABLE border="0" cellpadding="0"
cellspacing="0" width="620"><TR><TD bgcolor="#0086b2"><IMG height="1"
src="images/dot.gif" width="1"></TD></TR><TR><TD align="center"><FONT
color="#0086b2" size="-1"><I>
Copyright © 2001 The Apache Software Foundation.
All Rights Reserved.
</I></FONT></TD></TR></TABLE></BODY></HTML>
1.1 xml-site/targets/xalan-j/xsltc/xsltc_compiler.html
Index: xsltc_compiler.html
===================================================================
<HTML><HEAD><SCRIPT language="JavaScript" src="resources/script.js"
type="text/javascript"></SCRIPT><TITLE>XSLTC Compiler
Design</TITLE></HEAD><BODY alink="#ff0000" bgcolor="#ffffff" leftmargin="4"
link="#0000ff" marginheight="4" marginwidth="4" text="#000000" topmargin="4"
vlink="#0000aa"><TABLE border="0" cellpadding="0" cellspacing="0"
width="620"><TR><TD align="left" height="60" rowspan="3" valign="top"
width="135"><IMG border="0" height="60" hspace="0" src="resources/logo.gif"
vspace="0" width="135"></TD><TD align="left" colspan="4" height="5"
valign="top" width="456"><IMG border="0" height="5" hspace="0"
src="resources/line.gif" vspace="0" width="456"></TD><TD align="left"
height="60" rowspan="3" valign="top" width="29"><IMG border="0" height="60"
hspace="0" src="resources/right.gif" vspace="0" width="29"></TD></TR><TR><TD
align="left" bgcolor="#0086b2" colspan="4" height="35" valign="top"
width="456"><IMG alt="" border="0" height="35" hspace="0"
src="graphics/xsltc_compiler-header.jpg" vspace="0"
width="456"></TD></TR><TR><TD align="left" height="20" valign="top"
width="168"><IMG border="0" height="20" hspace="0" src="resources/bottom.gif"
vspace="0" width="168"></TD><TD align="left" height="20" valign="top"
width="96"><A href="http://xml.apache.org/" onMouseOut="rolloverOff('xml');"
onMouseOver="rolloverOn('xml');" target="new"><IMG alt="http://xml.apache.org/"
border="0" height="20" hspace="0" name="xml"
onLoad="rolloverLoad('xml','resources/button-xml-hi.gif','resources/button-xml-lo.gif');"
src="resources/button-xml-lo.gif" vspace="0" width="96"></A></TD><TD
align="left" height="20" valign="top" width="96"><A
href="http://www.apache.org/" onMouseOut="rolloverOff('asf');"
onMouseOver="rolloverOn('asf');" target="new"><IMG alt="http://www.apache.org/"
border="0" height="20" hspace="0" name="asf"
onLoad="rolloverLoad('asf','resources/button-asf-hi.gif','resources/button-asf-lo.gif');"
src="resources/button-asf-lo.gif" vspace="0" width="96"></A></TD><TD
align="left" height="20" valign="top" width="96"><A href="http://www.w3.org/"
onMouseOut="rolloverOff('w3c');" onMouseOver="rolloverOn('w3c');"
target="new"><IMG alt="http://www.w3.org/" border="0" height="20" hspace="0"
name="w3c"
onLoad="rolloverLoad('w3c','resources/button-w3c-hi.gif','resources/button-w3c-lo.gif');"
src="resources/button-w3c-lo.gif" vspace="0"
width="96"></A></TD></TR></TABLE><TABLE border="0" cellpadding="0"
cellspacing="0" width="620"><TR><TD align="left" valign="top" width="120"><IMG
border="0" height="14" hspace="0" src="resources/join.gif" vspace="0"
width="120"><BR>
<A href="index.html" onMouseOut="rolloverOff('side-index');"
onMouseOver="rolloverOn('side-index');"><IMG alt="Overview" border="0"
height="12" hspace="0" name="side-index"
onLoad="rolloverLoad('side-index','graphics/index-label-2.jpg','graphics/index-label-3.jpg');"
src="graphics/index-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<IMG alt="Compiler design" border="0" height="12" hspace="0"
src="graphics/xsltc_compiler-label-1.jpg" vspace="0" width="120"><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsl_whitespace_design.html"
onMouseOut="rolloverOff('side-xsl_whitespace_design');"
onMouseOver="rolloverOn('side-xsl_whitespace_design');"><IMG alt="Whitespace"
border="0" height="12" hspace="0" name="side-xsl_whitespace_design"
onLoad="rolloverLoad('side-xsl_whitespace_design','graphics/xsl_whitespace_design-label-2.jpg','graphics/xsl_whitespace_design-label-3.jpg');"
src="graphics/xsl_whitespace_design-label-3.jpg" vspace="0"
width="120"></A><BR>
<A href="xsl_sort_design.html"
onMouseOut="rolloverOff('side-xsl_sort_design');"
onMouseOver="rolloverOn('side-xsl_sort_design');"><IMG alt="xsl:sort"
border="0" height="12" hspace="0" name="side-xsl_sort_design"
onLoad="rolloverLoad('side-xsl_sort_design','graphics/xsl_sort_design-label-2.jpg','graphics/xsl_sort_design-label-3.jpg');"
src="graphics/xsl_sort_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_key_design.html"
onMouseOut="rolloverOff('side-xsl_key_design');"
onMouseOver="rolloverOn('side-xsl_key_design');"><IMG alt="Keys" border="0"
height="12" hspace="0" name="side-xsl_key_design"
onLoad="rolloverLoad('side-xsl_key_design','graphics/xsl_key_design-label-2.jpg','graphics/xsl_key_design-label-3.jpg');"
src="graphics/xsl_key_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_comment_design.html"
onMouseOut="rolloverOff('side-xsl_comment_design');"
onMouseOver="rolloverOn('side-xsl_comment_design');"><IMG alt="Comment design"
border="0" height="12" hspace="0" name="side-xsl_comment_design"
onLoad="rolloverLoad('side-xsl_comment_design','graphics/xsl_comment_design-label-2.jpg','graphics/xsl_comment_design-label-3.jpg');"
src="graphics/xsl_comment_design-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsl_lang_design.html"
onMouseOut="rolloverOff('side-xsl_lang_design');"
onMouseOver="rolloverOn('side-xsl_lang_design');"><IMG alt="lang()" border="0"
height="12" hspace="0" name="side-xsl_lang_design"
onLoad="rolloverLoad('side-xsl_lang_design','graphics/xsl_lang_design-label-2.jpg','graphics/xsl_lang_design-label-3.jpg');"
src="graphics/xsl_lang_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_unparsed_design.html"
onMouseOut="rolloverOff('side-xsl_unparsed_design');"
onMouseOver="rolloverOn('side-xsl_unparsed_design');"><IMG alt="Unparsed
entities" border="0" height="12" hspace="0" name="side-xsl_unparsed_design"
onLoad="rolloverLoad('side-xsl_unparsed_design','graphics/xsl_unparsed_design-label-2.jpg','graphics/xsl_unparsed_design-label-3.jpg');"
src="graphics/xsl_unparsed_design-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_runtime.html"
onMouseOut="rolloverOff('side-xsltc_runtime');"
onMouseOver="rolloverOn('side-xsltc_runtime');"><IMG alt="Runtime" border="0"
height="12" hspace="0" name="side-xsltc_runtime"
onLoad="rolloverLoad('side-xsltc_runtime','graphics/xsltc_runtime-label-2.jpg','graphics/xsltc_runtime-label-3.jpg');"
src="graphics/xsltc_runtime-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_dom.html" onMouseOut="rolloverOff('side-xsltc_dom');"
onMouseOver="rolloverOn('side-xsltc_dom');"><IMG alt="Internal DOM" border="0"
height="12" hspace="0" name="side-xsltc_dom"
onLoad="rolloverLoad('side-xsltc_dom','graphics/xsltc_dom-label-2.jpg','graphics/xsltc_dom-label-3.jpg');"
src="graphics/xsltc_dom-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsltc_namespace.html"
onMouseOut="rolloverOff('side-xsltc_namespace');"
onMouseOver="rolloverOn('side-xsltc_namespace');"><IMG alt="Namespaces"
border="0" height="12" hspace="0" name="side-xsltc_namespace"
onLoad="rolloverLoad('side-xsltc_namespace','graphics/xsltc_namespace-label-2.jpg','graphics/xsltc_namespace-label-3.jpg');"
src="graphics/xsltc_namespace-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_trax.html" onMouseOut="rolloverOff('side-xsltc_trax');"
onMouseOver="rolloverOn('side-xsltc_trax');"><IMG alt="Translet & TrAX"
border="0" height="12" hspace="0" name="side-xsltc_trax"
onLoad="rolloverLoad('side-xsltc_trax','graphics/xsltc_trax-label-2.jpg','graphics/xsltc_trax-label-3.jpg');"
src="graphics/xsltc_trax-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="todo.html" onMouseOut="rolloverOff('side-ext-40');"
onMouseOver="rolloverOn('side-ext-40');"><IMG alt="To-do list" border="0"
height="12" hspace="0" name="side-ext-40"
onLoad="rolloverLoad('side-ext-40','graphics/ext-40-label-2.jpg','graphics/ext-40-label-3.jpg');"
src="graphics/ext-40-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="14" hspace="0" src="resources/close.gif" vspace="0"
width="120"><BR></TD><TD align="left" valign="top" width="500"><TABLE
border="0" cellpadding="3" cellspacing="0"><TR><TD>
<UL>
<LI><A href="#overview">Compiler Overview</A></LI>
<LI><A href="#ast">Building an Abstract Syntax Tree</A></LI>
<LI><A href="#typecheck">Type-check and Cast Expressions</A></LI>
<LI><A href="#compile">Code generation</A></LI>
</UL>
<A name="overview"><!--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>Compiler overview</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>The input stylesheet is parsed using the SAX 1-based parser from Sun's
Project X:</P>
<UL>
<LI><CODE><FONT face="courier,
monospaced">com.sun.xml.parser.Parser</FONT></CODE></LI>
</UL>
<P>This parser builds a DOM from the stylesheet document, and hands this
DOM over to the compiler. The compiler uses its own specialised parser to
parse XPath expressions and patterns:</P>
<UL>
<LI><CODE><FONT face="courier,
monospaced">com.sun.xslt.compiler.XPathParser</FONT></CODE></LI>
</UL>
<P>Both parsers are encapsulated in XSLTC's parser class:</P>
<UL>
<LI><CODE><FONT face="courier,
monospaced">com.sun.xslt.compiler.Parser</FONT></CODE></LI>
</UL>
</FONT></TD></TR></TABLE><BR><A name="ast"><!--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>Building an Abstract Syntax Tree</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<UL>
<LI><A href="#mapping">Mapping stylesheet elements to Java
classes</A></LI>
<LI><A href="#domxsl">Building a DOM tree from the input XSL
file</A></LI>
</UL>
<P>The SAX parser builds a standard W3C DOM from the source stylesheet.
This DOM does not contain all the information needed to represent the
whole stylesheet. ( Remember that XSL is two languages; XML and XPath.
The DOM only covers XML. ) The compiler uses the DOM to build an
abstract syntax tree (AST) that contains all the nodes from the DOM, plus
additional nodes for the XPath expressions.</P>
<A name="mapping"><!--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>Mapping stylesheets elements to Java classes</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>Each XSL element is represented by a class in the
<CODE><FONT face="courier,
monospaced">com.sun.xslt.compiler</FONT></CODE> package. The Parser class
contains a
Hashtable that that maps XSL instructions to classes that inherit from a
common parent class 'Instruction' (which again inherits from
'SyntaxTreeNode'). This mapping is set up in the <CODE><FONT
face="courier, monospaced">initClasses()</FONT></CODE> method:</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> private void initStdClasses() {
try {
initStdClass("template", "Template");
initStdClass("param", "Param");
initStdClass("with-param", "WithParam");
initStdClass("variable", "Variable");
initStdClass("output", "Output");
:
:
:
}
}
private void initClass(String elementName, String className)
throws ClassNotFoundException {
_classes.put(elementName,
Class.forName(COMPILER_PACKAGE + '.' + className));
}</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="domxsl"><!--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>Building a DOM tree from the input XSL file</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>The parser instanciates a DOM that holds the input XSL stylesheet. The
DOM can only handle XML files and will not break up and identify XPath
patterns/expressions (these are stored as attributes to the various
nodes in the tree) or calls to XSL functions(). Each XSL instruction gets
its own node in the DOM, and the XPath patterns/expressions are stored as
attributes of these nodes. A stylesheet looking like this:</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>
<xsl:stylesheet .......>
<xsl:template match="chapter">
<xsl:text>Chapter</xsl:text>
<xslvalue-of select=".">
</xsl:template>
</xsl>stylesheet>
</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>
<P>will be stored in the DOM as indicated in the following picture:</P>
<P><IMG align="right" border="0" hspace="4" src="images/compiler_DOM.gif"
vspace="4"><BR clear="all"></P>
<P><I>Figure 1: DOM containing XSL stylesheet</I></P>
<P>The pattern '<CODE><FONT face="courier,
monospaced">match="chapter"</FONT></CODE>' and the expression
'<CODE><FONT face="courier,
monospaced">select="."</FONT></CODE>' are stored as attributes for
the nodes
'<CODE><FONT face="courier, monospaced">xsl:template</FONT></CODE>' and
'<CODE><FONT face="courier, monospaced">xsl:value-of</FONT></CODE>'
respectively.
These attributes are accessible through the DOM interface.</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>Creating the Abstract Syntax Tree from the DOM</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>What we have to do next is to create a tree that also holds the XSL
specific elements; XPath expressions and patterns (with possible filters)
and calls to XSL functions. This is done by parsing the DOM and creating
an
instance of a subclass of 'SyntaxTreeNode' for each node in the DOM. A
node
in the DOM containing an XSL instruction (for example,
"xsl:template") results in an
instance of the correspoding class derived from the HashTable created by
the parser (in this case in instance of the 'Template' class).</P>
<P>Each class that inherits SyntaxTreeNode has a vector called
'<CODE><FONT face="courier, monospaced">_contents</FONT></CODE>' that
holds references to all the children of the node
(if any). Each node has a method called '<CODE><FONT face="courier,
monospaced">parseContents()</FONT></CODE>'. It is
the responsibility of this method to parse any XPath expressions/patterns
that are expected and found in the node's attributes. The XPath patterns
and instructions are tokenised using the auto-generated class
'XPathParser'
(generated using JavaCup and JLex). The tokenised expressions/patterns
will result in a small sub-tree owned by the syntax tree node.</P>
<P>XSL nodes holding expressions has a pointer called '<CODE><FONT
face="courier, monospaced">_select</FONT></CODE>' that
points to a sub-tree representing the expression. This can be seen for
instance in the 'Template' class:</P>
<P><IMG align="right" border="0" hspace="4" src="images/compiler_AST.gif"
vspace="4"><BR clear="all"></P>
<P><I>Fiugre 2: Sample Abstract Syntax Tree</I></P>
<P>In this example _select only points to a single node. In more complex
expressions the pointer will point to an whole sub-tree.</P>
</FONT></TD></TR></TABLE><BR>
</FONT></TD></TR></TABLE><BR><A name="typecheck"><!--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>Type-check and Cast Expressions</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>In many cases we will need to typecast the top node in the expression
sub-tree to suit the expected result-type of the expression, or to
typecast
child nodes to suit the allowed types for the various operators in the
expression. This is done by calling 'typeCheck()' on the root-node in the
XSL tree. Each SyntaxTree node is responsible for its own type checking
(ie. the <CODE><FONT face="courier, monospaced">typeCheck()</FONT></CODE>
method must be overridden). Let us say that
our pattern was:</P>
<P><CODE><FONT face="courier, monospaced"><xsl:value-of
select="1+2.73"/></FONT></CODE></P>
<P><IMG align="right" border="0" hspace="4" src="images/typecast.gif"
vspace="4"><BR clear="all"></P>
<P><I>Figure 3: XPath expression type conflict</I></P>
<P>The number 1 is an integer, and the number 2.73 is a real number, so
the
1 has to be promoted to a real. This is done ny inserting a new node
between
the [1] and the [+]. This node will convert the 1 to a real number:</P>
<P><IMG align="right" border="0" hspace="4"
src="images/cast_expression.gif" vspace="4"><BR clear="all"></P>
<P><I>Figure 4: Type casting</I></P>
<P>The inserted node is an object of the class CastExpr. The SymbolTable
that was instanciated in (1) is used to determine what casts are needed
for
the various operators and what return types the various expressions will
have.</P>
</FONT></TD></TR></TABLE><BR><A name="compile"><!--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>Code generation</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<UL>
<LI><A href="#toplevelelem">Compiling top-level elements</A></LI>
<LI><A href="#templatecode">Compiling template code</A></LI>
<LI><A href="#instrfunc">Compiling XSL instructions and
functions</A></LI>
</UL>
<P>A general rule is that all classes that represent elements in the XSL
tree/document, i.e., classes that inherit from SyntaxTreeNode, output
bytecode in the 'translate()' method.</P>
<A name="toplevelelem"><!--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>Compiling top-level elements</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>The bytecode that handles top-level elements must be generated before
any
other code. The '<CODE><FONT face="courier,
monospaced">translate()</FONT></CODE>' method in these classes are mainly
called from these methods in the Stylesheet class:</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> private String
compileBuildKeys(ClassGenerator classGen);
private String compileTopLevel(ClassGenerator classGen, Enumeration
elements);
private void compileConstructor(ClassGenerator classGen, Output
output);</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>
<P>These methods handle most top-level elements, such as global variables
and parameters, <CODE><FONT face="courier,
monospaced"><xsl:output></FONT></CODE> and
<CODE><FONT face="courier,
monospaced"><xsl:decimal-format></FONT></CODE> instructions.</P>
</FONT></TD></TR></TABLE><BR><A name="templatecode"><!--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>Compiling template code</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>All XPath patterns in <CODE><FONT face="courier,
monospaced"><xsl:apply-template></FONT></CODE> instructions
are converted into numeric values (known as the pattern's kernel 'type').
All templates with identical pattern kernel types are grouped together and
inserted into a table with its assigned type. (This table is found in the
Mode class. There will be one such table for each mode that is used in the
stylesheet). This table is used to build a big <CODE><FONT face="courier,
monospaced">switch()</FONT></CODE> statement
in the translet's <CODE><FONT face="courier,
monospaced">applyTemplates()</FONT></CODE> method. This method is initially
called with the root node of the input document.</P>
<P>The <CODE><FONT face="courier,
monospaced">applyTemplates()</FONT></CODE> method determines the node's type
and passes
this type to the <CODE><FONT face="courier,
monospaced">switch()</FONT></CODE> statement to look up the matching
template.</P>
<P>There may be several templates that share the same pattern kernel type.
Here are a few examples of templates with patterns that all have the same
kernel type:</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> <xsl:template match="A/C">
<xsl:template match="A/B/C">
<xsl:template match="A | C"></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>
<P>All these templates will be grouped under the type for <CODE><FONT
face="courier, monospaced"><C></FONT></CODE>
and will all get the same kernel type (the type for <CODE><FONT
face="courier, monospaced">"C"</FONT></CODE>). The last
template will be grouped both under <CODE><FONT face="courier,
monospaced">"C"</FONT></CODE> and <CODE><FONT face="courier,
monospaced">"A"</FONT></CODE>. If the
type identifier for <CODE><FONT face="courier,
monospaced">"C"</FONT></CODE> in this case is 8, all these templates
will
be put under <CODE><FONT face="courier, monospaced">case 8:</FONT></CODE>
in <CODE><FONT face="courier, monospaced">applyTemplates()</FONT></CODE>'s big
<CODE><FONT face="courier, monospaced">switch()</FONT></CODE> statement.
The Mode class will insert extra code to choose
which template code to invoke.</P>
</FONT></TD></TR></TABLE><BR><A name="instrfunc"><!--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>Compiling XSL instructions and functions</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>The template code is generated by calling <CODE><FONT face="courier,
monospaced">translate()</FONT></CODE> on each
Template object in the abstract syntax tree. This call will be propagated
down the tree and every element will output the bytecodes necessary to
complete its task.</P>
<P>Each node will call 'translate()' on its children, and possibly on
objects representing the node's XPath expressions, before outputting its
own bytecode. In that way the correct sequence of instructions is
generated.
Each one of the child nodes is responsible of creating code that leaves
the
node's output value (if any) on the stack. The typical procedure for the
parent node is to create code that consumes these values off the stack and
then leave its own output on the stack for its parent.</P>
<P>The tree-structure of the stylesheet is in this way closely tied with
the stack-based JVM. The design does not offer any obvious way of
extending
the compiler to output code for other VMs or processors.</P>
</FONT></TD></TR></TABLE><BR>
</FONT></TD></TR></TABLE><BR>
</TD></TR></TABLE></TD></TR></TABLE><BR><TABLE border="0" cellpadding="0"
cellspacing="0" width="620"><TR><TD bgcolor="#0086b2"><IMG height="1"
src="images/dot.gif" width="1"></TD></TR><TR><TD align="center"><FONT
color="#0086b2" size="-1"><I>
Copyright © 2001 The Apache Software Foundation.
All Rights Reserved.
</I></FONT></TD></TR></TABLE></BODY></HTML>
1.1 xml-site/targets/xalan-j/xsltc/xsltc_dom.html
Index: xsltc_dom.html
===================================================================
<HTML><HEAD><SCRIPT language="JavaScript" src="resources/script.js"
type="text/javascript"></SCRIPT><TITLE>XSLTC Internal DOM</TITLE></HEAD><BODY
alink="#ff0000" bgcolor="#ffffff" leftmargin="4" link="#0000ff"
marginheight="4" marginwidth="4" text="#000000" topmargin="4"
vlink="#0000aa"><TABLE border="0" cellpadding="0" cellspacing="0"
width="620"><TR><TD align="left" height="60" rowspan="3" valign="top"
width="135"><IMG border="0" height="60" hspace="0" src="resources/logo.gif"
vspace="0" width="135"></TD><TD align="left" colspan="4" height="5"
valign="top" width="456"><IMG border="0" height="5" hspace="0"
src="resources/line.gif" vspace="0" width="456"></TD><TD align="left"
height="60" rowspan="3" valign="top" width="29"><IMG border="0" height="60"
hspace="0" src="resources/right.gif" vspace="0" width="29"></TD></TR><TR><TD
align="left" bgcolor="#0086b2" colspan="4" height="35" valign="top"
width="456"><IMG alt="" border="0" height="35" hspace="0"
src="graphics/xsltc_dom-header.jpg" vspace="0" width="456"></TD></TR><TR><TD
align="left" height="20" valign="top" width="168"><IMG border="0" height="20"
hspace="0" src="resources/bottom.gif" vspace="0" width="168"></TD><TD
align="left" height="20" valign="top" width="96"><A
href="http://xml.apache.org/" onMouseOut="rolloverOff('xml');"
onMouseOver="rolloverOn('xml');" target="new"><IMG alt="http://xml.apache.org/"
border="0" height="20" hspace="0" name="xml"
onLoad="rolloverLoad('xml','resources/button-xml-hi.gif','resources/button-xml-lo.gif');"
src="resources/button-xml-lo.gif" vspace="0" width="96"></A></TD><TD
align="left" height="20" valign="top" width="96"><A
href="http://www.apache.org/" onMouseOut="rolloverOff('asf');"
onMouseOver="rolloverOn('asf');" target="new"><IMG alt="http://www.apache.org/"
border="0" height="20" hspace="0" name="asf"
onLoad="rolloverLoad('asf','resources/button-asf-hi.gif','resources/button-asf-lo.gif');"
src="resources/button-asf-lo.gif" vspace="0" width="96"></A></TD><TD
align="left" height="20" valign="top" width="96"><A href="http://www.w3.org/"
onMouseOut="rolloverOff('w3c');" onMouseOver="rolloverOn('w3c');"
target="new"><IMG alt="http://www.w3.org/" border="0" height="20" hspace="0"
name="w3c"
onLoad="rolloverLoad('w3c','resources/button-w3c-hi.gif','resources/button-w3c-lo.gif');"
src="resources/button-w3c-lo.gif" vspace="0"
width="96"></A></TD></TR></TABLE><TABLE border="0" cellpadding="0"
cellspacing="0" width="620"><TR><TD align="left" valign="top" width="120"><IMG
border="0" height="14" hspace="0" src="resources/join.gif" vspace="0"
width="120"><BR>
<A href="index.html" onMouseOut="rolloverOff('side-index');"
onMouseOver="rolloverOn('side-index');"><IMG alt="Overview" border="0"
height="12" hspace="0" name="side-index"
onLoad="rolloverLoad('side-index','graphics/index-label-2.jpg','graphics/index-label-3.jpg');"
src="graphics/index-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_compiler.html"
onMouseOut="rolloverOff('side-xsltc_compiler');"
onMouseOver="rolloverOn('side-xsltc_compiler');"><IMG alt="Compiler design"
border="0" height="12" hspace="0" name="side-xsltc_compiler"
onLoad="rolloverLoad('side-xsltc_compiler','graphics/xsltc_compiler-label-2.jpg','graphics/xsltc_compiler-label-3.jpg');"
src="graphics/xsltc_compiler-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsl_whitespace_design.html"
onMouseOut="rolloverOff('side-xsl_whitespace_design');"
onMouseOver="rolloverOn('side-xsl_whitespace_design');"><IMG alt="Whitespace"
border="0" height="12" hspace="0" name="side-xsl_whitespace_design"
onLoad="rolloverLoad('side-xsl_whitespace_design','graphics/xsl_whitespace_design-label-2.jpg','graphics/xsl_whitespace_design-label-3.jpg');"
src="graphics/xsl_whitespace_design-label-3.jpg" vspace="0"
width="120"></A><BR>
<A href="xsl_sort_design.html"
onMouseOut="rolloverOff('side-xsl_sort_design');"
onMouseOver="rolloverOn('side-xsl_sort_design');"><IMG alt="xsl:sort"
border="0" height="12" hspace="0" name="side-xsl_sort_design"
onLoad="rolloverLoad('side-xsl_sort_design','graphics/xsl_sort_design-label-2.jpg','graphics/xsl_sort_design-label-3.jpg');"
src="graphics/xsl_sort_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_key_design.html"
onMouseOut="rolloverOff('side-xsl_key_design');"
onMouseOver="rolloverOn('side-xsl_key_design');"><IMG alt="Keys" border="0"
height="12" hspace="0" name="side-xsl_key_design"
onLoad="rolloverLoad('side-xsl_key_design','graphics/xsl_key_design-label-2.jpg','graphics/xsl_key_design-label-3.jpg');"
src="graphics/xsl_key_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_comment_design.html"
onMouseOut="rolloverOff('side-xsl_comment_design');"
onMouseOver="rolloverOn('side-xsl_comment_design');"><IMG alt="Comment design"
border="0" height="12" hspace="0" name="side-xsl_comment_design"
onLoad="rolloverLoad('side-xsl_comment_design','graphics/xsl_comment_design-label-2.jpg','graphics/xsl_comment_design-label-3.jpg');"
src="graphics/xsl_comment_design-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsl_lang_design.html"
onMouseOut="rolloverOff('side-xsl_lang_design');"
onMouseOver="rolloverOn('side-xsl_lang_design');"><IMG alt="lang()" border="0"
height="12" hspace="0" name="side-xsl_lang_design"
onLoad="rolloverLoad('side-xsl_lang_design','graphics/xsl_lang_design-label-2.jpg','graphics/xsl_lang_design-label-3.jpg');"
src="graphics/xsl_lang_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_unparsed_design.html"
onMouseOut="rolloverOff('side-xsl_unparsed_design');"
onMouseOver="rolloverOn('side-xsl_unparsed_design');"><IMG alt="Unparsed
entities" border="0" height="12" hspace="0" name="side-xsl_unparsed_design"
onLoad="rolloverLoad('side-xsl_unparsed_design','graphics/xsl_unparsed_design-label-2.jpg','graphics/xsl_unparsed_design-label-3.jpg');"
src="graphics/xsl_unparsed_design-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_runtime.html"
onMouseOut="rolloverOff('side-xsltc_runtime');"
onMouseOver="rolloverOn('side-xsltc_runtime');"><IMG alt="Runtime" border="0"
height="12" hspace="0" name="side-xsltc_runtime"
onLoad="rolloverLoad('side-xsltc_runtime','graphics/xsltc_runtime-label-2.jpg','graphics/xsltc_runtime-label-3.jpg');"
src="graphics/xsltc_runtime-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<IMG alt="Internal DOM" border="0" height="12" hspace="0"
src="graphics/xsltc_dom-label-1.jpg" vspace="0" width="120"><BR>
<A href="xsltc_namespace.html"
onMouseOut="rolloverOff('side-xsltc_namespace');"
onMouseOver="rolloverOn('side-xsltc_namespace');"><IMG alt="Namespaces"
border="0" height="12" hspace="0" name="side-xsltc_namespace"
onLoad="rolloverLoad('side-xsltc_namespace','graphics/xsltc_namespace-label-2.jpg','graphics/xsltc_namespace-label-3.jpg');"
src="graphics/xsltc_namespace-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_trax.html" onMouseOut="rolloverOff('side-xsltc_trax');"
onMouseOver="rolloverOn('side-xsltc_trax');"><IMG alt="Translet & TrAX"
border="0" height="12" hspace="0" name="side-xsltc_trax"
onLoad="rolloverLoad('side-xsltc_trax','graphics/xsltc_trax-label-2.jpg','graphics/xsltc_trax-label-3.jpg');"
src="graphics/xsltc_trax-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="todo.html" onMouseOut="rolloverOff('side-ext-40');"
onMouseOver="rolloverOn('side-ext-40');"><IMG alt="To-do list" border="0"
height="12" hspace="0" name="side-ext-40"
onLoad="rolloverLoad('side-ext-40','graphics/ext-40-label-2.jpg','graphics/ext-40-label-3.jpg');"
src="graphics/ext-40-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="14" hspace="0" src="resources/close.gif" vspace="0"
width="120"><BR></TD><TD align="left" valign="top" width="500"><TABLE
border="0" cellpadding="3" cellspacing="0"><TR><TD>
<UL>
<LI><A href="#functionality">General functionlaity</A></LI>
<LI><A href="#components">Components of the internal DOM</A></LI>
<LI><A href="#structure">Internal structure</A></LI>
<LI><A href="#navigation">Tree navigation</A></LI>
<LI><A href="#namespaces">Namespaces</A></LI>
<LI><A href="#w3c">W3C DOM2 navigation support</A></LI>
<LI><A href="#adapter">The DOM adapter - DOMAdapter</A></LI>
<LI><A href="#multiplexer">The DOM multiplexer - MultiDOM</A></LI>
<LI><A href="#builder">The DOM builder - DOMImpl$DOMBuilder</A></LI>
</UL>
<A name="functionality"><!--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>General functionality</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>The internal DOM gives the translet access to the XML document(s) it has
to transform. The interface to the internal DOM is specified in the DOM.java
class. This is the interface that the translet uses to access the DOM.
There is also an interface specified for DOM caches -- DOMCache.java</P>
</FONT></TD></TR></TABLE><BR><A name="components"><!--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>Components of the internal DOM</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>This DOM interface is implemented by three classes:</P>
<UL>
<LI><B>org.apache.xalan.xsltc.dom.DOMImpl</B><BR><BR>
This is the main DOM class. An instance of this class contains the nodes
of a <B>single</B> XML document.<BR>br/>
</LI>
<LI><B>org.apache.xalan.xsltc.dom.MultiDOM</B><BR><BR>
This class is best described as a DOM multiplexer. XSLTC was initially
designed to operate on a single XML document, and the initial DOM and
the DOM interface were designed and implemented without the
<CODE><FONT face="courier, monospaced">document()</FONT></CODE>
function in mind. This class will allow a translet
to access multiple DOMs through the original DOM interface.<BR><BR>
</LI>
<LI><B>org.apache.xalan.xsltc.dom.DOMAdapter</B><BR>br/>
The DOM adapter is a mediator between a DOMImpl or a MultiDOM object and
a single translet. A DOMAdapter object contains mappings and reverse
mappings between node types in the DOM(s) and node types in the
translet.
This mediator is needed to allow several translets access to a single
DOM.
<BR>br/>
</LI>
<LI><B>org.apache.xalan.xsltc.dom.DocumentCache</B><BR>br/>
A sample DOM cache (implementing DOMCache) that is used with our sample
transformation applications.
</LI>
</UL>
<P><IMG align="right" border="0" hspace="4" src="images/DOMInterface.gif"
vspace="4"><BR clear="all"></P>
<P><I>Figure 1: Main components of the internal DOM</I></P>
<P>The figure above shows how several translets can access one or more
internal DOM from a shared pool of cached DOMs. A translet can also access a
DOM tree outside of a cache. The Stylesheet class that represents the XSL
stylesheet to compile contains a flag that indicates if the translet uses
the
<CODE><FONT face="courier, monospaced">document()</FONT></CODE> function.
The code compiled into the translet will act
accordingly and instanciate a MultiDOM object if needed (this code is
compiled
in the compiler's <CODE><FONT face="courier,
monospaced">Stylesheet.compileTransform()</FONT></CODE> method).</P>
</FONT></TD></TR></TABLE><BR><A name="structure"><!--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>Internal Structure</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<UL>
<LI><A href="#node-id">Node identification</A></LI>
<LI><A href="#element-nodes">Element nodes</A></LI>
<LI><A href="#attribute-nodes">Attribute nodes</A></LI>
<LI><A href="#text-nodes">Text nodes</A></LI>
<LI><A href="#comment-nodes">Comment nodes</A></LI>
<LI><A href="#pi"></A>Processing instructions</LI>
</UL>
<A name="node-id"><!--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>Node identifation</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>Each node in the DOM is represented by an integer. This integer is an
index into a series of arrays that describes the node. Most important is
the <CODE><FONT face="courier, monospaced">_type[]</FONT></CODE> array,
which holds the (DOM internal) node type. There
are some general node types that are described in the DOM.java
interface:</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>
public final static int ROOT = 0;
public final static int TEXT = 1;
public final static int UNUSED = 2;
public final static int ELEMENT = 3;
public final static int ATTRIBUTE = 4;
public final static int PROCESSING_INSTRUCTION = 5;
public final static int COMMENT = 6;
public final static int NTYPES = 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>
<P>Element and attribute nodes will be assigned types based on their
expanded
QNames. The <CODE><FONT face="courier, monospaced">_type[]</FONT></CODE>
array is used for this:</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>
int type = _type[node]; // get node type
</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>
<P>The node type can be used to look up the element/attribute name in the
element/attribute name array <CODE><FONT face="courier,
monospaced">_namesArray[]</FONT></CODE>:</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>
String name = _namesArray[type-NTYPES]; // get node element name
</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>
<P>The resulting string contains the full, expanded QName of the element or
attribute. Retrieving the namespace URI of an element/attribute is done in a
very similar fashion:</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>
int nstype = _namespace[type-NTYPES]; // get namespace type
String namespace = _nsNamesArray[nstype]; // get node namespace name
</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="element-nodes"><!--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>Element nodes</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>The contents of an element node (child nodes) can be identified using
the <CODE><FONT face="courier, monospaced">_offsetOrChild[]</FONT></CODE>
and <CODE><FONT face="courier, monospaced">_nextSibling[]</FONT></CODE> arrays.
The
<CODE><FONT face="courier, monospaced">_offsetOrChild[]</FONT></CODE> array
will give you the first child of an element
node:</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>
int child = _offsetOrChild[node]; // first child
child = _nextSibling[child]; // next child
</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>
<P>The last child will have a "<CODE><FONT face="courier,
monospaced">_nextSibling[]</FONT></CODE>" of 0 (zero).
This value is OK since the root node (the 0 node) will not be a child of
any element.</P>
</FONT></TD></TR></TABLE><BR><A name="attribute-nodes"><!--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>Attribute nodes</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>The first attribute node of an element is found by a lookup in the
<CODE><FONT face="courier, monospaced">_lengthOrAttr[]</FONT></CODE> array
using the node index:</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>
int attribute = _offsetOrChild[node]; // first attribute
attribute = _nextSibling[attribute]; // next attribute
</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>
<P>The names of attributes are contained in the <CODE><FONT face="courier,
monospaced">_namesArray[]</FONT></CODE> just
like the names of element nodes. The value of attributes are store the same
way as text nodes:</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>
int offset = _offsetOrChild[attribute]; // offset into character
array
int length = _lengthOrAttr[attribute]; // length of attribute value
String value = new String(_text, offset, length);
</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="text-nodes"><!--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>Text nodes</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>Text nodes are stored identically to attribute values. See the previous
section on <A href="#attribute-nodes">attribute nodes</A>.</P>
</FONT></TD></TR></TABLE><BR><A name="comment-nodes"><!--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>Comment nodes</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>The internal DOM does currently <B>not</B> contain comment nodes. Yes, I
am quite aware that the DOM has a type assigned to comment nodes, but
comments
are still not inserted into the DOM.</P>
</FONT></TD></TR></TABLE><BR><A name="pi"><!--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>Processing instructions</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>Processing instructions are handled as text nodes. These nodes are stored
identically to attribute values. See the previous section on
<A href="#attribute-nodes">attribute nodes</A>.</P>
</FONT></TD></TR></TABLE><BR></FONT></TD></TR></TABLE><BR><A
name="navigation"><!--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>Tree navigation</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>The DOM implementation contains a series of iterator that implement the
XPath axis. All these iterators implement the NodeIterator interface and
extend the NodeIteratorBase base class. These iterators do the job of
navigating the tree using the <CODE><FONT face="courier,
monospaced">_offsetOrChild[]</FONT></CODE>, <CODE><FONT face="courier,
monospaced">_nextSibling</FONT></CODE>
and <CODE><FONT face="courier, monospaced">_parent[]</FONT></CODE> arrays.
All iterators that handles XPath axis are
implemented as a private inner class of DOMImpl. The translet uses a handful
of methods to instanciate these iterators:</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>
public NodeIterator getIterator();
public NodeIterator getChildren(final int node);
public NodeIterator getTypedChildren(final int type);
public NodeIterator getAxisIterator(final int axis);
public NodeIterator getTypedAxisIterator(final int axis, final int type);
public NodeIterator getNthDescendant(int node, int n);
public NodeIterator getNamespaceAxisIterator(final int axis, final int
ns);
public NodeIterator orderNodes(NodeIterator source, int node);
</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>
<P>There are a few iterators in addition to these, such as sorting/ordering
iterators and filtering iterators. These iterators are implemented in
separate classes and can be instanciated directly by the translet.</P>
</FONT></TD></TR></TABLE><BR><A name="namespaces"><!--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>Namespaces</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>Namespace support was added to the internal DOM at a late stage, and the
design and implementation of the DOM bears a few scars because of this.
There is a separate <A href="xsltc_namespace.html">design
document</A> that covers namespaces.</P>
</FONT></TD></TR></TABLE><BR><A name="w3c"><!--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>W3C DOM2 navigation support</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>The DOM has a few methods that give basic W3C-type DOM navigation. These
methods are:</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>
public Node makeNode(int index);
public Node makeNode(NodeIterator iter);
public NodeList makeNodeList(int index);
public NodeList makeNodeList(NodeIterator iter);
</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>
<P>These methods return instances of inner classes of the DOM that implement
the W3C Node and NodeList interfaces.</P>
</FONT></TD></TR></TABLE><BR><A name="adapter"><!--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 DOM adapter - DOMAdapter</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<UL>
<LI><A href="#translet-dom">Translet/DOM type mapping</A></LI>
<LI><A href="#whitespace">Whitespace text-node stripping</A></LI>
<LI><A href="#method-mapping">Method mapping</A></LI>
</UL>
<A name="translet-dom"><!--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>Translet/DOM type mapping</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>The DOMAdapter class performs the mappings between DOM and translet node
types, and vice versa. These mappings are necessary in order for the
translet
to correctly identify an element/attribute in the DOM and for the DOM to
correctly identify the element/attribute type of a typed iterator requested
by the translet. Note that the DOMAdapter also maps translet namespace types
to DOM namespace types, and vice versa.</P>
<P>The DOMAdapter class has four global tables that hold the translet/DOM
type and namespace-type mappings. If the DOM knows an element as type
19, the DOMAdapter will translate this to some other integer using the
<CODE><FONT face="courier, monospaced">_mapping[]</FONT></CODE> array:</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>
int domType = _mapping[transletType];
</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>
<P>This action will be performed when the DOM asks what type a specific node
is. The reverse is done then the translet wants an iterator for a specific
node type. The DOMAdapter must translate the translet-type to the type used
internally in the DOM by looking up the <CODE><FONT face="courier,
monospaced">_reverse[]</FONT></CODE> array:</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>
int transletType = _mapping[domType];
</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>
<P>There are two additional mapping tables: <CODE><FONT face="courier,
monospaced">_NSmapping[]</FONT></CODE> and
<CODE><FONT face="courier, monospaced">_NSreverse[]</FONT></CODE> that do
the same for namespace types.</P>
</FONT></TD></TR></TABLE><BR><A name="whitespace"><!--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>Whitespace text-node stripping</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>The DOMAdapter class has the additional function of stripping whitespace
nodes in the DOM. This functionality had to be put in the DOMAdapter, as
different translets will have different preferences for node stripping.</P>
</FONT></TD></TR></TABLE><BR><A name="method-mapping"><!--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>Method mapping</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>The DOMAdapter class implements the same <CODE><FONT face="courier,
monospaced">DOM</FONT></CODE> interface as the
DOMImpl class. A DOMAdapter object will look like a DOMImpl tree, but the
translet can access it directly without being concerned with type mapping
and whitespace stripping. The <CODE><FONT face="courier,
monospaced">getTypedChildren()</FONT></CODE> demonstrates very
well how this is done:</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>
public NodeIterator getTypedChildren(int type) {
// Get the DOM type for the requested typed iterator
final int domType = _reverse[type];
// Now get the typed child iterator from the DOMImpl object
NodeIterator iterator = _domImpl.getTypedChildren(domType);
// Wrap the iterator in a WS stripping iterator if child-nodes are
text nodes
if ((domType == DOM.TEXT) && (_filter != null))
iterator = _domImpl.strippingIterator(iterator,_mapping,_filter);
return(iterator);
}
</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></FONT></TD></TR></TABLE><BR><A
name="multiplexer"><!--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 DOM multiplexer - MultiDOM</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>The DOM multiplexer class is only used when the compiled stylesheet uses
the <CODE><FONT face="courier, monospaced">document()</FONT></CODE>
function. An instance of the MultiDOM class also
implements the DOM interface, so that it can be accessed in the same way
as a DOMAdapter object.</P>
<P>A node in the DOM is identified by an integer. The first 8 bits of this
integer are used to identify the DOM in which the node belongs, while the
lower 24 bits are used to identify the node within the DOM:</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">31-24
</FONT></TD>
<TD align="left" bgcolor="#a0ddf0" colspan="1" rowspan="1"
valign="top"><FONT color="#000000" face="arial,helvetica,sanserif"
size="-1">23-16
</FONT></TD>
<TD align="left" bgcolor="#a0ddf0" colspan="1" rowspan="1"
valign="top"><FONT color="#000000" face="arial,helvetica,sanserif"
size="-1">16-8
</FONT></TD>
<TD align="left" bgcolor="#a0ddf0" colspan="1" rowspan="1"
valign="top"><FONT color="#000000" face="arial,helvetica,sanserif"
size="-1">7-0
</FONT></TD>
</TR>
<TR>
<TD align="left" bgcolor="#a0ddf0" colspan="1" rowspan="1"
valign="top"><FONT color="#000000" face="arial,helvetica,sanserif"
size="-1">DOM id
</FONT></TD>
<TD align="left" bgcolor="#a0ddf0" colspan="3" rowspan="1"
valign="top"><FONT color="#000000" face="arial,helvetica,sanserif"
size="-1">node id
</FONT></TD>
</TR>
</TABLE>
<P>The DOM multiplexer has an array of DOMAdapter objects. The topmost 8
bits of the identifier is used to find the correct DOM from the array. Then
the lower 24 bits are used in calls to methods in the DOMAdapter object:</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>
public int getParent(int node) {
return _adapters[node>>>24].getParent(node & 0x00ffffff) |
node & 0xff000000;
}
</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>
<P>Note that the node identifier returned by this method has the same upper
8
bits as the input node. This is why we <CODE><FONT face="courier,
monospaced">OR</FONT></CODE> the result from
<CODE><FONT face="courier, monospaced">DOMAdapter.getParent()</FONT></CODE>
with the top 8 bits of the input node.</P>
</FONT></TD></TR></TABLE><BR><A name="builder"><!--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 DOM builder - DOMImpl$DOMBuilder</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<UL>
<LI><A href="#startelement">startElement()</A></LI>
<LI><A href="#endelement">endElement()</A></LI>
<LI><A href="#startprefixmapping">startPrefixMapping()</A></LI>
<LI><A href="#endprefixmapping">endPrefixMapping()</A></LI>
<LI><A href="#characters">characters()</A></LI>
<LI><A href="#startdocument">startDocument()</A></LI>
<LI><A href="#enddocument">endDocument()</A></LI>
</UL>
<P>The DOM builder is an inner class of the DOM implementation. The builder
implements the SAX2 <CODE><FONT face="courier,
monospaced">ContentHandler</FONT></CODE> interface and populates the DOM
by receiving SAX2 events from a SAX2 parser (presently xerces). An instance
of the DOM builder class can be retrieved from <CODE><FONT face="courier,
monospaced">DOMImpl.getBuilder()</FONT></CODE>
method, and this handler can be set as an XMLReader's content handler:</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>
final SAXParserFactory factory = SAXParserFactory.newInstance();
final SAXParser parser = factory.newSAXParser();
final XMLReader reader = parser.getXMLReader();
final DOMImpl dom = new DOMImpl();
reader.setContentHandler(dom.getBuilder());
</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>
<P>The DOM builder will start to populate the DOM once the XML parser starts
generating SAX2 events:</P>
<A name="startelement"><!--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>startElement()</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>This method can be called in one of two ways; either with the expanded
QName (the element's separate uri and local name are supplied) or as a
normal QName (one String on the format prefix:local-name). The DOM stores
elements as expanded QNames so it needs to know the element's namespace URI.
Since the URI is not supplied with this call, we have to keep track of
namespace prefix/uri mappings while we're building the DOM. See
<CODE><FONT face="courier, monospaced"><A
href="#startprefixmapping">startPrefixMapping()</A></FONT></CODE> below for
details on
namespace handling.</P>
<P>The <CODE><FONT face="courier, monospaced">startElement()</FONT></CODE>
inserts the element as a child of the current
parent element, creates attribute nodes for all attributes in the supplied
"<CODE><FONT face="courier, monospaced">Attributes</FONT></CODE>"
attribute list (by a series of calls to
<CODE><FONT face="courier, monospaced">makeAttributeNode()</FONT></CODE>),
and finally creates the actual element node
(by calling <CODE><FONT face="courier,
monospaced">internElement()</FONT></CODE>, which inserts a new entry in the
<CODE><FONT face="courier, monospaced">_type[]</FONT></CODE> array).</P>
</FONT></TD></TR></TABLE><BR><A name="endelement"><!--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>endElement()</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>This method does some cleanup after the <CODE><FONT face="courier,
monospaced">startElement()</FONT></CODE> method,
such as revering <CODE><FONT face="courier,
monospaced">xml:space</FONT></CODE> settings and linking the element's
child nodes.</P>
</FONT></TD></TR></TABLE><BR><A name="startprefixmapping"><!--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>startPrefixMapping()</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>This method is called for each namespace declaration in the source
document. The parser should call this method before the prefix is referenced
in a QName that is passed to the <CODE><FONT face="courier,
monospaced">startElement()</FONT></CODE> call. Namespace
prefix/uri mappings are stored in a Hashtable structure. Namespace prefixes
are used as the keys in the Hashtable, and each key maps to a Stack that
contains the various URIs that the prefix maps to. The URI on top of the
stack is the URI that the prefix currently maps to.</P>
<P><IMG align="right" border="0" hspace="4"
src="images/namespace_stack.gif" vspace="4"><BR clear="all"></P>
<P><I>Figure 2: Namespace handling in the DOM builder</I></P>
<P>Each call to <CODE><FONT face="courier,
monospaced">startPrefixMapping()</FONT></CODE> results in a lookup in the
Hashtable (using the prefix), and a <CODE><FONT face="courier,
monospaced">push()</FONT></CODE> of the URI onto the
Stack that the prefix maps to.</P>
</FONT></TD></TR></TABLE><BR><A name="endprefixmapping"><!--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>endPrefixMapping()</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>A namespace prefix/uri mapping is closed by locating the Stack for the
prefix, and then <CODE><FONT face="courier,
monospaced">pop()</FONT></CODE>'ing the topmost URI off this Stack.</P>
</FONT></TD></TR></TABLE><BR><A name="characters"><!--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>characters()</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>Text nodes are stored as simple character sequences in the character
array
<CODE><FONT face="courier, monospaced">_text[]</FONT></CODE>. The start and
lenght of a node's text can be determined by
using the node index to look up <CODE><FONT face="courier,
monospaced">_offsetOrChild[]</FONT></CODE> and
<CODE><FONT face="courier,
monospaced">_lengthOrAttribute[]</FONT></CODE>.</P>
<P>We want to re-use character sequences if two or more text nodes have
identical content. This can be achieved by having two different text node
indexes map to the same character sequence. The <CODE><FONT face="courier,
monospaced">maybeReuseText()</FONT></CODE>
method is always called before a new character string is stored in the
<CODE><FONT face="courier, monospaced">_text[]</FONT></CODE> array. This
method will locate the offset of an existing
instance of a character sequence.</P>
</FONT></TD></TR></TABLE><BR><A name="startdocument"><!--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>startDocument()</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>This method initialises a bunch of data structures that are used by the
builder. It also pushes the default namespace on the namespace stack (so
that
the "" prefix maps to the <CODE><FONT face="courier,
monospaced">null</FONT></CODE> namespace).</P>
</FONT></TD></TR></TABLE><BR><A name="enddocument"><!--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>endDocument()</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>This method builds the <CODE><FONT face="courier,
monospaced">_namesArray[]</FONT></CODE>, <CODE><FONT face="courier,
monospaced">_namespace[]</FONT></CODE>
and <CODE><FONT face="courier, monospaced">_nsNamesArray[]</FONT></CODE>
structures from temporary datastructures used
in the DOM builder.</P>
</FONT></TD></TR></TABLE><BR>
</FONT></TD></TR></TABLE><BR>
</TD></TR></TABLE></TD></TR></TABLE><BR><TABLE border="0" cellpadding="0"
cellspacing="0" width="620"><TR><TD bgcolor="#0086b2"><IMG height="1"
src="images/dot.gif" width="1"></TD></TR><TR><TD align="center"><FONT
color="#0086b2" size="-1"><I>
Copyright © 2001 The Apache Software Foundation.
All Rights Reserved.
</I></FONT></TD></TR></TABLE></BODY></HTML>
1.1 xml-site/targets/xalan-j/xsltc/xsltc_namespace.html
Index: xsltc_namespace.html
===================================================================
<HTML><HEAD><SCRIPT language="JavaScript" src="resources/script.js"
type="text/javascript"></SCRIPT><TITLE>XSLTC and Namespaces</TITLE></HEAD><BODY
alink="#ff0000" bgcolor="#ffffff" leftmargin="4" link="#0000ff"
marginheight="4" marginwidth="4" text="#000000" topmargin="4"
vlink="#0000aa"><TABLE border="0" cellpadding="0" cellspacing="0"
width="620"><TR><TD align="left" height="60" rowspan="3" valign="top"
width="135"><IMG border="0" height="60" hspace="0" src="resources/logo.gif"
vspace="0" width="135"></TD><TD align="left" colspan="4" height="5"
valign="top" width="456"><IMG border="0" height="5" hspace="0"
src="resources/line.gif" vspace="0" width="456"></TD><TD align="left"
height="60" rowspan="3" valign="top" width="29"><IMG border="0" height="60"
hspace="0" src="resources/right.gif" vspace="0" width="29"></TD></TR><TR><TD
align="left" bgcolor="#0086b2" colspan="4" height="35" valign="top"
width="456"><IMG alt="" border="0" height="35" hspace="0"
src="graphics/xsltc_namespace-header.jpg" vspace="0"
width="456"></TD></TR><TR><TD align="left" height="20" valign="top"
width="168"><IMG border="0" height="20" hspace="0" src="resources/bottom.gif"
vspace="0" width="168"></TD><TD align="left" height="20" valign="top"
width="96"><A href="http://xml.apache.org/" onMouseOut="rolloverOff('xml');"
onMouseOver="rolloverOn('xml');" target="new"><IMG alt="http://xml.apache.org/"
border="0" height="20" hspace="0" name="xml"
onLoad="rolloverLoad('xml','resources/button-xml-hi.gif','resources/button-xml-lo.gif');"
src="resources/button-xml-lo.gif" vspace="0" width="96"></A></TD><TD
align="left" height="20" valign="top" width="96"><A
href="http://www.apache.org/" onMouseOut="rolloverOff('asf');"
onMouseOver="rolloverOn('asf');" target="new"><IMG alt="http://www.apache.org/"
border="0" height="20" hspace="0" name="asf"
onLoad="rolloverLoad('asf','resources/button-asf-hi.gif','resources/button-asf-lo.gif');"
src="resources/button-asf-lo.gif" vspace="0" width="96"></A></TD><TD
align="left" height="20" valign="top" width="96"><A href="http://www.w3.org/"
onMouseOut="rolloverOff('w3c');" onMouseOver="rolloverOn('w3c');"
target="new"><IMG alt="http://www.w3.org/" border="0" height="20" hspace="0"
name="w3c"
onLoad="rolloverLoad('w3c','resources/button-w3c-hi.gif','resources/button-w3c-lo.gif');"
src="resources/button-w3c-lo.gif" vspace="0"
width="96"></A></TD></TR></TABLE><TABLE border="0" cellpadding="0"
cellspacing="0" width="620"><TR><TD align="left" valign="top" width="120"><IMG
border="0" height="14" hspace="0" src="resources/join.gif" vspace="0"
width="120"><BR>
<A href="index.html" onMouseOut="rolloverOff('side-index');"
onMouseOver="rolloverOn('side-index');"><IMG alt="Overview" border="0"
height="12" hspace="0" name="side-index"
onLoad="rolloverLoad('side-index','graphics/index-label-2.jpg','graphics/index-label-3.jpg');"
src="graphics/index-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_compiler.html"
onMouseOut="rolloverOff('side-xsltc_compiler');"
onMouseOver="rolloverOn('side-xsltc_compiler');"><IMG alt="Compiler design"
border="0" height="12" hspace="0" name="side-xsltc_compiler"
onLoad="rolloverLoad('side-xsltc_compiler','graphics/xsltc_compiler-label-2.jpg','graphics/xsltc_compiler-label-3.jpg');"
src="graphics/xsltc_compiler-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsl_whitespace_design.html"
onMouseOut="rolloverOff('side-xsl_whitespace_design');"
onMouseOver="rolloverOn('side-xsl_whitespace_design');"><IMG alt="Whitespace"
border="0" height="12" hspace="0" name="side-xsl_whitespace_design"
onLoad="rolloverLoad('side-xsl_whitespace_design','graphics/xsl_whitespace_design-label-2.jpg','graphics/xsl_whitespace_design-label-3.jpg');"
src="graphics/xsl_whitespace_design-label-3.jpg" vspace="0"
width="120"></A><BR>
<A href="xsl_sort_design.html"
onMouseOut="rolloverOff('side-xsl_sort_design');"
onMouseOver="rolloverOn('side-xsl_sort_design');"><IMG alt="xsl:sort"
border="0" height="12" hspace="0" name="side-xsl_sort_design"
onLoad="rolloverLoad('side-xsl_sort_design','graphics/xsl_sort_design-label-2.jpg','graphics/xsl_sort_design-label-3.jpg');"
src="graphics/xsl_sort_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_key_design.html"
onMouseOut="rolloverOff('side-xsl_key_design');"
onMouseOver="rolloverOn('side-xsl_key_design');"><IMG alt="Keys" border="0"
height="12" hspace="0" name="side-xsl_key_design"
onLoad="rolloverLoad('side-xsl_key_design','graphics/xsl_key_design-label-2.jpg','graphics/xsl_key_design-label-3.jpg');"
src="graphics/xsl_key_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_comment_design.html"
onMouseOut="rolloverOff('side-xsl_comment_design');"
onMouseOver="rolloverOn('side-xsl_comment_design');"><IMG alt="Comment design"
border="0" height="12" hspace="0" name="side-xsl_comment_design"
onLoad="rolloverLoad('side-xsl_comment_design','graphics/xsl_comment_design-label-2.jpg','graphics/xsl_comment_design-label-3.jpg');"
src="graphics/xsl_comment_design-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsl_lang_design.html"
onMouseOut="rolloverOff('side-xsl_lang_design');"
onMouseOver="rolloverOn('side-xsl_lang_design');"><IMG alt="lang()" border="0"
height="12" hspace="0" name="side-xsl_lang_design"
onLoad="rolloverLoad('side-xsl_lang_design','graphics/xsl_lang_design-label-2.jpg','graphics/xsl_lang_design-label-3.jpg');"
src="graphics/xsl_lang_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_unparsed_design.html"
onMouseOut="rolloverOff('side-xsl_unparsed_design');"
onMouseOver="rolloverOn('side-xsl_unparsed_design');"><IMG alt="Unparsed
entities" border="0" height="12" hspace="0" name="side-xsl_unparsed_design"
onLoad="rolloverLoad('side-xsl_unparsed_design','graphics/xsl_unparsed_design-label-2.jpg','graphics/xsl_unparsed_design-label-3.jpg');"
src="graphics/xsl_unparsed_design-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_runtime.html"
onMouseOut="rolloverOff('side-xsltc_runtime');"
onMouseOver="rolloverOn('side-xsltc_runtime');"><IMG alt="Runtime" border="0"
height="12" hspace="0" name="side-xsltc_runtime"
onLoad="rolloverLoad('side-xsltc_runtime','graphics/xsltc_runtime-label-2.jpg','graphics/xsltc_runtime-label-3.jpg');"
src="graphics/xsltc_runtime-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_dom.html" onMouseOut="rolloverOff('side-xsltc_dom');"
onMouseOver="rolloverOn('side-xsltc_dom');"><IMG alt="Internal DOM" border="0"
height="12" hspace="0" name="side-xsltc_dom"
onLoad="rolloverLoad('side-xsltc_dom','graphics/xsltc_dom-label-2.jpg','graphics/xsltc_dom-label-3.jpg');"
src="graphics/xsltc_dom-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG alt="Namespaces" border="0" height="12" hspace="0"
src="graphics/xsltc_namespace-label-1.jpg" vspace="0" width="120"><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_trax.html" onMouseOut="rolloverOff('side-xsltc_trax');"
onMouseOver="rolloverOn('side-xsltc_trax');"><IMG alt="Translet & TrAX"
border="0" height="12" hspace="0" name="side-xsltc_trax"
onLoad="rolloverLoad('side-xsltc_trax','graphics/xsltc_trax-label-2.jpg','graphics/xsltc_trax-label-3.jpg');"
src="graphics/xsltc_trax-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="todo.html" onMouseOut="rolloverOff('side-ext-40');"
onMouseOver="rolloverOn('side-ext-40');"><IMG alt="To-do list" border="0"
height="12" hspace="0" name="side-ext-40"
onLoad="rolloverLoad('side-ext-40','graphics/ext-40-label-2.jpg','graphics/ext-40-label-3.jpg');"
src="graphics/ext-40-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="14" hspace="0" src="resources/close.gif" vspace="0"
width="120"><BR></TD><TD align="left" valign="top" width="500"><TABLE
border="0" cellpadding="3" cellspacing="0"><TR><TD>
<UL>
<LI><A href="#functionality">Functionality</A></LI>
<LI><A href="#overview">Namespace overview</A></LI>
<LI><A href="#NSA">The DOM & namespaces</A></LI>
<LI><A href="#NSB">Namespaces in the XSL stylesheet</A></LI>
<LI><A href="#NSC">Namespaces in the output document</A></LI>
</UL>
<A name="functionality"><!--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>Functionality</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>Namespaces are used when an XML documents has elements have the same
name, but are from different contexts, and thus have different meanings
and interpretations. For instance, a <CODE><FONT face="courier,
monospaced"><TITLE></FONT></CODE> element can
be a HTML title element in one part of the XML document, while it in other
parts of the document the <CODE><FONT face="courier,
monospaced"><TITLE></FONT></CODE> element is used for
encapsulating the title of a play or a book. This sort of confusion is
very common when reading XML source from multiple documents, but can also
occur within a single document.</P>
<P>Namespaces have three very important properties: a name, a prefix (an
alias for its name) and a scope. Namespaces are declared as attributes of
almost any node in an XML document. The declaration looks like this:</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>
<element
xmlns:prefix="http://some.site/spec">....</element>
</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>
<P>The <CODE><FONT face="courier,
monospaced">"xmlns"</FONT></CODE> tells that this is a namespace
declaration. The
scope of the namespace declaration is the element in which it is defined
and all the children of that element.The prefix is the local alias we use
for referencing the namespace, and the URL (it can be anything, really) is
the name/definition of the namespace. Note that even though the namespace
definition is normally an URL, it does not have to point to anything. It
is recommended that it points to a page that describes the elements in the
namespace, but it does not have to. The prefix can be just about anything
- or nothing (in which case it is the default namespace). Any prefix,
including the empty prefix for the default namespace, can be redefined to
refer to a different namespace at any time in an XML document. This is
more likely to happen to the default namespace than any other prefix. Here
is an example of this:</P>
<A name="xml_sample_1"><!--anchor--></A>
<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>
<?xml version="1.0"?>
<employees xmlns:postal="http://postal.ie/spec-1.0"
xmlns:email="http://www.w3c.org/some-spec-3.2">
<employee>
<name>Bob Worker</name>
<postal:address>
<postal:street>Nassau Street</postal:street>
<postal:city>Dublin 3</postal:city>
<postal:country>Ireland</postal:country>
</postal:address>
<email:address>[EMAIL PROTECTED]</email:address>
</employee>
</employees>
</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>
<P>This short document has two namespace declarations, one with the prefix
<CODE><FONT face="courier, monospaced">"postal"</FONT></CODE>
and another with the prefix <CODE><FONT face="courier,
monospaced">"email"</FONT></CODE>. The
prefixes are used to distinguish between elements for e-mail addresses and
regular postal addresses. In addition to these two namespaces there is
also
an initial (unnamed) default namespace being used for the
<CODE><FONT face="courier, monospaced"><name></FONT></CODE> and
<CODE><FONT face="courier, monospaced"><employee></FONT></CODE> tags. The
scope of the
default namespace is in this case the whole document, while the scope of
the other two declared namespaces is the <CODE><FONT face="courier,
monospaced"><employees></FONT></CODE>
element and its children.</P>
<P>By changing the default namespace we could have made the document a
little bit simpler and more readable:</P>
<A name="xml_sample_2"><!--anchor--></A>
<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>
<?xml version="1.0"?>
<employees xmlns:email="http://www.w3c.org/some-spec-3.2">
<employee>
<name>Bob Worker</name>
<address xmlns="http://postal.ie/spec-1.0">
<street>Nassau Street</street>
<city>Dublin 3</city>
<country>Ireland</country>
</address>
<email:address>[EMAIL PROTECTED]</email:address>
</employee>
</employees>
</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>
<P>The default namespace is redefined for the <CODE><FONT face="courier,
monospaced"><address></FONT></CODE> node
and its children, so there is no need to specify the street as
<CODE><FONT face="courier,
monospaced"><postal:street></FONT></CODE> - just plain <CODE><FONT
face="courier, monospaced"><street></FONT></CODE> is
sufficient. Note that this also applies to the <CODE><FONT face="courier,
monospaced"><address></FONT></CODE>
where the namespace is first defined. This is in effect a redefinition of
the default namespace.</P>
</FONT></TD></TR></TABLE><BR><A name="overview"><!--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>Namespace overview</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>Namespaces will have to be handled in three separate parts of the XSLT
compiler:</P>
<A name="all_namespaces"><!--anchor--></A>
<P><IMG align="right" border="0" hspace="4"
src="images/all_namespaces.gif" vspace="4"><BR clear="all"></P>
<P><I>Figure 1: Namespace handlers in the XSLTC</I></P>
<P>The most obvious is the namespaces in the source XML document
(marked <A href="#NSA">"NS A"</A> in figure 1). These
namespaces will be
handled by our DOM implementation class. The source XSL stylesheet also
has its own set of namespaces (<A href="NSB.html">"NS B"</A>) -
one of which
is the XSL namespace. These namespaces will be handled at run-time and
whatever information that is needed to process there should be compiled
into the translet. There is also a set of namespaces that will be used in
the resulting document (<A href="NSC.html">"NS C"</A>). This is
an
intersection of the first two. The output document should not contain any
more namespace declarations than necessary.</P>
</FONT></TD></TR></TABLE><BR><A name="NSA"><!--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 DOM & namespaces</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<UL>
<LI><A href="#dom-namespace">DOM node types and namespace types</A></LI>
<LI><A href="#assign">Assigning namespace types to DOM nodes</A></LI>
</UL>
<A name="dom-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>DOM node types and namespace types</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>Refer to the XSLTC <A href="xsltc_runtime.html">runtime
environment design</A> document for a description of node types before
proceeding. In short, each node in the our DOM implementation is
represented by a simple integer. By using this integer as an index into an
array called <CODE><FONT face="courier, monospaced">_type[]</FONT></CODE>
we can find the type of the node.</P>
<P>The type of the node is an integer representing the type of element the
node is. All elements <CODE><FONT face="courier,
monospaced"><bob></FONT></CODE> will be given the same type,
all text nodes will be given the same type, and so on. By using the node
type as an index an array called <CODE><FONT face="courier,
monospaced">_namesArray[]</FONT></CODE> we can find the
name of the element type - in this case "bob". This code
fragment shows
how you can, with our current implementation, find the name of a node:</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>
int node = iterator.getNext(); // get next node
int type = _type[node]; // get node type
String name = _namesArray[type]; // get node name
</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>
<P>We want to keep the one-type-per-node arrangement, since that lets us
produce fairly efficient code. One type in the DOM maps to one type in
the compiled translet. What we could do to represent the namespace for
each node in the DOM is to add a <CODE><FONT face="courier,
monospaced">_namespaceType[]</FONT></CODE> array that holds
namespace types. Each node type maps to a namespace type, and each
namespace type maps to a namespace name (and a prefix with a limited
scope):</P>
<A name="type_mappings"><!--anchor--></A>
<P><IMG align="right" border="0" hspace="4"
src="images/type_mappings.gif" vspace="4"><BR clear="all"></P>
<P><I>Figure 2: Mapping between node types/names, namespace
types/names</I></P>
<P>This code fragment shows how we could get the namespace name for a
node:</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>
int node = iterator.getNext(); // get next node
int type = _type[node]; // get node type
int nstype = _namespace[type]; // get namespace type
String name = _namesArray[type]; // get node element name
String namespace = _nsNamesArray[nstype]; // get node namespace name
</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>
<P>Note that namespace prefixes are not included here. Namespace prefixes
are local to the XML document and will be expanded to the full namespace
names when the nodes are put into the DOM. This, however, is not a trivial
matter.</P>
</FONT></TD></TR></TABLE><BR><A name="assign"><!--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>Assigning namespace types to DOM nodes</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>We cannot simply have a single namespace prefix array similar to the
<CODE><FONT face="courier, monospaced">_namespaceArray[]</FONT></CODE>
array for mapping a namespace type to a single
prefix. This because prefixes can refer to different namespaces depending
on where in the document the prefixes are being used. In our last
example's
<A href="xml_sample_2.html">XML fragment</A> the empty prefix <CODE><FONT
face="courier, monospaced">""</FONT></CODE>
initially referred to the default namespace (the one with no name - just
like a Clint Eastwood character). Later on in the document the empty
prefix is changed to refer to a namespace called
<CODE><FONT face="courier,
monospaced">"http://postal.ie/spec-1.0"</FONT></CODE>.</P>
<P>Namespace prefixes are only relevant at the time when the XML document
is parsed and the DOM is built. Once we have the DOM completed we only
need
a table that maps each node type to a namespace type, and another array of
all the names of the different namespaces. So what we want to end up with
is something like this:</P>
<P><IMG align="right" border="0" hspace="4"
src="images/dom_namespace1.gif" vspace="4"><BR clear="all"></P>
<P><I>Figure 3: Each namespace references in the DOM gets one
entry</I></P>
<P>The namespace table has one entry for each namespace, nomatter how many
prefixes were used ro reference this namespace in the DOM. To build this
array we need a temporary data structure used by the DOM builder. This
structure is a hashtable - where the various prefixes are used for the
hash values. The contents of each entry in the table will be a small stack
where previous meanings of each prefix will be stored:</P>
<P><IMG align="right" border="0" hspace="4"
src="images/dom_namespace2.gif" vspace="4"><BR clear="all"></P>
<P><I>Figure 4: Temporary data structure used by the DOM builder</I></P>
<P>When the first node is encountered we define a new namespace
<CODE><FONT face="courier, monospaced">"foo"</FONT></CODE> and
assign this namespace type/index 1 (the default
namespace <CODE><FONT face="courier,
monospaced">""</FONT></CODE> has index 0). At the same time we use
the prefix
<CODE><FONT face="courier, monospaced">"A"</FONT></CODE> for a
lookup in the hashtable. This gives us
an integer stack used for the prefix <CODE><FONT face="courier,
monospaced">"A"</FONT></CODE>. We push the namespace
type 1 on this stack. From now on, until <CODE><FONT face="courier,
monospaced">"A"</FONT></CODE> is pop'ed off this
stack, the prefix <CODE><FONT face="courier,
monospaced">"A"</FONT></CODE> will map to namespace type 1, which
represents the namespace URI <CODE><FONT face="courier,
monospaced">"foo"</FONT></CODE>.</P>
<P>We then encounter the next node with a new namespace definition with
the same namespace prefix, we create a new namespace <CODE><FONT
face="courier, monospaced">"bar"</FONT></CODE> and
we put that in the namespace table under type 2. Again we use the prefix
<CODE><FONT face="courier, monospaced">"A"</FONT></CODE> as an
entry into the namespace prefix table and we get the
same integer stack. We now push namespace type 2 on the stack, so that
namespace prefix <CODE><FONT face="courier,
monospaced">"A"</FONT></CODE> maps to namespace URI <CODE><FONT
face="courier, monospaced">"bar"</FONT></CODE>. When
we have traversed this node's children we need to pop the integer off the
stack, so when we're back at the first node the prefix <CODE><FONT
face="courier, monospaced">"A"</FONT></CODE> again
will point to namespace type 0, which maps to <CODE><FONT face="courier,
monospaced">"foo"</FONT></CODE>. To keep
track of what nodes had what namespace declarations, we use a namespace
declaration stack:</P>
<P><IMG align="right" border="0" hspace="4"
src="images/dom_namespace3.gif" vspace="4"><BR clear="all"></P>
<P><I>Figure 5: Namespace declaration stack</I></P>
<P>Every namespace declaration is pushed on the namespace declaration
stack. This stack holds the node index for where the namespace was
declared, and a reference to the prefix stack for this declaration.
The <CODE><FONT face="courier, monospaced">endElement()</FONT></CODE>
method of the DOMBuilder class will need to
remove namespace declaration for the node that is closed. This is done
by first checking the namespace declaration stack for any namespaces
declared by this node. If any declarations are found these are un-declared
by poping the namespace prefixes off the respective prefix stack(s), and
then poping the entry/entries for this node off the namespace declaration
stack.</P>
<P>The <CODE><FONT face="courier, monospaced">endDocument()</FONT></CODE>
method will build an array that contains
all namespaces used in the source XML document - <CODE><FONT
face="courier, monospaced">_nsNamesArray[]</FONT></CODE>
- which holds the URIs of all refered namespaces. This method also builds
an array that maps all DOM node types to namespace types. This two arrays
are accessed through two new methods in the DOM interface:</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>
public String getNamespaceName(int node);
public int getNamespaceType(int node);
</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></FONT></TD></TR></TABLE><BR><A
name="NSB"><!--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>Namespaces in the XSL stylesheet</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<UL>
<LI><A href="#store-access">Storing and accessing namespace
information</A></LI>
<LI><A href="#mapdom-stylesheet">Mapping DOM namespaces to stylesheet
namespaces</A></LI>
<LI><A href="#wildcards">Wildcards and namespaces</A></LI>
</UL>
<A name="store-access"><!--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>Storing and accessing namespace information</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>The SymbolTable class has three datastructures that are used to hold
namespace information:</P>
<UL>
<LI>
First there is the <CODE><FONT face="courier,
monospaced">_namespaces[]</FONT></CODE> Hashtable that maps the names
of in-scope namespace to their respective prefixes. Each key in the
Hashtable object has a stack. A new prefix is pushed on the stack for
each new declaration of a namespace.
</LI>
<LI>
Then there is the <CODE><FONT face="courier,
monospaced">_prefixes[]</FONT></CODE> Hashtable. This has the reverse
function of the <CODE><FONT face="courier,
monospaced">_namespaces[]</FONT></CODE> Hashtable - it maps from
prefixes to namespaces.
</LI>
<LI>
There is also a hashtable that is used for implementing the
<CODE><FONT face="courier,
monospaced"><xsl:namespace-alias></FONT></CODE> element. The keys in this
hashtable is taken from the <CODE><FONT face="courier,
monospaced">stylesheet-prefix</FONT></CODE> attribute of
this element, and the resulting prefix (from the <CODE><FONT
face="courier, monospaced">result-prefix</FONT></CODE>
attribute) is used as the value for each key.
</LI>
</UL>
<P>The SymbolTable class offers 4 methods for accessing these data
structures:</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>
public void pushNamespace(String prefix, String uri);
public void popNamespace(String prefix);
public String lookupPrefix(String uri);
public String lookupNamespace(String prefix);
</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>
<P>These methods are wrapped by two methods in the Parser class (a Parser
object alwas has a SymbolTable object):</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>
// This method pushes all namespaces declared within a single element
public void pushNamespaces(ElementEx element);
// This method pops all namespaces declared within a single element
public void popNamespaces(ElementEx element);
</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>
<P>The translet class has, just like the DOM, a <CODE><FONT
face="courier, monospaced">namesArray[]</FONT></CODE>
structure for holding the expanded QNames of all accessed elements. The
compiled translet fills this array in its constructor. When the translet
has built the DOM (a DOMImpl object), it passes the DOM to the a DOM
adapter (a DOMAdapter object) together with the names array. The DOM
adapter then maps the translet's types to the DOM's types.</P>
</FONT></TD></TR></TABLE><BR><A name="mapdom-stylesheet"><!--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>Mapping DOM namespaces and stylesheet
namespaces</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>Each entry in the DOM's <CODE><FONT face="courier,
monospaced">_namesArray[]</FONT></CODE> is expanded to contain
the full QName, so that instead of containing <CODE><FONT face="courier,
monospaced">prefix:localname</FONT></CODE> it
will now contain <CODE><FONT face="courier,
monospaced">namespace-uri:localname</FONT></CODE>. In this way the expanded
QName in the translet will match the exanded QName in the DOM. This
assures
matches on full QNames, but does not do much for <CODE><FONT
face="courier, monospaced">match="A:*"</FONT></CODE> type
XPath patterns. This is where our main challenge lies.</P>
</FONT></TD></TR></TABLE><BR><A name="wildcards"><!--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>Wildcards and namespaces</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>The original implementation of the XSLTC runtime environment would
only allow matches on "<CODE><FONT face="courier,
monospaced">*</FONT></CODE>" and "<CODE><FONT face="courier,
monospaced">@*</FONT></CODE>" patterns. This was
achieved by mapping all elements that could not be mapped to a translet
type to 3 (DOM.ELEMENT type), and similarly all unknown attributes to
type 4 (DOM.ATTRIBUTE type). The main <CODE><FONT face="courier,
monospaced">switch()</FONT></CODE> statement in
<CODE><FONT face="courier, monospaced">applyTemplates()</FONT></CODE>
would then have a separate "<CODE><FONT face="courier,
monospaced">case()</FONT></CODE>"
for each of these. (Under each <CODE><FONT face="courier,
monospaced">case()</FONT></CODE> you might have to check
for the node's parents in case you were matching on "<CODE><FONT
face="courier, monospaced">path/*</FONT></CODE>"-type
patterns.) This figure shows how that was done:</P>
<A name="match_namespace1"><!--anchor--></A>
<P><IMG align="right" border="0" hspace="4"
src="images/match_namespace1.gif" vspace="4"><BR clear="all"></P>
<P><I>Figure 6: Previous pattern matching</I></P>
<P>The "Node test" box here represents the "<CODE><FONT
face="courier, monospaced">switch()</FONT></CODE>" statement.
The "Node parent test" box represent each "<CODE><FONT
face="courier, monospaced">case:</FONT></CODE>" for that
<CODE><FONT face="courier, monospaced">switch()</FONT></CODE> statement.
There is one <CODE><FONT face="courier, monospaced">case:</FONT></CODE> for
each know
translet node type. For each node type we have to check for any parent
patterns - for instance, for the pattern "<CODE><FONT face="courier,
monospaced">/foo/bar/baz</FONT></CODE>", we will
get a match with <CODE><FONT face="courier, monospaced">case
"baz"</FONT></CODE>, and we have to check that the parent
node is "<CODE><FONT face="courier,
monospaced">bar</FONT></CODE>" and that the grandparent is
"<CODE><FONT face="courier, monospaced">foo</FONT></CODE>" before
we can say that we have a hit. The "Element parent test" is the
test that
is done all DOM nodes that do not directly match any translet types. This
is the test for "<CODE><FONT face="courier,
monospaced">*</FONT></CODE>" or "<CODE><FONT face="courier,
monospaced">foo/*</FONT></CODE>". Similarly we have a
"<CODE><FONT face="courier, monospaced">case:</FONT></CODE>"
for match on attributes ("<CODE><FONT face="courier,
monospaced">@*</FONT></CODE>").</P>
<P>What we now want to achieve is to insert a check for patterns on the
format "<CODE><FONT face="courier,
monospaced">ns:*</FONT></CODE>", "<CODE><FONT face="courier,
monospaced">foo/ns:*</FONT></CODE>" or "<CODE><FONT face="courier,
monospaced">ns:@*</FONT></CODE>", which
this figure illustrates:</P>
<A name="match_namespace2"><!--anchor--></A>
<P><IMG align="right" border="0" hspace="4"
src="images/match_namespace2.gif" vspace="4"><BR clear="all"></P>
<P><I>Figure 7: Pattern matching with namespace tests</I></P>
<P>Each node in the DOM needs a namespace type as well as the QName type.
With this type we can match wildcard rules to any specific namespace.
So after any checks have been done on the whole QName of a node (the
type),
we can match on the namespace type of the node. The main dispatch
<CODE><FONT face="courier, monospaced">switch()</FONT></CODE> in
<CODE><FONT face="courier, monospaced">applyTemplates()</FONT></CODE> must be
changed from this:</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>
public void applyTemplates(DOM dom, NodeIterator iterator,
TransletOutputHandler handler) {
// Get next node from iterator
while ((node = iterator.next()) != END) {
// Get internal node type
final int type = DOM.getType(node);
switch(type) {
case DOM.ROOT: // Match on "/" pattern
handleRootNode();
break;
case DOM.TEXT: // Handle text nodes
handleText();
break;
case DOM.ELEMENT: // Match on "*" pattern
handleWildcardElement();
break;
case DOM.ATTRIBUTE: // Handle on "@*" pattern
handleWildcardElement();
break;
case nodeType1: // Handle 1st known element type
compiledCodeForType1();
break;
:
:
:
case nodeTypeN: // Handle nth known element type
compiledCodeForTypeN();
break;
default:
NodeIterator newIterator = DOM.getChildren(node);
applyTemplates(DOM, newIterator, handler);
break;
}
}
return;
}
</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>
<P>To something like this:</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>
public void applyTemplates(DOM dom, NodeIterator iterator,
TransletOutputHandler handler) {
// Get next node from iterator
while ((node = iterator.next()) != END) {
// First run check on node type
final int type = DOM.getType(node);
switch(type) {
case DOM.ROOT: // Match on "/" pattern
handleRootNode();
continue;
case DOM.TEXT: // Handle text nodes
handleText();
continue;
case DOM.ELEMENT: // Not handled here!!!
break;
case DOM.ATTRIBUTE: // Not handled here!!!
break;
case nodeType1: // Handle 1st known element type
if (compiledCodeForType1() == match) continue;
break;
:
:
:
case nodeTypeN: // Handle nth known element type
if (compiledCodeForTypeN() == match) continue;
break;
default:
break;
}
// Then run check on namespace type
final int namespace = DOM.getNamespace(type);
switch(namespace) {
case 0: // Handle nodes matching 1st known namespace
if (handleThisNamespace() == match) continue;
break;
case 1: // Handle nodes matching 2nd known namespace
if (handleOtherNamespace() == match) continue;
break;
}
// Finally check on element/attribute wildcard
if (type == DOM.ELEMENT) {
if (handleWildcardElement() == match)
continue;
else {
// The default action for elements
NodeIterator newIterator = DOM.getChildren(node);
applyTemplates(DOM, newIterator, handler);
}
}
else if (type == DOM.ATTRIBUTE) {
handleWildcardAttribute();
continue;
}
}
}
</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>
<P>First note that the default action (iterate on children) does not hold
for
attributes, since attribute nodes do not have children. Then note that
the way
the three levels of tests are ordered is consistent with the way patterns
should be prioritised:</P>
<UL>
<LI><B>Match on element/attribute types:</B></LI>
<UL>
<LI><CODE><FONT face="courier,
monospaced">match="/"</FONT></CODE> - match on the root node</LI>
<LI><CODE><FONT face="courier,
monospaced">match="B"</FONT></CODE> - match on any B element</LI>
<LI><CODE><FONT face="courier,
monospaced">match="A/B"</FONT></CODE> - match on B elements with A
parent</LI>
<LI><CODE><FONT face="courier, monospaced">match="A |
B"</FONT></CODE> - match on B or A element</LI>
<LI><CODE><FONT face="courier,
monospaced">match="foo:B"</FONT></CODE> - match on B element within
"foo" namespace</LI>
</UL>
<LI><B>Match on namespace:</B></LI>
<UL>
<LI><CODE><FONT face="courier,
monospaced">match="foo:*"</FONT></CODE> - match on any element within
"foo" namespace</LI>
<LI><CODE><FONT face="courier,
monospaced">match="foo:@*"</FONT></CODE> - match on any attribute
within "foo" namespace</LI>
<LI><CODE><FONT face="courier,
monospaced">match="A/foo:*"</FONT></CODE> - match on any element
within "foo" namespace with A parent</LI>
<LI><CODE><FONT face="courier,
monospaced">match="A/foo:@*"</FONT></CODE> - match on any attribute
within "foo" namespace with A parent</LI>
</UL>
<LI><B>Match on wildcard:</B> </LI>
<UL>
<LI><CODE><FONT face="courier,
monospaced">match="*"</FONT></CODE> - match on any element</LI>
<LI><CODE><FONT face="courier,
monospaced">match="@*"</FONT></CODE> - match on any attribute</LI>
<LI><CODE><FONT face="courier,
monospaced">match="A/*"</FONT></CODE> - match on any element with A
parent</LI>
<LI><CODE><FONT face="courier,
monospaced">match="A/@*"</FONT></CODE> - match on any attribute with
A parent</LI>
</UL>
</UL>
</FONT></TD></TR></TABLE><BR></FONT></TD></TR></TABLE><BR><A
name="NSC"><!--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>Namespaces in the output document</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>These are the categories of namespaces that end up in the output
document:</P>
<UL>
<LI>
Namespaces used in literal elements/attributes in the stylesheet.
These
namespaces should be declared <B>once</B> before use in the output
document. These elements are copied to the output document independent
of namespaces in the input XML document. However, the namespaces can
be declared using the same prefix, such that a namespace used by a
literal result element can overshadow a namespace from the DOM.
</LI>
<LI>
Namespaces from elements in the stylesheet that match elements in the
DOM. No namespaces from the DOM should be copied to the output
document
unless they are actually referenced in the stylesheet. No namespaces
from the stylesheet should be copied to the output document unless the
elements in which they are references match elements in the DOM.
</LI>
</UL>
<A name="output_namespaces1"><!--anchor--></A>
<P><IMG align="right" border="0" hspace="4"
src="images/output_namespaces1.gif" vspace="4"><BR clear="all"></P>
<P><I>Figure 8: Namespace declaration in the output document</I></P>
<P>Any literal element that ends up in the output document must declare
all
namespaces that were declared in the <CODE><FONT face="courier,
monospaced"><xsl:stylesheet<</FONT></CODE>
element. Exceptions are namespaces that are listed in this element's
<CODE><FONT face="courier,
monospaced">exclude-result-prefixes</FONT></CODE> or <CODE><FONT face="courier,
monospaced">extension-element-prefixes</FONT></CODE>
attributes. These namespaces should only be declared if they are
referenced
in the output.</P>
<P>Literal elements should only declare namespaces when necessary. A
literal element should only declare a namespace in the case where it
references a namespace using prefix that is not in scope for this
namespace. The output handler will take care of this problem. All
namespace
declarations are put in the output document using the output handler's
<CODE><FONT face="courier, monospaced">declarenamespace()</FONT></CODE>
method. This method will monitor all namespace
declarations and make sure that no unnecessary declarations are output.
The datastructures used for this are similar to those used to track
namespaces in the XSL stylesheet:</P>
<A name="output_namespaces2"><!--anchor--></A>
<P><IMG align="right" border="0" hspace="4"
src="images/output_namespaces2.gif" vspace="4"><BR clear="all"></P>
<P><I>Figure 9: Handling Namespace declarations in the output
document</I></P>
</FONT></TD></TR></TABLE><BR>
</TD></TR></TABLE></TD></TR></TABLE><BR><TABLE border="0" cellpadding="0"
cellspacing="0" width="620"><TR><TD bgcolor="#0086b2"><IMG height="1"
src="images/dot.gif" width="1"></TD></TR><TR><TD align="center"><FONT
color="#0086b2" size="-1"><I>
Copyright © 2001 The Apache Software Foundation.
All Rights Reserved.
</I></FONT></TD></TR></TABLE></BODY></HTML>
1.1 xml-site/targets/xalan-j/xsltc/xsltc_runtime.html
Index: xsltc_runtime.html
===================================================================
<HTML><HEAD><SCRIPT language="JavaScript" src="resources/script.js"
type="text/javascript"></SCRIPT><TITLE>XSLTC runtime
environment</TITLE></HEAD><BODY alink="#ff0000" bgcolor="#ffffff"
leftmargin="4" link="#0000ff" marginheight="4" marginwidth="4" text="#000000"
topmargin="4" vlink="#0000aa"><TABLE border="0" cellpadding="0" cellspacing="0"
width="620"><TR><TD align="left" height="60" rowspan="3" valign="top"
width="135"><IMG border="0" height="60" hspace="0" src="resources/logo.gif"
vspace="0" width="135"></TD><TD align="left" colspan="4" height="5"
valign="top" width="456"><IMG border="0" height="5" hspace="0"
src="resources/line.gif" vspace="0" width="456"></TD><TD align="left"
height="60" rowspan="3" valign="top" width="29"><IMG border="0" height="60"
hspace="0" src="resources/right.gif" vspace="0" width="29"></TD></TR><TR><TD
align="left" bgcolor="#0086b2" colspan="4" height="35" valign="top"
width="456"><IMG alt="" border="0" height="35" hspace="0"
src="graphics/xsltc_runtime-header.jpg" vspace="0"
width="456"></TD></TR><TR><TD align="left" height="20" valign="top"
width="168"><IMG border="0" height="20" hspace="0" src="resources/bottom.gif"
vspace="0" width="168"></TD><TD align="left" height="20" valign="top"
width="96"><A href="http://xml.apache.org/" onMouseOut="rolloverOff('xml');"
onMouseOver="rolloverOn('xml');" target="new"><IMG alt="http://xml.apache.org/"
border="0" height="20" hspace="0" name="xml"
onLoad="rolloverLoad('xml','resources/button-xml-hi.gif','resources/button-xml-lo.gif');"
src="resources/button-xml-lo.gif" vspace="0" width="96"></A></TD><TD
align="left" height="20" valign="top" width="96"><A
href="http://www.apache.org/" onMouseOut="rolloverOff('asf');"
onMouseOver="rolloverOn('asf');" target="new"><IMG alt="http://www.apache.org/"
border="0" height="20" hspace="0" name="asf"
onLoad="rolloverLoad('asf','resources/button-asf-hi.gif','resources/button-asf-lo.gif');"
src="resources/button-asf-lo.gif" vspace="0" width="96"></A></TD><TD
align="left" height="20" valign="top" width="96"><A href="http://www.w3.org/"
onMouseOut="rolloverOff('w3c');" onMouseOver="rolloverOn('w3c');"
target="new"><IMG alt="http://www.w3.org/" border="0" height="20" hspace="0"
name="w3c"
onLoad="rolloverLoad('w3c','resources/button-w3c-hi.gif','resources/button-w3c-lo.gif');"
src="resources/button-w3c-lo.gif" vspace="0"
width="96"></A></TD></TR></TABLE><TABLE border="0" cellpadding="0"
cellspacing="0" width="620"><TR><TD align="left" valign="top" width="120"><IMG
border="0" height="14" hspace="0" src="resources/join.gif" vspace="0"
width="120"><BR>
<A href="index.html" onMouseOut="rolloverOff('side-index');"
onMouseOver="rolloverOn('side-index');"><IMG alt="Overview" border="0"
height="12" hspace="0" name="side-index"
onLoad="rolloverLoad('side-index','graphics/index-label-2.jpg','graphics/index-label-3.jpg');"
src="graphics/index-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_compiler.html"
onMouseOut="rolloverOff('side-xsltc_compiler');"
onMouseOver="rolloverOn('side-xsltc_compiler');"><IMG alt="Compiler design"
border="0" height="12" hspace="0" name="side-xsltc_compiler"
onLoad="rolloverLoad('side-xsltc_compiler','graphics/xsltc_compiler-label-2.jpg','graphics/xsltc_compiler-label-3.jpg');"
src="graphics/xsltc_compiler-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsl_whitespace_design.html"
onMouseOut="rolloverOff('side-xsl_whitespace_design');"
onMouseOver="rolloverOn('side-xsl_whitespace_design');"><IMG alt="Whitespace"
border="0" height="12" hspace="0" name="side-xsl_whitespace_design"
onLoad="rolloverLoad('side-xsl_whitespace_design','graphics/xsl_whitespace_design-label-2.jpg','graphics/xsl_whitespace_design-label-3.jpg');"
src="graphics/xsl_whitespace_design-label-3.jpg" vspace="0"
width="120"></A><BR>
<A href="xsl_sort_design.html"
onMouseOut="rolloverOff('side-xsl_sort_design');"
onMouseOver="rolloverOn('side-xsl_sort_design');"><IMG alt="xsl:sort"
border="0" height="12" hspace="0" name="side-xsl_sort_design"
onLoad="rolloverLoad('side-xsl_sort_design','graphics/xsl_sort_design-label-2.jpg','graphics/xsl_sort_design-label-3.jpg');"
src="graphics/xsl_sort_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_key_design.html"
onMouseOut="rolloverOff('side-xsl_key_design');"
onMouseOver="rolloverOn('side-xsl_key_design');"><IMG alt="Keys" border="0"
height="12" hspace="0" name="side-xsl_key_design"
onLoad="rolloverLoad('side-xsl_key_design','graphics/xsl_key_design-label-2.jpg','graphics/xsl_key_design-label-3.jpg');"
src="graphics/xsl_key_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_comment_design.html"
onMouseOut="rolloverOff('side-xsl_comment_design');"
onMouseOver="rolloverOn('side-xsl_comment_design');"><IMG alt="Comment design"
border="0" height="12" hspace="0" name="side-xsl_comment_design"
onLoad="rolloverLoad('side-xsl_comment_design','graphics/xsl_comment_design-label-2.jpg','graphics/xsl_comment_design-label-3.jpg');"
src="graphics/xsl_comment_design-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsl_lang_design.html"
onMouseOut="rolloverOff('side-xsl_lang_design');"
onMouseOver="rolloverOn('side-xsl_lang_design');"><IMG alt="lang()" border="0"
height="12" hspace="0" name="side-xsl_lang_design"
onLoad="rolloverLoad('side-xsl_lang_design','graphics/xsl_lang_design-label-2.jpg','graphics/xsl_lang_design-label-3.jpg');"
src="graphics/xsl_lang_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_unparsed_design.html"
onMouseOut="rolloverOff('side-xsl_unparsed_design');"
onMouseOver="rolloverOn('side-xsl_unparsed_design');"><IMG alt="Unparsed
entities" border="0" height="12" hspace="0" name="side-xsl_unparsed_design"
onLoad="rolloverLoad('side-xsl_unparsed_design','graphics/xsl_unparsed_design-label-2.jpg','graphics/xsl_unparsed_design-label-3.jpg');"
src="graphics/xsl_unparsed_design-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<IMG alt="Runtime" border="0" height="12" hspace="0"
src="graphics/xsltc_runtime-label-1.jpg" vspace="0" width="120"><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_dom.html" onMouseOut="rolloverOff('side-xsltc_dom');"
onMouseOver="rolloverOn('side-xsltc_dom');"><IMG alt="Internal DOM" border="0"
height="12" hspace="0" name="side-xsltc_dom"
onLoad="rolloverLoad('side-xsltc_dom','graphics/xsltc_dom-label-2.jpg','graphics/xsltc_dom-label-3.jpg');"
src="graphics/xsltc_dom-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsltc_namespace.html"
onMouseOut="rolloverOff('side-xsltc_namespace');"
onMouseOver="rolloverOn('side-xsltc_namespace');"><IMG alt="Namespaces"
border="0" height="12" hspace="0" name="side-xsltc_namespace"
onLoad="rolloverLoad('side-xsltc_namespace','graphics/xsltc_namespace-label-2.jpg','graphics/xsltc_namespace-label-3.jpg');"
src="graphics/xsltc_namespace-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_trax.html" onMouseOut="rolloverOff('side-xsltc_trax');"
onMouseOver="rolloverOn('side-xsltc_trax');"><IMG alt="Translet & TrAX"
border="0" height="12" hspace="0" name="side-xsltc_trax"
onLoad="rolloverLoad('side-xsltc_trax','graphics/xsltc_trax-label-2.jpg','graphics/xsltc_trax-label-3.jpg');"
src="graphics/xsltc_trax-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="todo.html" onMouseOut="rolloverOff('side-ext-40');"
onMouseOver="rolloverOn('side-ext-40');"><IMG alt="To-do list" border="0"
height="12" hspace="0" name="side-ext-40"
onLoad="rolloverLoad('side-ext-40','graphics/ext-40-label-2.jpg','graphics/ext-40-label-3.jpg');"
src="graphics/ext-40-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="14" hspace="0" src="resources/close.gif" vspace="0"
width="120"><BR></TD><TD align="left" valign="top" width="500"><TABLE
border="0" cellpadding="3" cellspacing="0"><TR><TD>
<UL>
<LI><A href="#overview">Runtime overview</A></LI>
<LI><A href="#translet">The compiled translet</A></LI>
<LI><A href="#types">External/internal type mapping</A></LI>
<LI><A href="#mainloop">Main program loop</A></LI>
</UL>
<A name="overview"><!--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>Runtime overview</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>The actual transformation of the input XML document is initiated by
one of these classes:</P>
<UL>
<LI>
<CODE><FONT face="courier,
monospaced">com.sun.xslt.runtime.DefaultRun</FONT></CODE> (runs in a terminal)
</LI>
<LI>
<CODE><FONT face="courier,
monospaced">com.sun.xslt.demo.applet.TransformApplet</FONT></CODE> (runs in an
applet)
</LI>
<LI>
<CODE><FONT face="courier,
monospaced">com.sun.xslt.demo.servlet.Translate</FONT></CODE> (runs in a
servlet)
</LI>
</UL>
<P>Any one of these classes will have to go through the folloing steps in
order to initiate a transformation:</P>
<UL>
<LI>
Instanciate the translet object. The name of the translet (ie. class)
to use is passed to us as a string. We use this string as a parameter
to the static method <CODE><FONT face="courier,
monospaced">Class.forName(String name)</FONT></CODE> to get a
reference to a translet object.
</LI>
<LI>
Instanciate a <CODE><FONT face="courier,
monospaced">com.sun.xsl.parser.Parser</FONT></CODE> object to parse the
input XML file, and instanciate a DOM (we have our own DOM
implementation especially designed for XSLTC) where we store the
input document.
</LI>
<LI>
Pass any parameters to the translet (currently only possible when
running the transformation in a terminal using DefaultRun)
</LI>
<LI>
Instanciate a handler for the result document. This handler must be
extend the <CODE><FONT face="courier,
monospaced">TransletOutputHandler</FONT></CODE> class.
</LI>
<LI>
Invoke the <CODE><FONT face="courier,
monospaced">transform()</FONT></CODE> method on the translet, passing the
instanciated DOM and the output handler as parameters.
</LI>
</UL>
</FONT></TD></TR></TABLE><BR><A name="translet"><!--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 compiled translet</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>A translet is always a subclass of <CODE><FONT face="courier,
monospaced">AbstractTranslet</FONT></CODE>. As well
as having access to the public/protected methods in this class, the
translet is compiled with these methods:</P>
<P><CODE><FONT face="courier, monospaced">public void transform(DOM,
NodeIterator, TransletOutputHandler);</FONT></CODE></P>
<P>This method is passed a <CODE><FONT face="courier,
monospaced">DOMImpl</FONT></CODE> object. Depending on whether
the stylesheet had any calls to the <CODE><FONT face="courier,
monospaced">document()</FONT></CODE> function this
method will either generate a <CODE><FONT face="courier,
monospaced">DOMAdapter</FONT></CODE> object (when only one
XML document is used as input) or a <CODE><FONT face="courier,
monospaced">MultiDOM</FONT></CODE> object (when there
are more than one XML input documents). This DOM object is passed on to
the <CODE><FONT face="courier, monospaced">topLevel()</FONT></CODE>
method.</P>
<P>When the <CODE><FONT face="courier,
monospaced">topLevel()</FONT></CODE> method returns we initiate the output
document by calling <CODE><FONT face="courier,
monospaced">startDocument()</FONT></CODE> on the supplied output
handler object. We then call <CODE><FONT face="courier,
monospaced">applyTemplates()</FONT></CODE> to get the actual
output contents, before we close the output document by calling
<CODE><FONT face="courier, monospaced">endDocument()</FONT></CODE> on the
output handler.</P>
<P><CODE><FONT face="courier, monospaced">public void topLevel(DOM,
NodeIterator, TransletOutputHandler);</FONT></CODE></P>
<P>This method handles all of these top-level elements:</P>
<UL>
<LI><CODE><FONT face="courier,
monospaced"><xsl:output></FONT></CODE></LI>
<LI><CODE><FONT face="courier,
monospaced"><xsl:decimal-format></FONT></CODE></LI>
<LI><CODE><FONT face="courier,
monospaced"><xsl:key></FONT></CODE></LI>
<LI><CODE><FONT face="courier,
monospaced"><xsl:param></FONT></CODE> (for global parameters)</LI>
<LI><CODE><FONT face="courier,
monospaced"><xsl:variable></FONT></CODE> (for global variables)</LI>
</UL>
<P><CODE><FONT face="courier, monospaced">public void applyTemplates(DOM,
NodeIterator, TransletOutputHandler);</FONT></CODE></P>
<P>This is the method that produces the actual output. Its central element
is a big <CODE><FONT face="courier, monospaced">switch()</FONT></CODE>
statement that is used to choose the available
templates for the various node in the input document. See the chapter
<A href="#mainloop">Main Program Loop</A> for details on this method.</P>
<P><CODE><FONT face="courier, monospaced">public void <init>
();</FONT></CODE></P>
<A name="namesarray"><!--anchor--></A>
<P>The translet's constructor initializes a table
of all the elements we want to search for in the XML input document.
This table is called the <CODE><FONT face="courier,
monospaced">namesArray</FONT></CODE> and it is passed to the DOM
holding the input XML document.</P>
<P>The constructor also initializes any <CODE><FONT face="courier,
monospaced">DecimalFormatSymbol</FONT></CODE>
objects that are used to format numbers before passing them to the
output handler.</P>
<P><CODE><FONT face="courier, monospaced">public boolean stripSpace(int
nodeType);</FONT></CODE></P>
<P>This method is only present if any <CODE><FONT face="courier,
monospaced"><xsl:strip-space></FONT></CODE> or
<CODE><FONT face="courier,
monospaced"><xsl:preserve-space></FONT></CODE> elements are present in
the stylesheet.
If that is the case, the translet implements the
<CODE><FONT face="courier,
monospaced">StripWhitespaceFilter</FONT></CODE> interface by containing this
method.</P>
</FONT></TD></TR></TABLE><BR><A name="types"><!--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>External/internal type mapping</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<A name="external-types"><!--anchor--></A>
<P>This is the very core of XSL transformations: <B>Read
carefully!!!</B></P>
<P>Every node in the input XML document(s) is assigned a type by the
DOM builder class. This type is an integer value which represents the
element, so that for instance all <CODE><FONT face="courier,
monospaced"><bob></FONT></CODE> elements in the
input document will be given type <I>7</I> and can be referred to by using
that integer. These types can be used for lookups in the
<A href="#namesarray">namesArray</A> table to get the actual
element name (in this case "bob"). These types are referred to
as
<B>external types</B> or <B>DOM types</B>, as they are types known only
to the DOM and the DOM builder.</P>
<A name="internal-types"><!--anchor--></A>
<P>Similarly the translet assignes types to all element and attribute
names
that are referenced in the stylesheet. These types are referred to as
<B>internal types</B> or <B>translet types</B>.</P>
<P>It is not very probable that there will be a one-to-one mapping between
internal and external types. There will most often be elements in the DOM
(ie. the input document) that are not mentioned in the stylesheet, and
there could be elements in the stylesheet that do not match any elements
in the DOM. Here is an example:</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>
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="blahblahblah">
<xsl:template match="/">
<xsl:for-each select="//B">
<xsl:apply-templates select="." />
</xsl:for-each>
<xsl:for-each select="C">
<xsl:apply-templates select="." />
</xsl:for-each>
<xsl:for-each select="A/B">
<xsl:apply-templates select="." />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
</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>
<P>In this stylesheet we are looking for elements <CODE><FONT
face="courier, monospaced"><B></FONT></CODE>,
<CODE><FONT face="courier, monospaced"><C></FONT></CODE> and
<CODE><FONT face="courier, monospaced"><A></FONT></CODE>. For this
example we can assume
that these element types will be assigned the values 0, 1 and 2. Now, lets
say we are transforming this XML document:</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>
<?xml version="1.0"?>
<A>
The crocodile cried:
<F>foo</F>
<B>bar</B>
<B>baz</B>
</A>
</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>
<P>This XML document has the elements <CODE><FONT face="courier,
monospaced"><A></FONT></CODE>,
<CODE><FONT face="courier, monospaced"><B></FONT></CODE> and
<CODE><FONT face="courier, monospaced"><F></FONT></CODE>, which we assume
are assigned the
types 7, 8 and 9 respectively (the numbers below that are assigned for
specific element types, such as the root node, text nodes, etc.). This
causes a mismatch between the type used for <CODE><FONT face="courier,
monospaced"><B></FONT></CODE> in the
translet and the type used for <CODE><FONT face="courier,
monospaced"><B></FONT></CODE> in the DOM. Th
DOMAdapter class (which mediates between the DOM and the translet) has
been
given two tables for convertint between the two types; <CODE><FONT
face="courier, monospaced">mapping</FONT></CODE> for
mapping from internal to external types, and <CODE><FONT face="courier,
monospaced">reverseMapping</FONT></CODE> for
the other way around.</P>
<P>The translet contains a <CODE><FONT face="courier,
monospaced">String[]</FONT></CODE> array called
<CODE><FONT face="courier, monospaced">namesArray</FONT></CODE>. This
array will contain all the element and attribute
names that were referenced in the stylesheet. In our example, this array
would contain these string (in this specific order): "B",
"C" and "A". This array is passed as one of the
parameters to the DOM adapter constructor (the other adapter is the DOM
itself). The DOM adapter passes this table on to the DOM. The DOM has
a hashtable that maps known element names to external types. The DOM goes
through the <CODE><FONT face="courier,
monospaced">namesArray</FONT></CODE> from the DOM sequentially, looks up each
name in the hashtable, and is then able to map the internal type to an
external type. The result is then passed back to the DOM adapter.</P>
<P>The reverse is done for external types. External types that are not
interesting for the translet (such as the type for <CODE><FONT
face="courier, monospaced"><F></FONT></CODE>
elements in the example above) are mapped to a generic <CODE><FONT
face="courier, monospaced">"ELEMENT"</FONT></CODE>
type 3, and are more or less ignored by the translet.</P>
<P>It is important that we separate the DOM from the translet. In several
cases we want the DOM as a structure completely independent from the
translet - even though the DOM is a structure internal to XSLTC. One such
case is when transformations are offered by a servlet as a web service.
Any DOM that is built should potentially be stored in a cache and made
available for simultaneous access by several translet/servlet couples.</P>
<P><IMG align="right" border="0" hspace="4"
src="images/runtime_type_mapping.gif" vspace="4"><BR clear="all"></P>
<P><I>Figure 1: Two translets accessing a single dom using different type
mappings</I></P>
</FONT></TD></TR></TABLE><BR><A name="mainloop"><!--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>Main program loop</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>The main loop in the translet is found in the <CODE><FONT
face="courier, monospaced">applyTemplates()</FONT></CODE>
method. This method goes through these steps:</P>
<UL>
<LI>
Get the next node from the node iterator
</LI>
<LI>
Get the internal type of this node. The DOMAdapter object holds the
internal/external type mapping table, and it will supply the translet
with the internal type of the current node.
</LI>
<LI>
Execute a switch statement on the internal node type. There will be
one "case" label for each recognised node type - this
includes the
first 7 internal node types.
</LI>
</UL>
<P>The root node will have internal type 0 and will cause any initial
literal elements to be output. Text nodes will have internal node type 1
and will simply be dumped to the output handler. Unrecognized elements
will have internal node type 3 and will be given the default treatment
(a new iterator is created for the node's children, and this iterator
is passed with a recursive call to <CODE><FONT face="courier,
monospaced">applyTemplates()</FONT></CODE>).
Unrecognised attribute nodes (type 4) will be handled like text nodes.
The <CODE><FONT face="courier, monospaced">switch()</FONT></CODE>
statement in <CODE><FONT face="courier,
monospaced">applyTemplates</FONT></CODE> will thereby
look something like this:</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>
public void applyTemplates(DOM dom, NodeIterator,
TransletOutputHandler handler) {
// get nodes from iterator
while ((node = iterator.next()) != END) {
// get internal node type
switch(DOM.getType(node)) {
case 0: // root
outputPreable(handler);
break;
case 1: // text
DOM.characters(node,handler);
break;
case 3: // unrecognised element
NodeIterator newIterator = DOM.getChildren(node);
applyTemplates(DOM,newIterator,handler);
break;
case 4: // unrecognised attribute
DOM.characters(node,handler);
break;
case 7: // elements of type <B>
someCompiledCode();
break;
case 8: // elements of type <C>
otherCompiledCode();
break;
default:
break;
}
}
}
</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>
<P>Each recognised element will have its own piece of compiled code.</P>
<P>Note that each "case" will not lead directly to a single
template.
There may be several templates that match node type 7
(say <CODE><FONT face="courier, monospaced"><B></FONT></CODE>). In
the sample stylesheet in the previous chapter
we have to templates that would match a node <CODE><FONT face="courier,
monospaced"><B></FONT></CODE>. We have
one <CODE><FONT face="courier,
monospaced">match="//B"</FONT></CODE> (match just any <CODE><FONT
face="courier, monospaced"><B></FONT></CODE> element) and
one <CODE><FONT face="courier,
monospaced">match="A/B"</FONT></CODE> (match a <CODE><FONT
face="courier, monospaced"><B></FONT></CODE> element that is a
child of a <CODE><FONT face="courier, monospaced"><A></FONT></CODE>
element). In this case we would have to
compile code that first gets the type of the current node's parent, and
then compared this type with the type for <CODE><FONT face="courier,
monospaced"><A></FONT></CODE>. If there was
no match we will have executed the first <CODE><FONT face="courier,
monospaced"><xsl:for-each></FONT></CODE>
element, but if there was a match we will have executed the last one.
Consequentally, the compiler will generate the following code:</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>
switch(DOM.getType(node)) {
:
:
case 7: // elements of type <B>
int parent = DOM.getParent(node);
if (DOM.getType(parent) == 9) // type 9 = elements <A>
someCompiledCode();
else
evenOtherCompiledCode();
break;
:
:
}
</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>
<P>We could do the same for namespaces, that is, assign a numeric value
to every namespace that is references in the stylesheet, and use an
<CODE><FONT face="courier, monospaced">"if"</FONT></CODE>
statement for each namespace that needs to be checked for
each type. Lets say we had a stylesheet like this:</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>
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="blahblahblah">
<xsl:template match="/"
xmlns:foo="http://foo.com/spec"
xmlns:bar="http://bar.net/ref">
<xsl:for-each select="foo:A">
<xsl:apply-templates select="." />
</xsl:for-each>
<xsl:for-each select="bar:A">
<xsl:apply-templates select="." />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
</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>
<P>And a stylesheet like this:</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>
<?xml version="1.0"?>
<DOC
xmlns:foo="http://foo.com/spec"
xmlns:bar="http://bar.net/ref">
<foo:A>In foo namespace</foo:A>
<bar:A>In bar namespace</bar:A>
</DOC>
</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>
<P>We could still keep the same type for all <CODE><FONT face="courier,
monospaced"><A></FONT></CODE> elements
regardless of what namespace they are in, and use the same <CODE><FONT
face="courier, monospaced">"if"</FONT></CODE>
structure within the <CODE><FONT face="courier,
monospaced">switch()</FONT></CODE> statement above. The other option
is to assign different types to <CODE><FONT face="courier,
monospaced"><foo:A></FONT></CODE> and
<CODE><FONT face="courier, monospaced"><bar:A></FONT></CODE>
elements.</P>
</FONT></TD></TR></TABLE><BR>
</TD></TR></TABLE></TD></TR></TABLE><BR><TABLE border="0" cellpadding="0"
cellspacing="0" width="620"><TR><TD bgcolor="#0086b2"><IMG height="1"
src="images/dot.gif" width="1"></TD></TR><TR><TD align="center"><FONT
color="#0086b2" size="-1"><I>
Copyright © 2001 The Apache Software Foundation.
All Rights Reserved.
</I></FONT></TD></TR></TABLE></BODY></HTML>
1.1 xml-site/targets/xalan-j/xsltc/xsltc_trax.html
Index: xsltc_trax.html
===================================================================
<HTML><HEAD><SCRIPT language="JavaScript" src="resources/script.js"
type="text/javascript"></SCRIPT><TITLE>The Translet API &
TrAX</TITLE></HEAD><BODY alink="#ff0000" bgcolor="#ffffff" leftmargin="4"
link="#0000ff" marginheight="4" marginwidth="4" text="#000000" topmargin="4"
vlink="#0000aa"><TABLE border="0" cellpadding="0" cellspacing="0"
width="620"><TR><TD align="left" height="60" rowspan="3" valign="top"
width="135"><IMG border="0" height="60" hspace="0" src="resources/logo.gif"
vspace="0" width="135"></TD><TD align="left" colspan="4" height="5"
valign="top" width="456"><IMG border="0" height="5" hspace="0"
src="resources/line.gif" vspace="0" width="456"></TD><TD align="left"
height="60" rowspan="3" valign="top" width="29"><IMG border="0" height="60"
hspace="0" src="resources/right.gif" vspace="0" width="29"></TD></TR><TR><TD
align="left" bgcolor="#0086b2" colspan="4" height="35" valign="top"
width="456"><IMG alt="" border="0" height="35" hspace="0"
src="graphics/xsltc_trax-header.jpg" vspace="0" width="456"></TD></TR><TR><TD
align="left" height="20" valign="top" width="168"><IMG border="0" height="20"
hspace="0" src="resources/bottom.gif" vspace="0" width="168"></TD><TD
align="left" height="20" valign="top" width="96"><A
href="http://xml.apache.org/" onMouseOut="rolloverOff('xml');"
onMouseOver="rolloverOn('xml');" target="new"><IMG alt="http://xml.apache.org/"
border="0" height="20" hspace="0" name="xml"
onLoad="rolloverLoad('xml','resources/button-xml-hi.gif','resources/button-xml-lo.gif');"
src="resources/button-xml-lo.gif" vspace="0" width="96"></A></TD><TD
align="left" height="20" valign="top" width="96"><A
href="http://www.apache.org/" onMouseOut="rolloverOff('asf');"
onMouseOver="rolloverOn('asf');" target="new"><IMG alt="http://www.apache.org/"
border="0" height="20" hspace="0" name="asf"
onLoad="rolloverLoad('asf','resources/button-asf-hi.gif','resources/button-asf-lo.gif');"
src="resources/button-asf-lo.gif" vspace="0" width="96"></A></TD><TD
align="left" height="20" valign="top" width="96"><A href="http://www.w3.org/"
onMouseOut="rolloverOff('w3c');" onMouseOver="rolloverOn('w3c');"
target="new"><IMG alt="http://www.w3.org/" border="0" height="20" hspace="0"
name="w3c"
onLoad="rolloverLoad('w3c','resources/button-w3c-hi.gif','resources/button-w3c-lo.gif');"
src="resources/button-w3c-lo.gif" vspace="0"
width="96"></A></TD></TR></TABLE><TABLE border="0" cellpadding="0"
cellspacing="0" width="620"><TR><TD align="left" valign="top" width="120"><IMG
border="0" height="14" hspace="0" src="resources/join.gif" vspace="0"
width="120"><BR>
<A href="index.html" onMouseOut="rolloverOff('side-index');"
onMouseOver="rolloverOn('side-index');"><IMG alt="Overview" border="0"
height="12" hspace="0" name="side-index"
onLoad="rolloverLoad('side-index','graphics/index-label-2.jpg','graphics/index-label-3.jpg');"
src="graphics/index-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_compiler.html"
onMouseOut="rolloverOff('side-xsltc_compiler');"
onMouseOver="rolloverOn('side-xsltc_compiler');"><IMG alt="Compiler design"
border="0" height="12" hspace="0" name="side-xsltc_compiler"
onLoad="rolloverLoad('side-xsltc_compiler','graphics/xsltc_compiler-label-2.jpg','graphics/xsltc_compiler-label-3.jpg');"
src="graphics/xsltc_compiler-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsl_whitespace_design.html"
onMouseOut="rolloverOff('side-xsl_whitespace_design');"
onMouseOver="rolloverOn('side-xsl_whitespace_design');"><IMG alt="Whitespace"
border="0" height="12" hspace="0" name="side-xsl_whitespace_design"
onLoad="rolloverLoad('side-xsl_whitespace_design','graphics/xsl_whitespace_design-label-2.jpg','graphics/xsl_whitespace_design-label-3.jpg');"
src="graphics/xsl_whitespace_design-label-3.jpg" vspace="0"
width="120"></A><BR>
<A href="xsl_sort_design.html"
onMouseOut="rolloverOff('side-xsl_sort_design');"
onMouseOver="rolloverOn('side-xsl_sort_design');"><IMG alt="xsl:sort"
border="0" height="12" hspace="0" name="side-xsl_sort_design"
onLoad="rolloverLoad('side-xsl_sort_design','graphics/xsl_sort_design-label-2.jpg','graphics/xsl_sort_design-label-3.jpg');"
src="graphics/xsl_sort_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_key_design.html"
onMouseOut="rolloverOff('side-xsl_key_design');"
onMouseOver="rolloverOn('side-xsl_key_design');"><IMG alt="Keys" border="0"
height="12" hspace="0" name="side-xsl_key_design"
onLoad="rolloverLoad('side-xsl_key_design','graphics/xsl_key_design-label-2.jpg','graphics/xsl_key_design-label-3.jpg');"
src="graphics/xsl_key_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_comment_design.html"
onMouseOut="rolloverOff('side-xsl_comment_design');"
onMouseOver="rolloverOn('side-xsl_comment_design');"><IMG alt="Comment design"
border="0" height="12" hspace="0" name="side-xsl_comment_design"
onLoad="rolloverLoad('side-xsl_comment_design','graphics/xsl_comment_design-label-2.jpg','graphics/xsl_comment_design-label-3.jpg');"
src="graphics/xsl_comment_design-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsl_lang_design.html"
onMouseOut="rolloverOff('side-xsl_lang_design');"
onMouseOver="rolloverOn('side-xsl_lang_design');"><IMG alt="lang()" border="0"
height="12" hspace="0" name="side-xsl_lang_design"
onLoad="rolloverLoad('side-xsl_lang_design','graphics/xsl_lang_design-label-2.jpg','graphics/xsl_lang_design-label-3.jpg');"
src="graphics/xsl_lang_design-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsl_unparsed_design.html"
onMouseOut="rolloverOff('side-xsl_unparsed_design');"
onMouseOver="rolloverOn('side-xsl_unparsed_design');"><IMG alt="Unparsed
entities" border="0" height="12" hspace="0" name="side-xsl_unparsed_design"
onLoad="rolloverLoad('side-xsl_unparsed_design','graphics/xsl_unparsed_design-label-2.jpg','graphics/xsl_unparsed_design-label-3.jpg');"
src="graphics/xsl_unparsed_design-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_runtime.html"
onMouseOut="rolloverOff('side-xsltc_runtime');"
onMouseOver="rolloverOn('side-xsltc_runtime');"><IMG alt="Runtime" border="0"
height="12" hspace="0" name="side-xsltc_runtime"
onLoad="rolloverLoad('side-xsltc_runtime','graphics/xsltc_runtime-label-2.jpg','graphics/xsltc_runtime-label-3.jpg');"
src="graphics/xsltc_runtime-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="xsltc_dom.html" onMouseOut="rolloverOff('side-xsltc_dom');"
onMouseOver="rolloverOn('side-xsltc_dom');"><IMG alt="Internal DOM" border="0"
height="12" hspace="0" name="side-xsltc_dom"
onLoad="rolloverLoad('side-xsltc_dom','graphics/xsltc_dom-label-2.jpg','graphics/xsltc_dom-label-3.jpg');"
src="graphics/xsltc_dom-label-3.jpg" vspace="0" width="120"></A><BR>
<A href="xsltc_namespace.html"
onMouseOut="rolloverOff('side-xsltc_namespace');"
onMouseOver="rolloverOn('side-xsltc_namespace');"><IMG alt="Namespaces"
border="0" height="12" hspace="0" name="side-xsltc_namespace"
onLoad="rolloverLoad('side-xsltc_namespace','graphics/xsltc_namespace-label-2.jpg','graphics/xsltc_namespace-label-3.jpg');"
src="graphics/xsltc_namespace-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<IMG alt="Translet & TrAX" border="0" height="12" hspace="0"
src="graphics/xsltc_trax-label-1.jpg" vspace="0" width="120"><BR>
<IMG border="0" height="6" hspace="0" src="resources/separator.gif"
vspace="0" width="120"><BR>
<A href="todo.html" onMouseOut="rolloverOff('side-ext-40');"
onMouseOver="rolloverOn('side-ext-40');"><IMG alt="To-do list" border="0"
height="12" hspace="0" name="side-ext-40"
onLoad="rolloverLoad('side-ext-40','graphics/ext-40-label-2.jpg','graphics/ext-40-label-3.jpg');"
src="graphics/ext-40-label-3.jpg" vspace="0" width="120"></A><BR>
<IMG border="0" height="14" hspace="0" src="resources/close.gif" vspace="0"
width="120"><BR></TD><TD align="left" valign="top" width="500"><TABLE
border="0" cellpadding="3" cellspacing="0"><TR><TD>
<P><I>By</I> <A href="mailto:[EMAIL PROTECTED]">G. Todd Miller</A> -updated
May 11, 2001</P>
<UL>
<LI><A href="#abstract">Abstract</A></LI>
<LI><A href="#trax">TrAX</A></LI>
<LI><A href="#integrate">Translet Integration</A></LI>
<LI><A href="#factory">SAXTransformerFactory for Translets</A></LI>
<LI><A href="#transform">AbstractTranslet transform() method</A></LI>
<LI><A href="#conclusion">Conclusion</A></LI>
<LI><A href="#appendix">Appendix</A></LI>
</UL>
<P>See also: <A href="../xsltc_usage.html#api">Calling XSLTC with the
TrAX/JAXP API</A></P>
<A name="abstract"><!--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>Abstract</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>This document describes what I have so far as a prototype for integrating
Translets with the JAXP TrAX. In a nutshell, a new Transformer factory
class has be written that extends the JAXP SAXTransformerFactory class.
The newfactory delivers Translets as Transformers, and creates Templates.
Calling the Transformer transform() method will cause the given XML
document to be transformed by a translet that has been compiled from the
supplied stylesheet. The switch that determines what XSLT processor gets
to transform the XML document is based on the value of a JAXP system
property for the Transformers factory.</P>
</FONT></TD></TR></TABLE><BR><A name="trax"><!--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>TrAX</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>The Java API for XML Processing (JAXP) includes an XSLT framework based on
the
Transformation API for XML (TrAX). In a typical JAXP transformation
application
the steps involved in transforming an XML document with an XSLT stylesheet
are: (1)
create an instance of the TransformerFactory class, (2) from the factory
instance and
a given XSLT stylesheet, create a new Transformer object, (3) call the
Transformer
objects transform() method on a given XML document and a specified Result
object.
Alternatively, one could also ask the instance of the TransformerFactory for
a Templates object given an XSLT stylesheet. From the Templates object, a new
Transformer can be created, and again, its transform() method can be called
with
an XML document and specified Result object.</P>
<P>The code below illustrates a simple JAXP transformation application
(Proto.java)
that creates the Transformer directly.</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>import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
public class Proto {
public static void main(String[] args){
Proto app = new Proto();
app.run(args);
}
public void run(String[] args){
if (args.length != 2) {
usage();
}
String inputFilename = args[0];
String stylesheet = args[1];
Transformer transformer;
TransformerFactory factory = TransformerFactory.newInstance();
try {
transformer = factory.newTransformer(new StreamSource(stylesheet));
transformer.transform(new StreamSource(inputFilename),
new StreamResult(System.out));
} catch (Exception e) {
// nothing...
}
}
public void usage() {
System.err.println(
"Usage: run <xml_file> <xsl_file>");
System.exit(1);
}
}</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>
<P>The use of Templates is useful when multiple instances of the same
transformer
are needed. For example transforming multiple documents by the same
transformer,
each working in a separate thread. In this case, the TransformerFactory is
used to
create a Templates object for a given stylesheet. Each Transformer instance
is then
created by the Templates object. In this way the Templates object can compile
the
stylesheet once, and each time a new instance of the transformer is asked
for, a clone is
provided rather than recompile the stylesheet again and again. The Proto
class above
would be modified as follows:</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>try {
Templates templates = factory.newTemplates(new StreamSource(stylesheet));
transformer = templates.newTransformer();
transformer.transform(new StreamSource(inputFilename),
new StreamResult(System.out));
} catch (Exception e) {
// nothing...
}</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>
<P>The JAXP TransformerFactory is configurable. The API supports configuring
the
factory to: (1) use attributes which are passed down to the underlying XSL
processor,
these are vendor dependent, (2) register an ErrorListener that provides
callbacks
to handle error and warning message generated by the XSL processor, (3)
register
an URIResolver which can be used to resolve URIs encountered in xsl:include,
xsl:import,anddocument() functions.</P>
<P>The JAXP TransformerFactory can be queried at runtme to discover what
features
it supports. For example, an application might want to know if a particular
factory
implementation supports the use of SAX events as a source, or whether it can
write
out transformation results as a DOM. The factory API queries with the
getFeature()
method. In the Proto code above, I could add the following code before the
try-catch
block:</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>if
(!(factory.getFeature(StreamSource.FEATURE)) ||
!(factory.getFeature(StreamResult.FEATURE))) {
System.err.println(
"Stream Source/Result not supported by Transformer
Factory\n" +
"exiting.");
System.exit(1);
}</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="integrate"><!--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>Translet Integration</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>The crux of the integration strategy is the pluggable TransformerFactory
class. The
JAXP specifies that the actual TransformerFactory implementation be
controlled by the
a Java system property (javax.xml.transformer.TransformerFactory) . This
system property can be specified in the usual ways, for
example in a properties file or on the command line as a -D optionpassed to
thejava
engine itself. The strategy involves writing a TransformerFactory for
Translets.
In the JAXP the TransformerFactory is an abstract class. In Xalan, the system
property specifies the implementation class TransformerFactoryImpl
(org.apache.xalan.processor.TransformerFactoryImpl).
This implementation is an extension of the abstract SAXTransformerFactory
class, which in
turn is an extension of the abstract TransformerFactory class
(javax.xml.transform.sax.SAXTransformerFactory).</P>
<P>In this prototype integration I have constructed an XSLTC
TransformerFactory as
an extension of the abstract SAXTransformerFactory class.</P>
</FONT></TD></TR></TABLE><BR><A name="factory"><!--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>SAXTransformerFactory for Translets</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>The prototype XSLTC TransformerFactory needs to accomplish the
following:</P>
<UL>
<LI><A href="#saxtransformerfactory">Implement the abstract methods of the
SAXTransformerFactory class</A></LI>
<LI><A href="#transformerfactory">Implement the abstract methods of the
TransformerFactory class</A></LI></UL>
<A name="saxtransformerfactory"><!--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>SAXTransformerFactory Methods</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>The methods of the abstract SAXTransformerFactory class have been stubbed
out as
follows.</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>public TemplatesHandler newTemplatesHandler()
{ return null; }
public TransformerHandler newTransformerHandler() { return null; }
public TransformerHandler newTransformerHandler(Source src) {
return null;
}
public TransformerHandler newTransformerHandler(Templates templates) {
return null;
}
public XMLFilter newXMLFilter(Source src) { return null; }
public XMLFilter newXMLFilter(Templates templates) { return null;
}</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>
<P>These stubbed out methods will need to be replaced with real
implementations.</P>
</FONT></TD></TR></TABLE><BR><A name="transformerfactory"><!--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>TransformerFactory Methods</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>The methods of the abstract TransformerFactory class have been stubbed out
as
follows:</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>public ErrorListener getErrorListener() {
return null; }
public void setErrorListener(ErrorListener listener) { }
public Object getAttribute(String name) { return null; }
public void setAttribute(String name, Object value) { }
public boolean getFeature(String name) { return false; }
public URIResolver getURIResolver() { return null; }
public void setURIResolver(URIResolver resolver) { }
public Source getAssociatedStylesheet(Source src, String media,
String title, String charset) { return null; }
public Templates newTemplates(Source xslSrc) throws
TransformerConfigurationException { return null; }
public Transformer newTransformer() throws
TransformerConfigurationException { return null; }</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>
<P>The methods listed above fall into 4 categories: (1) <A
href="#transformcreation">Transform creation</A>,
(2) <A href="#templatescreation">Templates creation</A>, (3) <A
href="#featurediscovery">feature discovery</A>,
and (4) <A href="#limitations">others that will remain unimplemented at this
time</A>.</P>
<A name="transformercreation"><!--anchor--></A>
<TABLE border="0" cellpadding="0" cellspacing="0" width="474"><TR><TD
bgcolor="666699" colspan="2" width="484"><TABLE border="0" cellpadding="0"
cellspacing="0" width="474"><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="472"><IMG border="0"
height="1" hspace="0" src="resources/void.gif" vspace="0" width="472"></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="472"><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>Transformer Creation</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="472"><IMG border="0" height="1" hspace="0"
src="resources/void.gif" vspace="0" width="472"></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"> </TD><TD
width="464"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>The JAXP specifies a method that takes the stylesheet as a Source object
and returns a
Transformer.</P>
<P><CODE><FONT face="courier, monospaced">public Transformer
newTransformer(Source xslSrc)</FONT></CODE></P>
<P>This method needs to return a Transformer to comply with the JAXP API, but
also
needs to return a Translet. In the XSLTC/Xalan API, a Translet is an
interface that is
implemented by the runtime abstract class AbstractTranslet
(org.apache.xalan.xsltc.Translet and
org.apache.xalan.xsltc.runtime.AbstractTranslet, repectively). Therefore, I had
to
change the AbstractTranslet class so that it will extend the abstract
Transformer
class while still implementing the Translet interface. Once this is done,
then the
newTransformer() method of the new TransformerFactory can return a Translet
that
is a Transformer.</P>
<P>In order to have AbstractTranslet extend Transformer, several abstract
methods
have to be implemented in AbstractTranslet class. These are:</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>public void clearParameters() { }
public ErrorListener getErrorListener() { return null; }
public Properties getOutputProperties() throws IllegalArgumentException {
return null;
}
public String getOutputProperty(String name)
throws IllegalArgumentException{ return ""; }
//public Object getParameter(String name) { return null; }
public URIResolver getURIResolver() { return null; }
public void setErrorListener(ErrorListener listener)
throws IllegalArgumentException { }
public void setOutputProperties(Properties props)
throws IllegalArgumentException { }
public void setOutputProperty(String name, String value)
throws IllegalArgumentException { }
public void setParameter(String name, Object value) { }
public void setURIResolver(URIResolver resolver) { }
public void transform(Source xmlsrc, Result outputTarget)
throws TransformerException { ... }</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>
<P>Mapping these methods to some existing ones in AbstractTranslet still has
to be
done. In particular the transform() method which is explained further in a
following
section.</P>
<P>Now that XSLTCbstractTranslet is a Transformer, the new Transformer
factory class can implement the newTransformer() method. This method needs to
do
two fundamental things: (1) create a translet from the given XSLT stylesheet
and (2)
instantiate the translet so it can be returned as a Transformer.</P>
<P>The code belows hows my current implementation of the newTransformer()
method
in the new factory class:</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>public class ToddsTransformerFactoryImpl
extends SAXTransformerFactory {
...
public Transformer newTransformer(Source stylesheet) throws
TransformerConfigurationException
{
XSLTC xsltc = new XSLTC();
xsltc.init();
String stylesheetName = stylesheet.getSystemId();
int index = stylesheetName.indexOf(;
String transletName = stylesheetName.substring(0,index);
boolean isSuccessful = true;
try {
File file = new File(stylesheetName);
URL url = file.toURL();
isSuccessful = xsltc.compile(url);
} catch (MalformedURLException e) {
throw new TransformerConfigurationException(
"URL for stylesheet stylesheetName +
"n not be formed.");
}
if (!isSuccessful) {
throw new TransformerConfigurationException(
"Compilation of stylesheet stylesheetName +
"iled.");
}
Translet translet = null;
try {
Class clazz = Class.forName(transletName);
translet = (Translet)clazz.newInstance();
((AbstractTranslet)translet).setTransletName(transletName);
} catch (ClassNotFoundException e) {
throw new TransformerConfigurationException(
"Translet class transletName + "t
found.");
} catch (InstantiationException e) {
throw new TransformerConfigurationException(
"Translet class transletName +
"uld not be instantiated");
} catch (IllegalAccessException e) {
throw new TransformerConfigurationException(
"Translet class transletName + "uld not be
accessed.");
}
return (AbstractTranslet)translet;
}
}</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="templatescreation"><!--anchor--></A>
<TABLE border="0" cellpadding="0" cellspacing="0" width="474"><TR><TD
bgcolor="666699" colspan="2" width="484"><TABLE border="0" cellpadding="0"
cellspacing="0" width="474"><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="472"><IMG border="0"
height="1" hspace="0" src="resources/void.gif" vspace="0" width="472"></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="472"><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>Templates Creation</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="472"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0"
width="472"></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"> </TD><TD
width="464"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>The JAXP specifies a method that takes the stylesheet as a Source object
and returns a
Templates object.</P>
<P><CODE><FONT face="courier, monospaced">public Templates
newTemplates(Source xslSrc)</FONT></CODE></P>
<P>To implement this method I needed to create a new class that would be a
Templates
for Translets object. The new class TransletTemplates
(org.apache.xalan.xsltc.runtime.TransletTemplates) implements the Templates
interface as is shown below:</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>package org.apache.xalan.xsltc.runtime;
import javax.xml.transform.Templates;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.sax.SAXTransformerFactory;
import org.apache.xalan.xsltc.runtime.AbstractTranslet;
import java.util.Properties;
public class TransletTemplates implements Templates {
public TransletTemplates(Transformer translet) {
_translet = (AbstractTranslet)translet;
}
public Properties getOutputProperties() { /*TBD*/ return null; }
public Transformer newTransformer() throws
TransformerConfigurationException
{
if (_translet == null) {
throw new TransformerConfigurationException(
"Error: Null Translet");
}
return _translet;
}
private AbstractTranslet _translet = null;
}</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>
<P>The factory method newTemplates() simply creates a Transformer for the
stylesheet,
and returns a newTransletTemplates object. The implementation of
newTemplates()
is shown below:</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>public class TransformerFactoryImpl extends
SAXTransformerFactory {
...
public Templates newTemplates(Source stylesheet) throws
TransformerConfigurationException
{
Transformer translet = newTransformer(stylesheet);
return new TransletTemplates(translet);
}
}</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>
<P>This implementation only satisfies the JAXP, it does not address caching
of previously
created translets. This type of mechanism belongs in Templates,where a given
stylesheet will be compiled one time only, but the generated translet can be
cloned to
create multiple instances upon demand.</P>
</FONT></TD></TR></TABLE><BR><A name="featurediscovery"><!--anchor--></A>
<TABLE border="0" cellpadding="0" cellspacing="0" width="474"><TR><TD
bgcolor="666699" colspan="2" width="484"><TABLE border="0" cellpadding="0"
cellspacing="0" width="474"><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="472"><IMG border="0"
height="1" hspace="0" src="resources/void.gif" vspace="0" width="472"></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="472"><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>Feature Discovery</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="472"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0"
width="472"></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"> </TD><TD
width="464"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>The JAXP specifies a method that allows programs to discover what features
the factory
is capable of supporting.</P>
<P><CODE><FONT face="courier, monospaced">public boolean getFeature(String
featureName)</FONT></CODE></P>
<P>At this time the new transformer factory supports Stream sources and
results, and
the SAX Transform factory feature. The getFeature() implementation is shown
below:</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>public class TransformerFactoryImpl extends
SAXTransformerFactory {
...
public boolean getFeature(String name) {
if ((StreamSource.FEATURE == name) ||
(StreamResult.FEATURE == name) ||
(SAXTransformerFactory.FEATURE == name)) {
return true;
} else if ((StreamSource.FEATURE.equals(name))
|| (StreamResult.FEATURE.equals(name))
|| (SAXTransformerFactory.FEATURE.equals(name))) {
return true;
} else {
return false;
}
}
}</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>
<P>As the other features are implemented, this methods will need to be
updated.</P>
</FONT></TD></TR></TABLE><BR><A name="limitations"><!--anchor--></A>
<TABLE border="0" cellpadding="0" cellspacing="0" width="474"><TR><TD
bgcolor="666699" colspan="2" width="484"><TABLE border="0" cellpadding="0"
cellspacing="0" width="474"><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="472"><IMG border="0"
height="1" hspace="0" src="resources/void.gif" vspace="0" width="472"></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="472"><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>Limitations</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="472"><IMG
border="0" height="1" hspace="0" src="resources/void.gif" vspace="0"
width="472"></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"> </TD><TD
width="464"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>As you can see, the prototype will compile the stylesheet everytime. This
obviously
needs to be smarter. This is where the question ������I already have this
translet?������eds
to be answered. Also for now the translet bytecodes are written out to a File
in the current
working directory, and then instantiated using a Class.forName, newInstance()
pair. This also needs work. Note the return statement, the Translet is cast
to an AbstractTranslet
which now is a Transformer.</P>
</FONT></TD></TR></TABLE><BR>
</FONT></TD></TR></TABLE><BR>
</FONT></TD></TR></TABLE><BR><A name="transform"><!--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>AbstractTransletransform()
Method</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>Now the JAXP program (Proto) shown in the first section has a way to get a
Transformer
factory that can return Translets. The next step of the Proto.java program is
calling the transform() method and having the Translet process the given XML
document.</P>
<P>This requires some surgery in the AbstractTranslet class again. The
AbstractTranslet
already has a transform() method, but its signature is not the same as the
JAXP Transform signature. In the AbstractTranslet, transform methods expect a
DOM
argument, in some cases a NodeIterator, and a TransletOutputHandler argument.
The
JAXP Transformransform() signature requires only the XML document as a
Source
object reference and an outputTarget as a Result object reference. My
implementation
of the JAXP transform() signature is as shown:</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>public void transform(Source xmlsrc, Result
outputTarget)
throws TransformerException
{
doTransform( xmlsrc.getSystemId(),
((StreamResult)outputTarget).getOutputStream() );
}</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>
<P>This implementation leverages code derived from XSLTCefaultRun class.
In
that class there is a doTransform() method that carries out the work of: (1)
parsing the
input XML document (using a JAXP SAXParserFactory and SAXParser), (2) creating
a DOMImpl (org.apache.xalan.xsltc.dom.DOMImpl), (3) creating a
SAXOutputHandler, and finally (4) calling the translet to
transform the input XML document (from the DOMImpl).</P>
<P>The code for doTransform is shown below:</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>public abstract class AbstractTranslet extends
Transformer implements Translet{
...
private void doTransform(String xmlDocName, OutputStream ostream) {
try {
final Translet translet = (Translet)this; // GTM added
// Create a SAX parser and get the XMLReader object it uses
final SAXParserFactory factory = SAXParserFactory.newInstance();
final SAXParser parser = factory.newSAXParser();
final XMLReader reader = parser.getXMLReader();
// Set the DOMOM builder as the XMLReaderAX2 content handler
final DOMImpl dom = new DOMImpl();
reader.setContentHandler(dom.getBuilder());
// Create a DTD monitor and pass it to the XMLReader object
final DTDMonitor dtdMonitor = new DTDMonitor();
dtdMonitor.handleDTD(reader);
dom.setDocumentURI(xmlDocName);
/****************
if (_uri)
reader.parse(xmlDocName);
else
*******************/
reader.parse("file:"+(new
File(xmlDocName).getAbsolutePath()));
// Set size of key/id indices
setIndexSize(dom.getSize());
// If there are any elements with ID attributes, build an index
dtdMonitor.buildIdIndex(dom, 0, this);
setUnparsedEntityURIs(dtdMonitor.getUnparsedEntityURIs());
// Transform the document
String encoding = translet.getOutputEncoding();
if (encoding == null) encoding = "UTF-8";
//TextOutput textOutput = new TextOutput(System.out, encoding);
DefaultSAXOutputHandler saxHandler = new
DefaultSAXOutputHandler(ostream, encoding);
TextOutput textOutput = new TextOutput(saxHandler, encoding);
translet.transform(dom, textOutput);
textOutput.flush();
}
catch (TransletException e) {
...
}
catch (RuntimeException e) {
...
}
catch (FileNotFoundException e) {
...
}
catch (MalformedURLException e) {
...
}
catch (UnknownHostException e) {
...
}
catch (Exception e) {
...
}
}
}</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="conclusion"><!--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>Conclusion</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<P>This is the current state of the integration of Translet and TrAX. The
JAXP program
illustrated in the first section (Proto.java) compiles and runs with the
changes outlined
above. The new transformer factory TransformerFactoryImpl supports
transformer,
templates creation, and the feature discovery mechanism. The transformers
returned from the factory are in fact AbstractTranslet objects. The new class
TransletTemplates implements the Templates interface for translets. This is
the
result of a first pass implementation, there are many stubbed out methods
that need to
be implemented, translet caching in Templates needs to be implemented and
support
for Source and Result types beyond simple stream types, such as DOM and
SAX.</P>
</FONT></TD></TR></TABLE><BR><A name="appendix"><!--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>Appendix</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"> </TD><TD
width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
<UL>
<LI><A href="#runscript">The Run script</A></LI>
<LI><A href="#transformerfactoryimpl">TransformerFactoryImpl.java</A></LI>
<LI><A href="#TransletTemplates">TransletTemplates.java</A></LI>
<LI><A href="#makefile">The Makefile</A></LI>
</UL>
<A name="runscript"><!--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>The Run script</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<P>By changing the FAC variable I can switch between the two Transformer
factory implementations
for testing.</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>#!/bin/ksh
JAXP=/usr/local/jaxp-1.1/jaxp.jar
CRIMSON=/usr/local/jaxp-1.1/crimson.jar
XSLT=/net/bigblock/files18/tmiller/xml-xalan/java/build/classes
XML=/net/bigblock/files18/tmiller/xml-xalan/java/bin/xml.jar
BCEL=/net/bigblock/files18/tmiller/xml-xalan/java/bin/BCEL.jar
JCUP=/net/bigblock/files18/tmiller/xml-xalan/java/bin/java_cup.jar
JCUPRT=/net/bigblock/files18/tmiller/xml-xalan/java/bin/runtime.jar
CLASSPATH=${JAXP}:${CRIMSON}:${XSLT}:${XML}:${BCEL}:${JCUP}:${JCUPRT}:.
FAC=org.apache.xalan.xsltc.runtime.TransformerFactoryImpl
#FAC=org.apache.xalan.processor.TransformerFactoryImpl
java -classpath ${CLASSPATH} \
-Djavax.xml.transform.TransformerFactory=${FAC} \
Proto $@</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="transformerfactoryimpl"><!--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>TransformerFactoryImpl.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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<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>package org.apache.xalan.xsltc.runtime;
import javax.xml.transform.Templates;
import javax.xml.transform.Transformer;
import javax.xml.transform.ErrorListener;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.URIResolver;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.sax.TemplatesHandler;
import javax.xml.transform.sax.TransformerHandler;
import org.xml.sax.XMLFilter;
import org.apache.xalan.xsltc.Translet;
import org.apache.xalan.xsltc.compiler.XSLTC;
import org.apache.xalan.xsltc.runtime.AbstractTranslet;
import java.io.File;
import java.net.URL;
import java.net.MalformedURLException;
/**
* Implementation of a JAXP1.1 SAXTransformerFactory for Translets.
*/
public class TransformerFactoryImpl extends SAXTransformerFactory {
public TransformerFactoryImpl() { /* nothing yet */ }
//////////////////////////////////////////////////////
// SAXTransformerFactory (subclass of TransformerFactory)
//
public TemplatesHandler newTemplatesHandler() { /*TBD*/ return null; }
public TransformerHandler newTransformerHandler() { /*TBD*/ return null; }
public TransformerHandler newTransformerHandler(Source src) {
/*TBD*/ return null;
}
public TransformerHandler newTransformerHandler(Templates templates) {
/*TBD*/ return null;
}
public XMLFilter newXMLFilter(Source src) { /*TBD*/ return null; }
public XMLFilter newXMLFilter(Templates templates) { /*TBD*/ return null; }
//
// End SAXTransformerFactory methods
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
// TransformerFactory
//
public ErrorListener getErrorListener() { /*TBD*/ return null; }
public void setErrorListener(ErrorListener listener) {/*TBD*/ }
public Object getAttribute(String name) { /*TBD*/ return null; }
public void setAttribute(String name, Object value) { /*TBD*/ }
public boolean getFeature(String name) {
if ((StreamSource.FEATURE == name) ||
(StreamResult.FEATURE == name) ||
(SAXTransformerFactory.FEATURE == name)) {
return true;
} else if ((StreamSource.FEATURE.equals(name))
|| (StreamResult.FEATURE.equals(name))
|| (SAXTransformerFactory.FEATURE.equals(name))) {
return true;
} else {
return false;
}
}
public URIResolver getURIResolver() { /*TBD*/ return null; }
public void setURIResolver(URIResolver resolver) {/*TBD*/ }
public Source getAssociatedStylesheet(Source src, String media,
String title, String charset) { /*TBD*/ return null; }
public Transformer newTransformer() throws
TransformerConfigurationException { /*TBD*/ return null; }
//
// End TransformerFactory methods
//////////////////////////////////////////////////////
public Transformer newTransformer(Source stylesheet) throws
TransformerConfigurationException
{
XSLTC xsltc = new XSLTC();
xsltc.init();
String stylesheetName = stylesheet.getSystemId();
int index = stylesheetName.indexOf(;
String transletName = stylesheetName.substring(0,index);
boolean isSuccessful = true;
try {
File file = new File(stylesheetName);
URL url = file.toURL();
isSuccessful = xsltc.compile(url);
} catch (MalformedURLException e) {
throw new TransformerConfigurationException(
"URL for stylesheet stylesheetName +
"n not be formed.");
}
if (!isSuccessful) {
throw new TransformerConfigurationException(
"Compilation of stylesheet stylesheetName +
"iled.");
}
Translet translet = null;
try {
Class clazz = Class.forName(transletName);
translet = (Translet)clazz.newInstance();
((AbstractTranslet)translet).setTransletName(transletName);
} catch (ClassNotFoundException e) {
throw new TransformerConfigurationException(
"Translet class transletName + "t
found.");
} catch (InstantiationException e) {
throw new TransformerConfigurationException(
"Translet class transletName +
"uld not be instantiated");
} catch (IllegalAccessException e) {
throw new TransformerConfigurationException(
"Translet class transletName + "uld not be
accessed.");
}
return (AbstractTranslet)translet;
}
public Templates newTemplates(Source stylesheet) throws
TransformerConfigurationException
{
Transformer translet = newTransformer(stylesheet);
return new TransletTemplates(translet);
}
}</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="translettemplates"><!--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>TransletTemplates.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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<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>package org.apache.xalan.xsltc.runtime;
import javax.xml.transform.Templates;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.sax.SAXTransformerFactory;
import org.apache.xalan.xsltc.runtime.AbstractTranslet;
import java.util.Properties;
/**
* Implementation of a JAXP1.1 Templates object for Translets.
*/
public class TransletTemplates implements Templates {
public TransletTemplates(Transformer translet) {
_translet = (AbstractTranslet)translet;
}
public Properties getOutputProperties() { /*TBD*/ return null; }
public Transformer newTransformer() throws
TransformerConfigurationException
{
if (_translet == null) {
throw new TransformerConfigurationException(
"Error: Null Translet");
}
return _translet;
}
private AbstractTranslet _translet = null;
}</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="makefile"><!--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>The Makefile</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"> </TD><TD
width="474"><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<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>JAXP=/usr/local/jaxp-1.1/jaxp.jar
CRIMSON=/usr/local/jaxp-1.1/crimson.jar
XSLT=/net/bigblock/files18/tmiller/xml-xalan/java/build/classes
CLASSPATH=${JAXP}:${CRIMSON}:${XSLT}
SRCS=\
Proto.java
all:
javac -classpath ${CLASSPATH} ${SRCS}</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>
</FONT></TD></TR></TABLE><BR>
</TD></TR></TABLE></TD></TR></TABLE><BR><TABLE border="0" cellpadding="0"
cellspacing="0" width="620"><TR><TD bgcolor="#0086b2"><IMG height="1"
src="images/dot.gif" width="1"></TD></TR><TR><TD align="center"><FONT
color="#0086b2" size="-1"><I>
Copyright © 2001 The Apache Software Foundation.
All Rights Reserved.
</I></FONT></TD></TR></TABLE></BODY></HTML>
1.1
xml-site/targets/xalan-j/xsltc/graphics/ext-40-label-1.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/ext-40-label-2.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/ext-40-label-3.jpg
<<Binary file>>
1.1 xml-site/targets/xalan-j/xsltc/graphics/index-header.jpg
<<Binary file>>
1.1 xml-site/targets/xalan-j/xsltc/graphics/index-label-1.jpg
<<Binary file>>
1.1 xml-site/targets/xalan-j/xsltc/graphics/index-label-2.jpg
<<Binary file>>
1.1 xml-site/targets/xalan-j/xsltc/graphics/index-label-3.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsl_comment_design-header.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsl_comment_design-label-1.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsl_comment_design-label-2.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsl_comment_design-label-3.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsl_key_design-header.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsl_key_design-label-1.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsl_key_design-label-2.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsl_key_design-label-3.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsl_lang_design-header.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsl_lang_design-label-1.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsl_lang_design-label-2.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsl_lang_design-label-3.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsl_sort_design-header.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsl_sort_design-label-1.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsl_sort_design-label-2.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsl_sort_design-label-3.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsl_unparsed_design-header.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsl_unparsed_design-label-1.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsl_unparsed_design-label-2.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsl_unparsed_design-label-3.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsl_whitespace_design-header.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsl_whitespace_design-label-1.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsl_whitespace_design-label-2.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsl_whitespace_design-label-3.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsltc_compiler-header.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsltc_compiler-label-1.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsltc_compiler-label-2.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsltc_compiler-label-3.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsltc_dom-header.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsltc_dom-label-1.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsltc_dom-label-2.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsltc_dom-label-3.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsltc_namespace-header.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsltc_namespace-label-1.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsltc_namespace-label-2.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsltc_namespace-label-3.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsltc_runtime-header.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsltc_runtime-label-1.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsltc_runtime-label-2.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsltc_runtime-label-3.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsltc_trax-header.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsltc_trax-label-1.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsltc_trax-label-2.jpg
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/graphics/xsltc_trax-label-3.jpg
<<Binary file>>
1.1 xml-site/targets/xalan-j/xsltc/images/DOMInterface.gif
<<Binary file>>
1.1 xml-site/targets/xalan-j/xsltc/images/all_namespaces.gif
<<Binary file>>
1.1 xml-site/targets/xalan-j/xsltc/images/cast_expression.gif
<<Binary file>>
1.1 xml-site/targets/xalan-j/xsltc/images/compiler_AST.gif
<<Binary file>>
1.1 xml-site/targets/xalan-j/xsltc/images/compiler_DOM.gif
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/images/compiler_architecture.gif
<<Binary file>>
1.1 xml-site/targets/xalan-j/xsltc/images/dom_namespace1.gif
<<Binary file>>
1.1 xml-site/targets/xalan-j/xsltc/images/dom_namespace2.gif
<<Binary file>>
1.1 xml-site/targets/xalan-j/xsltc/images/dom_namespace3.gif
<<Binary file>>
1.1 xml-site/targets/xalan-j/xsltc/images/key_relations.gif
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/images/match_namespace1.gif
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/images/match_namespace2.gif
<<Binary file>>
1.1 xml-site/targets/xalan-j/xsltc/images/namespace_stack.gif
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/images/output_namespaces1.gif
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/images/output_namespaces2.gif
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/images/runtime_architecture.gif
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/images/runtime_type_mapping.gif
<<Binary file>>
1.1 xml-site/targets/xalan-j/xsltc/images/sort_objects.gif
<<Binary file>>
1.1 xml-site/targets/xalan-j/xsltc/images/type_mappings.gif
<<Binary file>>
1.1 xml-site/targets/xalan-j/xsltc/images/typecast.gif
<<Binary file>>
1.1 xml-site/targets/xalan-j/xsltc/resources/bottom.gif
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/resources/button-asf-hi.gif
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/resources/button-asf-lo.gif
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/resources/button-w3c-hi.gif
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/resources/button-w3c-lo.gif
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/resources/button-xml-hi.gif
<<Binary file>>
1.1
xml-site/targets/xalan-j/xsltc/resources/button-xml-lo.gif
<<Binary file>>
1.1 xml-site/targets/xalan-j/xsltc/resources/close.gif
<<Binary file>>
1.1 xml-site/targets/xalan-j/xsltc/resources/dot.gif
<<Binary file>>
1.1 xml-site/targets/xalan-j/xsltc/resources/join.gif
<<Binary file>>
1.1 xml-site/targets/xalan-j/xsltc/resources/line.gif
<<Binary file>>
1.1 xml-site/targets/xalan-j/xsltc/resources/logo.gif
<<Binary file>>
1.1 xml-site/targets/xalan-j/xsltc/resources/note.gif
<<Binary file>>
1.1 xml-site/targets/xalan-j/xsltc/resources/right.gif
<<Binary file>>
1.1 xml-site/targets/xalan-j/xsltc/resources/script.js
Index: script.js
===================================================================
rolloverImagesOn=new Array();
rolloverImagesOff=new Array();
function rolloverOn(name) {
if(rolloverImagesOn[name]){
document.images[name].src=rolloverImagesOn[name].src;
}
}
function rolloverOff(name) {
if(rolloverImagesOff[name]){
document.images[name].src=rolloverImagesOff[name].src;
}
}
function rolloverLoad(name,on,off) {
rolloverImagesOn[name]=new Image();
rolloverImagesOn[name].src=on;
rolloverImagesOff[name]=new Image();
rolloverImagesOff[name].src=off;
}
1.1 xml-site/targets/xalan-j/xsltc/resources/separator.gif
<<Binary file>>
1.1 xml-site/targets/xalan-j/xsltc/resources/void.gif
<<Binary file>>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]