Sablotron Guide and Reference

Debugging XSLT .General

Summary

Sablotron can be used as XSLT debugger.

Syntax

These commands can be used from the debugger command line:

Processed data:
   data filename        - sets the data file
   param name value     - sets the external parameter
   P                    - lists all params
   PP                   - clears all params
   sheet filename       - sets the stylesheet
Breakpoints:
   break filename:line  - sets the breakpoint
   bstat                - shows breakpoint stats (total/enabled/break)
   B                    - lists all breakpoints
   condition num cond   - for the breakpoint NUM sets the condition COND
   del num              - deletes the breakpoint NUM
   disable num          - toggles the breakpoint number NUM
   D                    - deletes all breakpoints
   ignore num count     - ignores the breakpoint NUM for COUNT times
Execution control:
   continue             - continues the execution
   finish               - finishes the current node parent
   kill                 - stops the processing immediately
   next                 - goes to the next sibling
   run                  - runs the processor
   step                 - continues until the next element
   templ                - continues until the next template executed
Evaluation:
   eval                 - evaluates the XPath expression
   x [list | num]       - examines the current context
Miscellaneous:
   batch filename       - loads the command set for file
   help                 - prints this help
   output               - toggles output on/off
   point                - shows where you are
   quit                 - quites the debugger

Description

Run 'sabcmd --debugger' to invoke the debugger. Then, you can trace execution of your templates. The only point, where the debugger can stop the execution is the element start.

Notes

Abbreviations
You need to type as few letters to specify the command as is needed to recognize, what you mean. The most frequent command may be run with single letter not caring, whether another command starts with this letter. The `s' abbrev runs the `step' command rather the `sheet'.

Emacs Integration
There is an Emacs library available. You may use it to debug your stylesheets in Emacs directly. You need to grab the sabdbg.el from the Sablotron source tree and to add a couple of lines into your .emacs file. Look at doc/misc/DEBUGGER file in Sablotron distribution for more details.

See Also

Groups [ .General ]

Dependencies .General

Summary

Third-party libraries that must be or can be linked to Sablotron.

Description

Expat - an XML parser Sablotron depends on. This is the only MANDATORY dependence. Sablotron looks for Expat during the configuration. Expat is a standard part of many operating systems and is available for all systems where Sablotron can run. Expat is distributed under the MIT license.

Iconv - a GNU encoding library you need if you want to use more encodings/charsets than these supported by Sablotron internally. See .Encodings for more details. Sablotron looks for Iconv during the configuration but it still compiles when not found. Iconv is a standard part of many operating systems and is available for all systems where Sablotron can run. Iconv is released under the terms of the GNU LGPL license.

JavaScript - JS C (SpiderMonkey) engine by Mozilla is needed to run XSLT extension function. See .Extensions for details. Linking JavaScript is optional (./configure --enable-javascript). JS engine is available for all systems where Sablotron can run. Mozilla's C implementation of JavaScript is distributed under the terms of the MPL license.

Readline - a GNU library providing the XSLT debugger with functions to easily work with the command line. You may want to link Readline if you compile Sablotron with XSLT debugger (./configure --enable-debugger --with-readline). Without Readline, the debugger still works, but you can't use user-friendly features such as the command-line history. Readline is distributed under the GNU GPL license, thus you must use Sablotron under the GPL (this is one of two possible alternatives, see .License for details) if you want to link Readline. Export SABLOT_GPL=1 environment in order to express your decision.

See Also

Groups [ .General ]
Documents [ Readline | Expat | Iconv | JavaScript ]
Entries [ .Encodings | .Extensions | .License ]

Encodings .Implementation Notes

Summary

Sablotron supports a number of input/output encodings and charsets; either internally or through the iconv library.

Description

Sablotron handles encoding conversions with the help of iconv library. As a standard part of glibc, iconv is automatically available on many Unix-based systems (including Linux). It's available for most other platforms where Sablotron runs (Windows, Solaris, MacOS X, FreeBSD, etc). See .Dependencies for more details on iconv.

With iconv installed on your system, you can use any encoding it supports (that is, almost any encoding whatsoever) for both the input and the output documents.

If iconv is not available, encodings may still be supported internally by Sablotron. At present, the list is of such encodings is rather short: UTF-8, UTF-16, ASCII, iso-8859-1, iso-8859-2 and windows-1250 on input, UTF-8 only on output.

Lastly, a user has the option to implement a custom encoding conversion handler, which will be asked to perform any unsupported conversion. See .Handlers for details.

The default input and output encoding is in all cases UTF-8.

See Also

Groups [ .Implementation Notes ]
Entries [ .Dependencies | .Handlers ]

Errors and logs .Implementation Notes

Summary

Sablotron writes error and warning messages to stderr, and does no logging by default, but this behavior can be changed.

Description

The name of the log file to be used can be specified with SablotSetLog. Besides, you can use SablotRegHandler to override the default message handling. The handler you register will receive all messages in a structured form that's easy to process and filter. For details, see .Handlers.

See Also

Groups [ .Implementation Notes ]
Entries [ .Handlers | SablotRegHandler | SablotSetLog ]

Extensions .General

Summary

Sablotron supports a number of EXSLT extensions.

Description

Sablotron recognizes the extension element funct:script (xmlns:funct="http://exslt.org/functions") to run ECMAScript (JavaScript) functions as suggested by EXSLT.org. Extension functions have a read-only DOM access to the main XML document and to node-sets passed as arguments. The implementation follows the ECMAScript/DOM2 Language Binding defined in XSLT 1.1, Appendix C3, and DOM Level2, Appendix E. See Sablotron Extensions API Reference guide to get more details on how to use DOM methods from JS extension functions.

Sablotron also supports exsl:document element (xmlns:exsl="http://exslt.org/common") to produce multiple output documents.

In addition to the standard output methods (xml, html and text), it is possible to output xhtml. Documents output using this method obey the XHTML 1.0 rules (in particular, all empty elements are closed). To choose the method, use xsl:output method='xhtml'.

See Also

Groups [ .General ]
Documents [ EXSLT.org | Extensions API Reference | DOM Level2 | XSLT 1.1 ]

Handlers .Implementation Notes

Summary

It is possible for the user to supply the following handlers to Sablotron.

Description

message handler - to bypass the default way of displaying error and warning messages and logging,
scheme handler - to retrieve documents whose URI use an unsupported scheme,
streaming handler - an expat-like interface to the XML document which is the result of the processing,
encoding handler - to handle an unsupported encoding
'miscellaneous' handler - which will probably serve as a collections of odd callbacks.

The handlers are set using SablotRegHandler. For details concerning the interface of these handlers, consult the header files sablot.h and shandler.h.

See Also

Groups [ .Implementation Notes ]
Entries [ SablotRegHandler ]

Introduction .General

Summary

Sablotron is an XML processor implementing XPath 1.0, XSLT 1.0 and DOM Level2. It also includes some other features such as XSLT debugger, SXP (access to external documents via callbacks) or EXSLT support.

Description

Sablotron is a single shared library written in C++ (sablot.dll or libsablot.so.x.xx). It provides a native C API; APIs for Perl, PHP, Python, Ruby and other languages are available through wrappers (not part of the Sablotron project). See gingerall.org for more information on Sablotron wrappers. Sablotron can also be used from the command line via a simple interface called sabcmd.

Sablotron implements the following W3C recommendations: XPath 1.0, XSLT 1.0 and DOM Level2. See .Known Issues for details on deviations from the specs. Go to .Sablotron DOM for more information on Sablotron DOM Level 2 interface.

Sablotron also includes an XPath Processor (SXP) working with virtual DOM objects accessed via user-defined (DOM-like) callback functions. The C API to SXP is described in a separate SXP Reference guide.

A relevant subset of EXSLT extensions is supported by Sablotron. See .Extensions for details.

Third-party libraries Sablotron depends on and libraries that can be linked by Sablotron optionally are listed in .Dependencies.

The latest Sablotron sources can be downloaded from gingerall.org. For instructions on how to build the sources, refer to the accompanying INSTALL file. The gingerall.org site also includes links to other documentation, FAQs, mailing lists, CVS, bugzilla, lxr and other Sablotron-related resources. Sablotron is an open source project and everyone is invited to join it.

See Also

Groups [ .General ]
Documents [ gingerall.org | SXP Reference | DOM Level2 | XPath 1.0 | XSLT 1.0 ]
Entries [ .Dependencies | .Extensions | .Known Issues | .Sablotron DOM | sabcmd ]

Known Issues .General

Summary

There are some known minor distinctions from W3C specifications.

Description

XPath 1.0
* id() function not implemented.

XSLT 1.0
* embedded stylesheets don't work,
* some illegal operations with RTFs are allowed,
* case-order attribute of xsl:sort not supported.

DOM Level2
* Document.docElementsByTagName not implemented,
* Document.docElementsByTagNameNS not implemented,
* node name lists may be accessed with the item() function only not as array items,
* NamedNodeMap.getNamedItemsNS not implemented.

Other issues:
* the 'xhtml' output method is different from what is suggested in XSLT 2.0 WD,
* all parameters must be passed in utf-8 encoded.

See Also

Groups [ .General ]
Documents [ DOM Level2 | XPath 1.0 | XSLT 1.0 ]

License .General

Summary

Sablotron licensing terms and Copyright

Description

Sablotron is subject to the Mozilla Public License Version 1.1 (the MPL). Alternatively, Sablotron may be used under the terms of the GNU General Public License Version 2 or later (the GPL), in which case the provisions of the GPL are applicable instead of those of the MPL.

The Sablotron project has been originated and is maintained by Ginger Alliance. Portions created by Ginger Alliance are Copyright Ginger Alliance, s.r.o. Portions created by other contributors are Copyright of these contributors. All rights are reserved.

See Also

Groups [ .General ]
Documents [ GPL | MPL ]

Named buffers .Implementation Notes

Summary

Sablotron can store XML strings and parsed trees to so called named buffers.

Description

Sablotron introduces an URI scheme 'arg:' which enables one to use strings and parsed trees in named memory buffers. Named buffers are can be set using SablotAddArgBuffer or SablotAddArgTree functions. The content of buffers can be accessed with the document() function or xsl:include/import instructions (e.g. document('arg:/my_buffer')/root).

The buffer names can have a tree-like structure so that a relative reference from a document in a buffer can be resolved as pointing to another buffer.

For instance, if we invoke Sablotron specifying that a buffer named /mybuf/1 contains the string "<a>contents</a>", then the expression document('arg:/mybuf/1')/a has string-value "contents". If the document in arg:/mybuf/1 contained a relative URI reference "../theirbuf/2" then this would be resolved as pointing to "arg:/theirbuf/2".

See Also

Groups [ .Implementation Notes ]
Entries [ SablotAddArgBuffer | SablotAddArgTree ]

Sablotron DOM DOM

Summary

Sablotron implements DOM Level2 API.

Description

This book contains a brief description of the implemented interface only; for more details, please refer to the header file named sdom.h.

Sablotron DOM interface includes types (see DOM types) and functions (see DOM functions). All of the names related to the DOM interface start with SDOM_ (for Sablot DOM).

As Sablotron provides a C API for the object-oriented Document Object Model, you can't not expect the API follows the DOM specs literally. Instead, it maps object methods to plain functions, one to one usually. This arrangement makes it possible to write the specs compliant object oriented wrappers over the Sablotron DOM API. XML::Sablotron::DOM written in Perl is the primary example. See .Known Issues for the list of minor deviations from the DOM Level 2 specs.

See Also

Groups [ DOM ]
Documents [ DOM Level2 ]
Entries [ .Known Issues | DOM functions | DOM types ]

URIs .Implementation Notes

Summary

Sablotron can handle two URI schemes natively: 'file' and 'arg'.

Description

Only two URI schemes are built-in: 'file' and 'arg' (see .Named buffers). Moreover, it is possible to use the function SablotRegHandler to register an external scheme handler which will receive requests in all other schemes. See .Handlers and sablot.h and shandler.h files for details.

Relative URI references are resolved in conformance to RFC 2396. The base URI is well defined when the relative reference appears inside a XML document; when invoking sabcmd, the base URI is taken to correspond to the current working directory.

When specifying filenames, the following rules are in effect:
* specify the "file:" scheme for any standard files, i.e. refer to stdin as file://stdin etc.
* slashes and backslashes work equally fine, in Windows as well as Linux.
* to include a drive letter under Windows (e.g. C:\doc.xml), it is necessary to say file://c:/doc.xml.

See Also

Groups [ .Implementation Notes ]
Entries [ .Handlers | .Named buffers | SablotRegHandler | sabcmd ]

Usage .General

Summary

Examples of how to use the native API of Sablotron.

Syntax

EXAMPLE 1: a simple transformation

SablotSituation S;
SablotHandle proc;

SablotCreateSituation(&S);
SablotCreateProcessorForSituation(S, &proc);

SablotRunProcessorGen(S, proc, "my_sheet.xsl", "my_data.xml", "arg:/out");

char * result;
SablotGetResultArg(proc, "arg:/out", &result);

...

SablotFree(result);
SablotDestroyProcessor(proc);
SablotDestroySituation(S);

EXAMPLE 2: a transformation with reusable parsed trees

SablotSituation S;
SablotHandle proc;
SDOM_Document xsl, xml;

SablotCreateSituation(&S);
SablotParseStylesheetBuffer(S, my_xsl_ptr, &xsl);
SablotParseBuffer(S, my_xml_ptr, &xml);

SablotCreateProcessorForSituation(S, &proc);
SablotAddArgTree(S, proc, "sheet", xsl);
SablotAddArgTree(S, proc, "data", xml);

SablotRunProcessorGen(S, proc, "arg:/sheet", "arg:/data", "arg:/out");

char * result;
SablotGetResultArg(proc, "arg:/out", &result);

...

SablotFree(result);
SablotDestroyDocument(xsl);
SablotDestroyDocument(xml);
SablotDestroyProcessor(proc);
SablotDestroySituation(S);

Description

The first example shows the simplest way to run a transformation with two files. The second example parses trees explicitly and makes them available for further processing. In this example, the source XML document and the XSLT stylesheet are already loaded in strings (my_xsl_ptr, my_xml_ptr). To work with URIs, use SablotParseStylesheet and SablotParse instead of SablotParseStylesheetBuffer and SablotParseBuffer.

See Also

Groups [ .General ]
Entries [ SablotParse | SablotParseBuffer | SablotParseStylesheet | SablotParseStylesheetBuffer ]

DOM functions DOM

Summary

Functions introduced by .Sablotron DOM Level 2 interface.

Description

The functions listed below are implemented as defined in the DOM Level 2 specification, with two exceptions: their names are prefixed with SDOM_ and the first argument is always a SablotSituation. All the functions return a value of SDOM_Exception type. The functions aren't described in details as they correspond to well known DOM methods. Please, look to sdom.h for more details.

createElement, createElementNS, createAttribute, createAttributeNS, createTextNode, createCDATASection, createComment, createProcessingInstruction

getNodeType, getNodeName, getNodeNSUri, getNodePrefix, getNodeLocalName, setNodeName, getNodeValue, setNodeValue

getParentNode, getFirstChild, getLastChild, getPreviousSibling, getNextSibling, getChildNodeIndex, getChildNodeCount, getOwnerDocument

insertBefore, appendChild, removeChild, replaceChild

cloneNode

getAttribute, getAttributeNS, getAttributeNode, getAttributeNodeNS, getAttributeNodeIndex, getAttributeNodeCount, setAttribute, setAttributeNS, setAttributeNode, setAttributeNodeNS, removeAttribute, removeAttributeNode, getAttributeElement, getAttributeList

Several functions have been added:

disposeNode frees all memory used by the given node.

cloneForeignNode clones a node from a different document.

docToString serializes the document, returning the resulting string.

nodeToString serializes a node (and its descendants), returning the resulting string.

xql performs an XPath query on the DOM tree, returning a list of the nodes satisfying the query.

In addition, there are some functions used to manipulate the node lists returned by xql and getAttributeList functions. These include getNodeListLength, getNodeListItem and disposeNodeList.

Finally, there are functions to extract DOM exception-related information from the situation object, namely getExceptionCode, getExceptionMessage and getExceptionDetails.

See Also

Groups [ DOM ]
Entries [ .Sablotron DOM ]

DOM types DOM

Summary

Types introduced by .Sablotron DOM Level 2 interface.

Description

