5 Since the version number of 0.96 Sablotron supports a debugging of
6 stylesheets. Although it is just an experimental state, it works quite
7 fine, and may be found useful by many XSLT developers.
11 !!! Important change, read this !!!
13 The Sablotron library is dual-licensed. You may choose either of MPL
16 Optionally the debugger command line interface uses a great GNU library
17 'readline'. This library may not be linked to non GPL'ed programs, so
18 if you want to use the debugger, you have to choose the GPL from
19 Sablotron license model.
21 See the *Building* section, how to do it.
25 For short, all you need is to pass the --enable-debugger to the
26 configure script. If you want to use the readline library (what is
27 great), read the detailed description.
29 To enable the debugger, you need meed following:
31 1. Optionally you may install ``readline'' and ``ncurses'' libraries
32 of GNU. (nice systems have it by default) and make it available to
33 the compiler and linker (you may use CPLUS_INCLUDE_PATH and
34 LIBRARY_PATH environment).
36 2. If you want to use the readline library, you have to confirm, that
37 you accept the GPL license terms. You do it with setting the
38 SABLOT_GPL environment to whatever else then empty string. You need
39 set this variable when the configure script is ran (later it is not
42 3. You have to add the --enable-debugger to the configure script.
44 4. Optionally you may set the --with-readline too.
46 That should be enough.
50 Run 'sabcmd --debugger'. That's all.
54 You may trace, how your templates are executing. The only point, where
55 the debugger may stop the execution is the element start.
59 The first thing, you need to do is to specify the stylesheet and the
60 data file. Use the `sheet' and `data' commands for it.
62 If you want to set external parameters (for top level <xsl:param>
63 elements) use the `param' command.
65 ** Running the Transformation
67 Use the `run' command to fire the processor. A new processor instance
68 is created for any new round.
70 If the debugger stooped at the breakpoint, you may use the `cont'
71 command to run further.
73 You may use the `templ' command to run the processor and stop in the
74 first template called.
76 If you want to kill currently running transformation, use the `kill'
79 ** Setting Breakpoints
81 You may use the `break' command to set the breakpoint. Processor then
82 stops on marked line every time it hits it.
84 There are some issues:
86 - breakpoint must be set at the line with the element start
88 Another command are `B' - list all breakpoints and `D' delete all
91 You may toggle a breakpoint enabled/disabled with the `disable'
94 You may set a XPath expression for the breakpoint, what is evaluated
95 each time the breakpoint is met. The breakpoint takes an effect only
96 if this expression is true.
98 ** Walking Trough the Source
100 You may use the `step' command to move to the next element start.
102 You may use the `next` command to move to the next sibling of the
105 You may use the `finish' command to move to the next sibling of the
106 parent of the current element.
121 The arrow marks, where you are. In this case
125 `finish' - goes to <x>
127 The very special (and very useful) command id the `templ'
128 command. This one continues the execution, until any template is
129 executed. It may be used to run the transformation as well as to resume
134 You may evaluate any XPath expression using the `eval' command. It
135 evaluates in the current context and displays the result and its type.
137 ** Examinig the Context
139 You may examine the current context with the `x' command.
142 x all - list all context nodes
143 x n - detailed info on the n-th context node (n is an integer)
147 You may create files containing the sequences of you favorite commands
148 (one per line) and execute them with the `batch' command
152 You need to type as few letters to specify the command as is needed to
153 recognize, what you mean. The most frequent command may be run with
154 single command not caring, whether another command starts with this
155 letter. The `s' abbrev runs the `step' command rather the `sheet'.
159 There is an Emacs library available. You may use it, if you want to
160 debug your stylesheets and see, what is happening.
162 You need to grab the sabdbg.el from the Sablotron source tree.
164 Next you need to put something like this into your .emacs file:
169 The sabdbg-set-keys function should be called the best from some hook
170 for your favorite xsl mode.
172 We use the xml-mode (part of psgml-mode). My .emacs looks like this:
174 (add-hook 'xml-mode-hook
177 (when (string-match "\\.xsl$" buffer-file-name))
180 As the result several keys should be mapped locally in you buffers for
183 (local-set-key [(control c)(control g)(control x)] 'sabdbg-debug-current)
184 (local-set-key [(control c)(control g)(control s)] 'sabdbg-step)
185 (local-set-key [(control c)(control g)(control n)] 'sabdbg-next)
186 (local-set-key [(control c)(control g)(control t)] 'sabdbg-step-template)
187 (local-set-key [(control c)(control g)(control c)] 'sabdbg-continue)
188 (local-set-key [(control c)(control g)(control p)] 'sabdbg-show-point)
189 (local-set-key [(control c)(control g)(control b)] 'sabdbg-set-breakpoint)
190 (local-set-key [(control c)(control g)(control r)] 'sabdbg-run)
192 E.g. while you are in the buffer holding the XSL file, you may press
193 and hold control and press `c' `g' `x' sequence to execute the
194 debugger and set the current buffer file name as the stylesheet.
196 Next you need to use the `data' command in the debugger buffer, switch
197 back to the stylesheet and continue debugging using mapped keys.
200 opens debugger for current buffer (only one debugger may be ran at once
206 preform the `next' command
209 perform the `templ' command
212 continues the execution
215 synchronize file displayed with debugger
217 sabdbg-set-breakpoint
218 sets breakpoint to file and line, where currently the point is