Steve Ball'\" Copyright (c) 2002 Zveno Pty Ltd



RCS: @(#) $Id: tclxslt.diff,v 1.2 2004/08/20 18:39:36 tpeterso Exp $

The definitions below are for supplemental macros used in Tcl/Tk
manual entries.

.AP type name in/out ?indent?
Start paragraph describing an argument to a library procedure.
type is type of argument (int, etc.), in/out is either "in", "out",
or "in/out" to describe whether procedure reads or modifies arg,
and indent is equivalent to second arg of .IP (shouldn't ever be
needed; use .AS below instead)

.AS ?type? ?name?
Give maximum sizes of arguments for setting tab stops. Type and
name are examples of largest possible arguments that will be passed
to .AP later. If args are omitted, default tab stops are used.

.BS
Start box enclosure. From here until next .BE, everything will be
enclosed in one large box.

.BE
End of box enclosure.

.CS
Begin code excerpt.

.CE
End code excerpt.

.VS ?version? ?br?
Begin vertical sidebar, for use in marking newly-changed parts
of man pages. The first argument is ignored and used for recording
the version when the .VS was added, so that the sidebars can be
found and removed when they reach a certain age. If another argument
is present, then a line break is forced before starting the sidebar.

.VE
End of vertical sidebar.

.DS
Begin an indented unfilled display.

.DE
End of indented unfilled display.

.SO
Start of list of standard options for a Tk widget. The
options follow on successive lines, in four columns separated
by tabs.

.SE
End of list of standard options for a Tk widget.

.OP cmdName dbName dbClass
Start of description of a specific option. cmdName gives the
option's name as specified in the class command, dbName gives
the option's name in the option database, and dbClass gives
the option's class in the option database.

.UL arg1 arg2
Print arg1 underlined, then print arg2 normally.

RCS: @(#) $Id: tclxslt.diff,v 1.2 2004/08/20 18:39:36 tpeterso Exp $

# Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
.nr ^l \n(.l # Start an argument description
. ie !"\\$2"" .TP \\n()Cu . el .TP 15 .\} \\$1 \\\$2\ (\\$3) .b
.\}

\\$1 \\\$2\ .\} \\\$1\ .\} .\} .. # define tabbing values for .AP
.nr )A 10n .nr )B \\n()Au+15n
.nr )C \\n()Bu+\\w'(in/out)'u+2n .. .AS Tcl_Interp Tcl_CreateInterp in/out # BS - start boxed text
# ^y = starting y location
# ^b = 1

^y .nr ^b 1u .. # BE - end boxed text (draw box now)

^t Draw four-sided box normally, but don't draw top of
box if the box started on an earlier page.
\h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .\}

.nr ^b 0 .. # VS - start vertical sidebar
# ^Y = starting y location
# ^v = 1 (for troff; for nroff this doesn't matter)

^Y .. # VE - end of vertical sidebar
.ev 2

^t \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'

.ev .\} .nr ^v 0 .. # Special macro to handle page bottom: finish off current
# box/sidebar if in box/sidebar mode, then invoked standard
# page bottom macro.
.ev 2 'ti 0 'nf

^t Draw three-sided box if this is the box's first page,
draw two sides but no top otherwise.
.\} .nr ^x \\n(^tu+1v-\\n(^Yu \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c .\} .bp 'fi .ev

^y .nr ^b 2 .\}

^Y .\} .. # DS - begin display

..
 # DE - end display
.. # SO - start of list of standard options
"STANDARD OPTIONS"

..
 # SE - end of list of standard options

See the \options\ manual entry for details on the standard options. .. # OP - start of full description for a single option

Command-Line Name: \\\$1\
Database Name: \\\$2\
Database Class: \\\$3\
.. # CS - begin code excerpt

..
 # CE - end code excerpt
