1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6// invalid widl
7// interface nsIVariant;
8
9[Constructor]
10interface XSLTProcessor {
11    /**
12     * Import the stylesheet into this XSLTProcessor for transformations.
13     *
14     * @param style The root-node of a XSLT stylesheet. This can be either
15     *              a document node or an element node. If a document node
16     *              then the document can contain either a XSLT stylesheet
17     *              or a LRE stylesheet.
18     *              If the argument is an element node it must be the
19     *              xsl:stylesheet (or xsl:transform) element of an XSLT
20     *              stylesheet.
21     */
22    [Throws]
23    void importStylesheet(Node style);
24
25    /**
26     * Transforms the node source applying the stylesheet given by
27     * the importStylesheet() function. The owner document of the output node
28     * owns the returned document fragment.
29     *
30     * @param source The node to be transformed
31     * @param output This document is used to generate the output
32     * @return DocumentFragment The result of the transformation
33     */
34    [CEReactions, Throws]
35    DocumentFragment transformToFragment(Node source,
36                                         Document output);
37
38    /**
39     * Transforms the node source applying the stylesheet given by the
40     * importStylesheet() function.
41     *
42     * @param source The node to be transformed
43     * @return Document The result of the transformation
44     */
45    [CEReactions, Throws]
46    Document transformToDocument(Node source);
47
48    /**
49     * Sets a parameter to be used in subsequent transformations with this
50     * XSLTProcessor. If the parameter doesn't exist in the stylesheet the
51     * parameter will be ignored.
52     *
53     * @param namespaceURI The namespaceURI of the XSLT parameter
54     * @param localName    The local name of the XSLT parameter
55     * @param value        The new value of the XSLT parameter
56     */
57    [Throws]
58    void setParameter([TreatNullAs=EmptyString] DOMString namespaceURI,
59                      DOMString localName,
60                      any value);
61
62    /**
63     * Gets a parameter if previously set by setParameter. Returns null
64     * otherwise.
65     *
66     * @param namespaceURI The namespaceURI of the XSLT parameter
67     * @param localName    The local name of the XSLT parameter
68     * @return nsIVariant  The value of the XSLT parameter
69     */
70    [Throws]
71    nsIVariant? getParameter([TreatNullAs=EmptyString] DOMString namespaceURI,
72                             DOMString localName);
73    /**
74     * Removes a parameter, if set. This will make the processor use the
75     * default-value for the parameter as specified in the stylesheet.
76     *
77     * @param namespaceURI The namespaceURI of the XSLT parameter
78     * @param localName    The local name of the XSLT parameter
79     */
80    [Throws]
81    void removeParameter([TreatNullAs=EmptyString] DOMString namespaceURI,
82                         DOMString localName);
83
84    /**
85     * Removes all set parameters from this XSLTProcessor. This will make
86     * the processor use the default-value for all parameters as specified in
87     * the stylesheet.
88     */
89    void clearParameters();
90
91    /**
92     * Remove all parameters and stylesheets from this XSLTProcessor.
93     */
94    void reset();
95
96    /**
97    * Disables all loading of external documents, such as from
98    * <xsl:import> and document()
99    * Defaults to off and is *not* reset by calls to reset()
100    */
101    [ChromeOnly]
102    const unsigned long DISABLE_ALL_LOADS = 1;
103
104    /**
105    * Flags for this processor. Defaults to 0. See individual flags above
106    * for documentation for effect of reset()
107    */
108    [ChromeOnly, NeedsCallerType]
109    attribute unsigned long flags;
110};
111