# Sablotron Guide and Reference

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 ]

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