.. \\$1\l'|0\(ul'\\$2 ..
TclXSLT n Tcl "Tcl Built-In Commands"
S Note: do not modify the .SH NAME line immediately below!
NAME
::xslt::compile -
SYNOPSIS
package require xslt xslt2.5 ::xslt ::xslt::compile doc ssheet method ? option value ... ? ? args ... ? ::xslt::extensionadd nsuri tcl-namespace E
DESCRIPTION

TclXSLT is a wrapper for the that allows an application to perform XSL transformations (XSLT). The package also provides a binding to the XSLT extension mechanism so that XSLT extension may be implemented using Tcl scripts.

Transformation only works with documents created by TclDOM/libxml2.

The TclXSLT package makes extensive use of Tcl objects. Compiled XSL stylesheets are stored as the internal representation of a Tcl object. Source and result documents are accessed via TclDOM's C interface as Tcl objects. This allows the application to cache parsed XML documents and compiled XSL stylesheets for better runtime performance.

PACKAGES AND NAMESPACES

The TclXSLT package defines the package and also a Tcl namespace using that name.

COMMANDS

::xslt::compile

The ::xslt::compile command pre-compiles a stylesheet document. It returns a compiled stylesheet object and also defines a Tcl command to access the stylesheet. This Tcl command may be used to transform XML documents.

NB. It is advisable to use the -baseuri option when parsing the source and stylesheet documents to allow external resources to be resolved.

Stylesheet Command

The stylesheet command created by ::xslt::compile command accesses a compiled stylesheet.

Following is an example of how to use the stylesheet transform method.

Command Methods

The following command methods may be used:

cget option

Returns the value of an option. See below for the list of valid options.

configure optionvalue

Sets the value of an option. Available options are as follows:

transform source ? name value?

Performs an XSL transformation on the given source document. Stylesheet parameters may be specified as name-value pairs. The return result is the DOM token for the result document.

Stylesheet Parameters

Any number of name-value pairs may be specified as arguments to the stylesheet transform method. These are passed as values for parameters in the stylesheet. interprets the values as XPath expressions, where the context node is the root node for the source document. To pass a value as a string it must be XPath-quoted, for example

.CS set library "Gnome libxslt" $ssheet transform $source_doc \ library '$library' \ author "'Daniel Veillard'" \ node {/*/Element[3]} .CE

::xslt::extension

The ::xslt::extension command is used to manage extensions of the library. The add is used to register an extension. The remove is used to unregister an extension. See for more detail.

EXTENSIONS

The TclXSLT package allows an application to bind Tcl scripts to the extension mechanism of . This means that Tcl scripts may provide the implementation of an XSLT extension element or function. The binding is achieved to associating a Tcl namespace with an XML namespace.

Implementing An Extension

The Tcl application uses the ::xslt::extension add command to register an extension. An XML Namespace for the extension is specified as an argument, along with a Tcl namespace that will provide implementations of extension elements and functions. For example,

Everytime the ::xslt::transform command is executed, a newly-created XSLT engine is initialized. For each registered extension, every procedure in the associated Tcl namespace is defined in the XSLT engine as either an extension element or an extension function. The procedure is defined as an extension function if it has a variable argument list, otherwise it is defined as an extension element. The procedure name is used as the local part of the extension name. For example,

"myfunc" is defined as an extension function and "myelement" is defined as an extension element.

Extension Functions

The arguments to an extension function are converted to a string value and then passed as parameters to the Tcl procedure.

The return result of the Tcl procedure becomes the return value of the extension function. The type of the result is preserved where possible, otherwise it is converted to a string value.

Extension Elements

Extension elements have not been implemented in TclXSLT v1.1.

Using An Extension

To invoke an extension in an XSL stylesheet, use the normal XSLT extension mechanism. The XML Namespace matches the extension to the registered Tcl namespace (NB. the stylesheet author is free to choose any prefix for the extension namespace). For example,

This stylesheet would result in the following Tcl script being evaluated: