/* * documents.c: Implementation of the documents handling * * See Copyright for the status of this software. * * [email protected] */ #define IN_LIBXSLT #include "libxslt.h" #include <string.h> #include <libxml/xmlmemory.h> #include <libxml/tree.h> #include <libxml/hash.h> #include <libxml/parser.h> #include <libxml/parserInternals.h> #include "xslt.h" #include "xsltInternals.h" #include "xsltutils.h" #include "documents.h" #include "transform.h" #include "imports.h" #include "keys.h" #include "security.h" #ifdef LIBXML_XINCLUDE_ENABLED #include <libxml/xinclude.h> #endif #define WITH_XSLT_DEBUG_DOCUMENTS #ifdef WITH_XSLT_DEBUG #define WITH_XSLT_DEBUG_DOCUMENTS #endif /************************************************************************ * * * Hooks for the document loader * * * ************************************************************************/ /** * xsltDocDefaultLoaderFunc: * @URI: the URI of the document to load * @dict: the dictionary to use when parsing that document * @options: parsing options, a set of xmlParserOption * @ctxt: the context, either a stylesheet or a transformation context * @type: the xsltLoadType indicating the kind of loading required * * Default function to load document not provided by the compilation or * transformation API themselve, for example when an xsl:import, * xsl:include is found at compilation time or when a document() * call is made at runtime. * * Returns the pointer to the document (which will be modified and * freed by the engine later), or NULL in case of error. */ static xmlDocPtr xsltDocDefaultLoaderFunc(const xmlChar * URI, xmlDictPtr dict, int options, void *ctxt ATTRIBUTE_UNUSED, xsltLoadType type ATTRIBUTE_UNUSED) { … } xsltDocLoaderFunc xsltDocDefaultLoader = …; /** * xsltSetLoaderFunc: * @f: the new function to handle document loading. * * Set the new function to load document, if NULL it resets it to the * default function. */ void xsltSetLoaderFunc(xsltDocLoaderFunc f) { … } /************************************************************************ * * * Module interfaces * * * ************************************************************************/ /** * xsltNewDocument: * @ctxt: an XSLT transformation context (or NULL) * @doc: a parsed XML document * * Register a new document, apply key computations * * Returns a handler to the document */ xsltDocumentPtr xsltNewDocument(xsltTransformContextPtr ctxt, xmlDocPtr doc) { … } /** * xsltNewStyleDocument: * @style: an XSLT style sheet * @doc: a parsed XML document * * Register a new document, apply key computations * * Returns a handler to the document */ xsltDocumentPtr xsltNewStyleDocument(xsltStylesheetPtr style, xmlDocPtr doc) { … } /** * xsltFreeStyleDocuments: * @style: an XSLT stylesheet (representing a stylesheet-level) * * Frees the node-trees (and xsltDocument structures) of all * stylesheet-modules of the stylesheet-level represented by * the given @style. */ void xsltFreeStyleDocuments(xsltStylesheetPtr style) { … } /** * xsltFreeDocuments: * @ctxt: an XSLT transformation context * * Free up all the space used by the loaded documents */ void xsltFreeDocuments(xsltTransformContextPtr ctxt) { … } /** * xsltLoadDocument: * @ctxt: an XSLT transformation context * @URI: the computed URI of the document * * Try to load a document (not a stylesheet) * within the XSLT transformation context * * Returns the new xsltDocumentPtr or NULL in case of error */ xsltDocumentPtr xsltLoadDocument(xsltTransformContextPtr ctxt, const xmlChar *URI) { … } /** * xsltLoadStyleDocument: * @style: an XSLT style sheet * @URI: the computed URI of the document * * Try to load a stylesheet document within the XSLT transformation context * * Returns the new xsltDocumentPtr or NULL in case of error */ xsltDocumentPtr xsltLoadStyleDocument(xsltStylesheetPtr style, const xmlChar *URI) { … } /** * xsltFindDocument: * @ctxt: an XSLT transformation context * @doc: a parsed XML document * * Try to find a document within the XSLT transformation context. * This will not find document infos for temporary * Result Tree Fragments. * * Returns the desired xsltDocumentPtr or NULL in case of error */ xsltDocumentPtr xsltFindDocument (xsltTransformContextPtr ctxt, xmlDocPtr doc) { … }