Major new types are SDOM_Document (a DOM tree) and SDOM_Node (a node of the tree). A document can also be used in place of a node. This corresponds to the DOM spec, Document is a subclass of Node. When used in this way, the document represents its own root node (which is not the same as the `root element' aka 'document element').

Other types include:

SDOM_char: a DOM character type. Currently, this is just char. Note that the DOM spec requires that the DOM implementations work with UTF-16. Sablotron deviates from this by using UTF-8 instead.

SDOM_NodeType: a node type enum. Some of the values are SDOM_ELEMENT_NODE, SDOM_ATTRIBUTE_NODE and SDOM_TEXT_NODE. See sdom.h for the rest.

SDOM_NodeList: a node list returned by some of the functions.

SDOM_Exception: DOM exception codes enum, with values such as SDOM_NOT_FOUND_ERR or SDOM_INVALID_NODE_TYPE. See sdom.h for details.

See Also

Groups [ DOM ]
Entries [ .Sablotron DOM | SDOM_Document ]

EncHandler Types

Summary

This type is used to provide the Sablotron engine with a callback structure for an encoding handler.

Syntax

       typedef EHDescriptor 
       EncHandlerOpen(void* userData, 
           SablotHandle processor_,
           int direction, const char *encoding);

       typedef EHResult 
       EncHandlerConv(void* userData, SablotHandle processor_,
           EHDescriptor cd, const char** inbuf, size_t *inbytesleft,
           char ** outbuf, size_t *outbytesleft);

       typedef int 
       EncHandlerClose(void* userData, SablotHandle processor_,
           EHDescriptor cd);

       typedef struct
       {
           EncHandlerOpen      *open;
           EncHandlerConv      *conv;
           EncHandlerClose     *close;
       } EncHandler;

Notes

See the shandler.h file for more comments.

See Also

Groups [ Types ]

MessageHandler Types

Summary

This type is used to provide the Sablotron engine with a callback structure for a message handler.

Syntax

       typedef MH_ERROR 
       MessageHandlerMakeCode(
           void *userData, SablotHandle processor_,
           int severity, unsigned short facility, unsigned short code);

       typedef MH_ERROR 
       MessageHandlerLog(
           void *userData, SablotHandle processor_,
           MH_ERROR code, MH_LEVEL level, char **fields);

       typedef MH_ERROR 
       MessageHandlerError(void *userData, SablotHandle processor_,
           MH_ERROR code, MH_LEVEL level, char **fields);

       typedef struct
       {
           MessageHandlerMakeCode *makeCode;
           MessageHandlerLog *log;
           MessageHandlerError *error;
       } MessageHandler;

Notes

See the shandler.h file for more comments.

See Also

Groups [ Types ]

MiscHandler Types

Summary

This type is used to provide the Sablotron engine with a callback structure for a custom handler.

Syntax

       typedef void
       MiscHandlerDocumentInfo(void* userData, SablotHandle processor_,
           const char *contentType, const char *encoding);

       typedef struct
       {
           MiscHandlerDocumentInfo     *documentInfo;
       } MiscHandler;

Notes

See the shandler.h file for more comments.

See Also

Groups [ Types ]

SAXHandler Types

Summary

This type is used to provide the Sablotron engine with a callback structure for a SAX handler.

Syntax

       typedef SAX_RETURN 
       SAXHandlerStartDocument(void* userData, SablotHandle processor_);

       typedef SAX_RETURN 
       SAXHandlerStartElement(void* userData, SablotHandle processor_,
           const char* name, const char** atts);

       typedef SAX_RETURN 
       SAXHandlerEndElement(void* userData, SablotHandle processor_,
           const char* name);

       typedef SAX_RETURN 
       SAXHandlerStartNamespace(void* userData, SablotHandle processor_,
           const char* prefix, const char* uri);

       typedef SAX_RETURN 
       SAXHandlerEndNamespace(void* userData, SablotHandle processor_,
           const char* prefix);

       typedef SAX_RETURN 
       SAXHandlerComment(void* userData, SablotHandle processor_,
           const char* contents);

       typedef SAX_RETURN 
       SAXHandlerPI(void* userData, SablotHandle processor_,
           const char* target, const char* contents);

       typedef SAX_RETURN 
       SAXHandlerCharacters(void* userData, SablotHandle processor_,
           const char* contents, int length);

       typedef SAX_RETURN 
       SAXHandlerEndDocument(void* userData, SablotHandle processor_);


       typedef struct
       {
           SAXHandlerStartDocument     *startDocument;
           SAXHandlerStartElement      *startElement;
           SAXHandlerEndElement        *endElement;
           SAXHandlerStartNamespace    *startNamespace;
           SAXHandlerEndNamespace      *endNamespace;
           SAXHandlerComment           *comment;
           SAXHandlerPI                *processingInstruction;
           SAXHandlerCharacters        *characters;
           SAXHandlerEndDocument       *endDocument;
       } SAXHandler;

Notes

This is not a real SAX interface; think about it as about a SAX-like interface. See the shandler.h file for more comments.

See Also

Groups [ Types ]

SDOM_Document Types

Summary

Handle for manipulation of Sablotron DOM documents.

Syntax

typedef void *SDOM_Document;

Description

You may use this type, if you need to deal with Sablotron internal representation of the XML data model. There is a DOM-like set of functions defined for such manipulation in the sdom.h file.

See Also

Groups [ Types ]

SablotAddArgBuffer Functions

Summary

Adds a buffer containing the XML data as the named argument.

Syntax

int SablotAddArgBuffer(SablotSituation S,
       void *processor_,
       const char *argName,
       const char *bufferValue);
NameTypeDescription
SSablotSituationSituation handle
processor_void*Processor handle
argNameconst char*argument name
bufferValueconst char*XML data

Description

This API adds the named buffer to the list of arguments maintained by the processor instance. Named arguments may be used either while the processed data are specified (e.g. in SablotRunProcessorGen or in the document() XSLT function.

See Also

Groups [ Functions ]
Entries [ SablotAddArgTree | SablotRunProcessorGen | SablotSituation ]

SablotAddArgTree Functions

Summary

Adds the pre-parsed tree as the named argument.

Syntax

int SablotAddArgTree(SablotSituation S,
       void *processor_,
       const char *argName,
       SDOM_Document tree);
NameTypeDescription
SSablotSituationSituation handle
processor_void*Processor handle
argNameconst char*argument name
treeSDOM_Documenttree handle

Description

This function adds the named pre-parsed tree to the list of arguments maintained by the processor instance. Named arguments may be used either while the processed data are specified (e.g. in SablotRunProcessorGen or in the document() XSLT function.

See Also

Groups [ Functions ]
Entries [ SDOM_Document | SablotAddArgBuffer | SablotRunProcessorGen | SablotSituation ]

SablotAddParam Functions

Summary

Sets the value of the parameter for the processing.

Syntax

int SablotAddParam(SablotSituation S,
       void *processor_,
       const char *paramName,
       const char *paramValue);
NameTypeDescription
SSablotSituationSituation handle
processor_void*Processor handle
paramNameconst char*parameter name
paramValueconst char*parameter value

Description

Use this function if you need to set the external parameter for the upcoming processing (for the top-level ).

Notes

Currently the parameter value MUST be UTF-8 encoded.

See Also

Groups [ Functions ]
Entries [ .Usage | SablotRunProcessorGen | SablotSituation ]

SablotClearError Functions

Summary

Clears the 'pending error' flag.

Syntax

int SablotClearError(SablotHandle processor_);
NameTypeDescription
processor_SablotHandledesc

Description

Clears the 'pending error' flag for this instance of Sablotron.

See Also

Groups [ Functions ]
Entries [ SablotHandle ]

SablotClearSituation Functions

Summary

Clears the status of the situation.

Syntax

int SablotClearSituation(SablotSituation S);
NameTypeDescription
SSablotSituationsituation handle

Description

Clear all error info stored with the situation.

See Also

Groups [ Functions ]
Entries [ SablotSituation ]

SablotCreateDocument Functions

Summary

Creates a new DOM document.

Syntax

int SablotCreateDocument(SablotSituation S, 
       SDOM_Document *D);
NameTypeDescription
SSablotSituationSituation handle
DSDOM_Document*The new handle goes here

Description

The returned handle may be used to manipulate the internal DOM document with the set of API defined in the sdom.h file.

See Also

Groups [ Functions ]
Entries [ SDOM_Document | SablotSituation ]

SablotCreateProcessor Functions

Summary

Creates the processor object.

Syntax

int SablotCreateProcessor(SablotHandle *processorPtr);
NameTypeDescription
processorPtrSablotHandle*the result goes here

Description

This API creates the processor instance. See .Usage for the details to be done.

Notes

This function is slightly obsoleted with SablotCreateProcessorForSituation, since we suppose you'd prefer the situation object recently created with SablotCreateSituation.

See Also

Groups [ Functions ]
Entries [ .Usage | SablotCreateProcessorForSituation | SablotCreateSituation | SablotHandle ]

SablotCreateProcessorForSituation Functions

Summary

Creates the processor instance and associate it with the situation object.

Syntax

int SablotCreateProcessorForSituation(SablotSituation S,
       void **processorPtr);
NameTypeDescription
SSablotSituationsituation handle
processorPtrvoid**the result goes here

Description

Use this function if you want to create a processor instance and associate it with the given situation object. This call is preferred over SablotCreateProcessor.

See Also

Groups [ Functions ]
Entries [ SablotCreateProcessor | SablotSituation ]

SablotCreateSituation Functions

Summary

Creates a situation object handle.

Syntax

int SablotCreateSituation(SablotSituation *sPtr);
NameTypeDescription
sPtrSablotSituation*the result goes here

Description

This call creates a situation object. This object servers for several reasons like error processing, option settings etc. Most of API functions take the situation handle as their first parameter.

See Also

Groups [ Functions ]
Entries [ .Usage | SablotSituation ]

SablotDestroyDocument Functions

Summary

Frees the internal document and all resources.

Syntax

int SablotDestroyDocument(SablotSituation S,
       SDOM_Document D);
NameTypeDescription
SSablotSituationSituation object
DSDOM_Documentdocument to be destroyed

Description

This function frees the internal document representation and all resources allocated.

See Also

Groups [ Functions ]
Entries [ SDOM_Document | SablotSituation ]

SablotDestroyProcessor Functions

Summary

Destroys the processor object.

Syntax

int SablotDestroyProcessor(SablotHandle processor_);
NameTypeDescription
processor_SablotHandleProcessor handle

Description

Destroys processor and all associated resources.

See Also

Groups [ Functions ]
Entries [ SablotHandle ]

SablotDestroySituation Functions

Summary

Destroys the situation object.

Syntax

int SablotDestroySituation(SablotSituation S);
NameTypeDescription
SSablotSituationdesc

Description

Destroys the situation object. You should call this function as the very last call.

See Also

Groups [ Functions ]
Entries [ SablotSituation ]

SablotFree Functions

Summary

SablotFree frees the buffer formerly allocated by the engine.

Syntax

int SablotFree(char *resultStr);
NameTypeDescription
resultStrchar*desc

Description

Use the SablotFree function whenever you finish a work with a Sablotron generated API. Typically, do it after the SablotrGetResultArg is called. Some DOM-access functions allocate buffers too.

See Also

Groups [ Functions ]

SablotFreeResultArgs Functions

Summary

Frees all internal result arguments.

Syntax

int SablotFreeResultArgs(SablotHandle processor_);
NameTypeDescription
processor_SablotHandleprocessor handle

Description

This call frees all memory associated with the output of the most recent transformation. You don't have to make this call, destroying the processor takes care as well as new transformation invocation.

See Also

Groups [ Functions ]
Entries [ SablotHandle ]

SablotGetInstanceData Functions

Summary

SablotGetInstanceData reads the user data stored with processor recently with SablotSetInstanceData

Syntax

void *SablotGetInstanceData(SablotHandle processor_);
NameTypeDescription
processor_SablotHandledesc

Description

SablotGetInstanceData

See Also

Groups [ Functions ]
Entries [ SablotHandle | SablotSetInstanceData ]

SablotGetMsgText Functions

Summary

SablotGetMsgText return a constant pointer to the message for the given error code.

Syntax

const char *SablotGetMsgText(int code);
NameTypeDescription
codeintdesc

Description

The value returned is typically a format string (contains C ``printf'' formatting specifiers). You need more info (code dependent) to get a full message).

See Also

Groups [ Functions ]

SablotGetOptions Functions

Summary

Get current procesor options.

Syntax

int SablotSetOptions(SablotSituation S,
       int flag);
NameTypeDescription
SSablotSituationSituation handle

Description

Options may be any bitwise combination of following:

SAB_NO_ERROR_REPORTING (0x1) suppresses the invocation of the messages handler (if registered)

SAB_PARSE_PUBLIC_ENTITIES (0x2) makes parser to resolve public external entities

SAB_DISABLE_ADDING_META (0x4) suppresses the generation of the META tag (HTML output method)

SAB_DISABLE_STRIPPING (0x8) suppresses the whitespace stripping (on data files only)

SAB_IGNORE_DOC_NOT_FOUND (0x10) doesn't consider unresolved documents (the document() function) to be lethal

SAB_FILES_TO_HANDLER (0x20) doesn't read 'file' URI internally, but pass it into the scheme handler

SAB_DUMP_SHEET_STRUCTURE (0x40) writes a stylesheet structure (hierarchy of includes and imports) into the log

SAB_NO_EXTERNAL_ENTITIES (0x80) doesn't parse any external entities

See Also

Groups [ Functions ]
Entries [ SablotSituation ]

SablotGetResultArg Functions

Summary

Gets the result argument.

Syntax

int SablotGetResultArg(SablotHandle processor_,
       const char *argURI,
       char* *argValue);
NameTypeDescription
processor_SablotHandleProcessor handle
argURIconst char*argument name
argValuechar**the result goes here

Description

This API is used to pull the data output to the 'arg:' scheme URI location. This happens during the transformation e.g. with SablotRunProcessorGen

This function allocates new buffer for you. You have to free its memory with SablotFree, after you use it no more.

See Also

Groups [ Functions ]
Entries [ SablotFree | SablotHandle | SablotRunProcessorGen ]

SablotHandle Types

Summary

Defines the basic abstract handle for manipulation of Sablotron internals.

Syntax

typedef void *SablotHandle;

Description

Actually this type is the void*, but you should never rely on this.

See Also

Groups [ Types ]

SablotLockDocument Functions

Summary

Lock the document before the processing.

Syntax

int SablotLockDocument(SablotSituation S,
       SDOM_Document D);
NameTypeDescription
SSablotSituationSituation object
DSDOM_Documentdocument to be locked

Description

Actually this function doesn't perform any locking in the common sense of the word, but updates some internal values needed for the processing.

Notes

You SHOULD call this function whenever you changed the DOM document before the processing. You don't need this, if you just parsed the document (no modification).

See Also

Groups [ Functions ]
Entries [ SDOM_Document | SablotSituation ]

SablotParse Functions

Summary

Parses a XML file into the internal structure.

Syntax

int SablotParse(SablotSituation S,
       const char *uri,
       SDOM_Document *D);
NameTypeDescription
SSablotSituationSituation handle
uriconst char*URI of the file
DSDOM_Document*The new handle goes here

Description

Sablotron parses the document given by the URI and sets the D to a new handle value. Returns FALSE on success.

See Also

Groups [ Functions ]
Entries [ SDOM_Document | SablotSituation ]

SablotParseBuffer Functions

Summary

Parses a XML string into the internal structure.

Syntax

int SablotParseBuffer(SablotSituation S,
       const char *buffer,
       SDOM_Document *D);
NameTypeDescription
SSablotSituationSituation handle
bufferconst char*string to be parsed
DSDOM_Document*The node handle goes here

Description

Sablotron parses given string and creates a new document handle. The last parameter obtains the handle. Function returns FALSE on success.

See Also

Groups [ Functions ]
Entries [ SDOM_Document | SablotSituation ]

SablotParseStylesheet Functions

Summary

Parses a XSLT stylesheet from file.

Syntax

int SablotParseStylesheet(SablotSituation S,
       const char *uri,
       SDOM_Document *D);
NameTypeDescription
SSablotSituationSituation handle
uriconst char*data URI
DSDOM_Document*The result goes here

Description

Does the same as SablotParse, but document parsed with this function may be used as the stylesheet for the XSLT processing.

Notes

You should not modify a document created by this function, if you want to use it for the processing. It might (and probably would) lead to the processor crash.

See Also

Groups [ Functions ]
Entries [ SDOM_Document | SablotParse | SablotSituation ]

SablotParseStylesheetBuffer Functions

Summary

Parses a XSLT stylesheet from a buffer.

Syntax

int SablotParseStylesheetBuffer(SablotSituation S,
       const char *buffer,
       SDOM_Document *D);
NameTypeDescription
SSablotSituationSituation handle
bufferconst char*XML string
DSDOM_Document*The result goes here

Description

Does the same as SablotParseBuffer, but document parsed with this function may be used as the stylesheet for the XSLT processing.

Notes

You should not modify a document created by this function, if you want to use it for the processing. It might (and probably would) lead to the processor crash.

See Also

Groups [ Functions ]
Entries [ SDOM_Document | SablotParseBuffer | SablotSituation ]

SablotProcess Functions Deprecated

Summary

SablotProcess

Syntax

int SablotProcess(const char *sheetURI,
       const char *inputURI,
       const char *resultURI,
       const char* *params,
       const char* *arguments,
       char* *resultArg);
NameTypeDescription
sheetURIconst char*desc
inputURIconst char*desc
resultURIconst char*desc
paramsconst char**desc
argumentsconst char**desc
resultArgchar**desc

Description

SablotProcess

See Also

Groups [ Deprecated | Functions ]

SablotProcessFiles Functions Deprecated

Summary

SablotProcessFiles

Syntax

int SablotProcessFiles(const char *styleSheetName,
       const char *inputName,
       const char *resultName);
NameTypeDescription
styleSheetNameconst char*desc
inputNameconst char*desc
resultNameconst char*desc

Description

SablotProcessFiles

See Also

Groups [ Deprecated | Functions ]

SablotProcessStrings Functions Deprecated

Summary

SablotProcessStrings

Syntax

int SablotProcessStrings(const char *styleSheetStr,
       const char *inputStr,
       char* *resultStr);
NameTypeDescription
styleSheetStrconst char*desc
inputStrconst char*desc
resultStrchar**desc

Description

SablotProcessStrings

See Also

Groups [ Deprecated | Functions ]

SablotProcessStringsWithBase Functions Deprecated

Summary

SablotProcessStringsWithBase

Syntax

int SablotProcessStringsWithBase(const char *styleSheetStr,
       const char *inputStr,
       char* *resultStr,
       const char *theHardBase);
NameTypeDescription
styleSheetStrconst char*desc
inputStrconst char*desc
resultStrchar**desc
theHardBaseconst char*desc

Description

SablotProcessStringsWithBase

See Also

Groups [ Deprecated | Functions ]

SablotRegHandler Functions

Summary

Registers new handler.

Syntax

int SablotRegHandler(SablotHandle processor_,
       HandlerType type,
       void *handler,
       void *userData);
NameTypeDescription
processor_SablotHandleprocessor handle
typeHandlerTypehandler type
handlervoid*pointer to the handler struct
userDatavoid*user data

Description

Registers one of available handlers. The handler type is either of HLR_MESSAGE, HLR_SCHEME, HLR_SAX, HLR_MISC, HLR_ENC. The ``handler'' parameter point to the callback structure.

The stucture format depends on the handler sype specified. Possible callbacks structures are:
SchemeHandler, MessageHandler, SAXHandler, MiscHandler, EncHandler.

See .Handlers for more.

See Also

Groups [ Functions ]
Entries [ .Handlers | EncHandler | MessageHandler | MiscHandler | SAXHandler | SablotHandle | SchemeHandler ]

SablotRunProcessor Functions Deprecated

Summary

Runs the XSLT transformation.

Syntax

int SablotRunProcessor(SablotHandle processor_,
       const char *sheetURI,
       const char *inputURI,
       const char *resultURI,
       const char* *params,
       const char* *argument);
NameTypeDescription
processor_SablotHandleprocessor handle
sheetURIconst char*sheet URI
inputURIconst char*data URI
resultURIconst char*result URI
paramsconst char**parameters
argumentconst char**arguments

Description

This API is deprecated and shouldn't be used. Use SablotRunProcessorGen instead.

See Also

Groups [ Deprecated | Functions ]
Entries [ SablotHandle | SablotRunProcessorGen ]

SablotRunProcessorExt Functions

Summary

Runs the processor on the external document.

Syntax

int SablotRunProcessorExt(SablotSituation S,
       void *processor_,
       const char *sheetURI,
       const char *resultURI,
       NodeHandle doc);
NameTypeDescription
SSablotSituationSituation handle
processor_void*Processor handle
sheetURIconst char*stylesheet URI
resultURIconst char*result URI
docNodeHandleexternal root node

Description

This function acts as the SablotRunProcessorGen does. The difference is, that the data processed are provided by the external DOM provider.
See SXP documentation for more details on DOM providers etc.

Notes

Currently there is no way to start the processing on an 'ordinary' document and access the external data via some XSLT function (opposite to the document() function).

See Also

Groups [ Functions ]
Entries [ SablotRunProcessorGen | SablotSituation ]

SablotRunProcessorGen Functions

Summary

Runs the processor.

Syntax

int SablotRunProcessorGen(SablotSituation S,
       void *processor_,
       const char *sheetURI,
       const char *inputURI,
       const char *resultURI);
NameTypeDescription
SSablotSituationSablotron handle
processor_void*Processor handle
sheetURIconst char*stylesheet URI
inputURIconst char*data URI
resultURIconst char*result URI

Description

This call runs the processing on the given data. Data are specified by URIs; what may be either of URI to the file, org the 'arg:' scheme URI (see SablotAddArg). Other URI schemes may be recognized if the appropriate handler is set.

See Also

Groups [ Functions ]
Entries [ .Handlers | .Usage | SablotGetResultArg | SablotSituation ]

SablotSetBase Functions

Summary

Sets base URI.

Syntax

int SablotSetBase(SablotHandle processor_,
       const char *theBase);
NameTypeDescription
processor_SablotHandleprocessor handle
theBaseconst char*base URI

Description

Sets the base URI. All relatives URIs resolved during the processing are evaluated against this one.

See Also

Groups [ Functions ]
Entries [ SablotHandle ]

SablotSetBaseForScheme Functions

Summary

Sets the base URI for given scheme.

Syntax

int SablotSetBaseForScheme(void *processor_,
       const char *scheme,
       const char *base);
NameTypeDescription
processor_void*processor handle
schemeconst char*desc
baseconst char*desc

Description

SablotSetBaseForScheme

See Also

Groups [ Functions ]

SablotSetEncoding Functions

Summary

SablotSetEncoding sets the encoding for the output document.

Syntax

void SablotSetEncoding(SablotHandle processor_,
       char *encoding_);
NameTypeDescription
processor_SablotHandledesc
encoding_char*desc

Description

The encoding set via the SablotSetEncoding call overrides a stylesheet-defined value.

See Also

Groups [ Functions ]
Entries [ SablotHandle ]

SablotSetInstanceData Functions

Summary

SablotSetInstanceData associates user-defined pointer to the processor instance.

Syntax

void SablotSetInstanceData(SablotHandle processor_,
       void *idata);
NameTypeDescription
processor_SablotHandledesc
idatavoid*desc

Description

You may use this call to store any pointer-like value with the processor. You may obtain this value later usinf the SablotGetInstanceData. This is usefull for miscellaneous wrapper implementations etc.

See Also

Groups [ Functions ]
Entries [ SablotGetInstanceData | SablotHandle ]

SablotSetLog Functions

Summary

Sets the log filename.

Syntax

int SablotSetLog(SablotHandle processor_,
       const char *logFilename,
       int logLevel);
NameTypeDescription
processor_SablotHandledesc
logFilenameconst char*desc
logLevelintdesc

Description

The logLevel parameter is currently not used. Pass NULL for logFilename to turn logging off (default).

See Also

Groups [ Functions ]
Entries [ SablotHandle ]

SablotSetOptions Functions

Summary

Sets miscellaneous processing options.

Syntax

int SablotSetOptions(SablotSituation S,
       int flag);
NameTypeDescription
SSablotSituationSituation handle
flagintnew options

Description

Options may be any bitwise combination of following:

SAB_NO_ERROR_REPORTING (0x1) suppresses the invocation of the messages handler (if registered)

SAB_PARSE_PUBLIC_ENTITIES (0x2) makes parser to resolve public external entities

SAB_DISABLE_ADDING_META (0x4) suppresses the generation of the META tag (HTML output method)

SAB_DISABLE_STRIPPING (0x8) suppresses the whitespace stripping (on data files only)

SAB_IGNORE_DOC_NOT_FOUND (0x10) doesn't consider unresolved documents (the document() function) to be lethal

SAB_FILES_TO_HANDLER (0x20) doesn't read 'file' URI internally, but pass it into the scheme handler

SAB_DUMP_SHEET_STRUCTURE (0x40) writes a stylesheet structure (hierarchy of includes and imports) into the log

SAB_NO_EXTERNAL_ENTITIES (0x80) doesn't parse any external entities

See Also

Groups [ Functions ]
Entries [ SablotSituation ]

SablotSituation Types

Summary

Handle for manipulation of the Situation object.

Syntax

typedef void *SablotSituation;

Description

The Situation object is the very basic object you have to deal with. See the .Usage

See Also

Groups [ Types ]
Entries [ .Usage | SablotCreateSituation ]

SablotUnregHandler Functions

Summary

Unregisters the handler.

Syntax

int SablotUnregHandler(SablotHandle processor_,
       HandlerType type,
       void *handler,
       void *userData);
NameTypeDescription
processor_SablotHandleprocessor handle
typeHandlerTypehandler type
handlervoid*handler
userDatavoid*user data

Description

Registers one of available handlers. See .Handlers for more.

See Also

Groups [ Functions ]
Entries [ .Handlers | SablotHandle ]

SchemeHandler Types

Summary

This type is used to provide the Sablotron engine with a callback structure for a scheme handler.

Syntax

       typedef int 
       SchemeHandlerGetAll(void *userData, 
           SablotHandle processor_,
           const char *scheme, const char *rest, 
           char **buffer, int *byteCount);

       typedef int 
       SchemeHandlerFreeMemory(void *userData, 
           SablotHandle processor_,
           char *buffer);

       typedef int 
       SchemeHandlerOpen(void *userData, 
           SablotHandle processor_,
           const char *scheme, 
           const char *rest, int *handle);
       
       typedef int 
       SchemeHandlerGet(void *userData, 
           SablotHandle processor_,
           int handle, char *buffer, int *byteCount);
       
       typedef int 
       SchemeHandlerPut(void *userData, 
           SablotHandle processor_,
           int handle, const char *buffer, int *byteCount);
       
       typedef int 
       SchemeHandlerClose(void *userData, 
           SablotHandle processor_,
           int handle);
       
       typedef struct
       {
           SchemeHandlerGetAll *getAll;
           SchemeHandlerFreeMemory *freeMemory;
           SchemeHandlerOpen *open;
           SchemeHandlerGet *get;
           SchemeHandlerPut *put;
           SchemeHandlerClose *close;
       } SchemeHandler;

Notes

See the shandler.h file for more comments.

See Also

Groups [ Types ]

sabcmd .General

Summary

sabcmd is a command line interface to Sablotron library.

Syntax

sabcmd [options] <stylesheet> [<input> [<output>]] [assignments]
sabcmd [options] -batch-xml <input> [<stylesheet> [<output>]]+ [assignments]
sabcmd [options] -batch-xsl <stylesheet> [<input> [<output>]]+ [assignments]

Description

sabcmd is a command line interface to Sablotron XSLT processor. You can use is to transform XML files with XSLT stylesheets.

The only required parameter is a stylesheet; this is a URI of an XSLT stylesheet to be used for the transformation process. If you omit an input file, the standard input is used. In addition, you can specify an output file. If no output file is given, the output is sent to the standard output.

sabcmd can also run in a batch mode to process single input file with multiple stylesheets (--batch-xml) or to apply a stylesheet to multiple input files (--batch-xsl).

Assignments allow to pass parameters and named buffers to the processor. The assignments have always the form of name1=value1 name2=value2 ... where name is either an ASCII string for named buffers or an ASCII string with the leading '$' sign for parameters. (Note that you need to use the right quotes to prevent the shell interpreter from performing an expansion of variables).

OPTIONS
Option can be of two forms - short or long. If some options have values, the values are separated with a whitespace for short options and with a equal sign ('=') for long options. -L mylog.log is the same as --log-file=mylog.log

COMMON OPTIONS
-x, --batch-xml - multiple stylesheets, single input file
-s, --batch-xsl - multiple input files, single stylesheet
-b, --base=NAME - set the hard base URI to NAME
--debug-options - display the information on debugging options
-?, --help - display this help message
-L, --log-file=NAME - set the log file, turns logging on
-m, --measure - measure the time of processing
-v, --version - display the version information

DEBUG OPTIONS
--debug - display results of the command line parse
-t, --times=COUNT - run sabcmd the specified number of times
-f, --flags - pass flags given to SablotSetOptions()
-F, --use-SPF - use SablotProcessFiles()
-S, --use-SPS - use SablotProcessStrings(). Give 2 args (stylesheet, input). Precede each by @.
--use-SPS-on-files - use SablotProcessStrings() on the contents of the given files.

ENVIRONMENT
When the xsl:sort instruction is used without the 'lang' attribute, common locale related environment variables apply..

See Also

Groups [ .General ]

© 2002-2003 Ginger Alliance
revision 03-06-30
This page was generated by APIDOC