summaryrefslogtreecommitdiffstats
path: root/klinkstatus/src/utils/xsl.h
blob: e579968bd729e0d28eb446855082582a7b374f04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/***************************************************************************
 *   Copyright (C) 2004 by Paulo Moura Guedes                              *
 *   moura@kdewebdev.org                                                   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
 ***************************************************************************/
#ifndef XSL_H
#define XSL_H

#include <tqobject.h>

class XSLTPrivate;

/**
    @author Paulo Moura Guedes <moura@kdewebdev.org>
    
    Taken from kopetexsl. Kudos to the Kopete team.
 * 
 * This class provides an easy to use interface to basic
 * libxslt transformations.
*/
class XSLT : public TQObject
{
    TQ_OBJECT
    

    TQ_PROPERTY( Flags flags READ flagsProperty WRITE setFlagsProperty )
    TQ_PROPERTY( bool isValid READ isValid )

    TQ_SETS( Flags )

public:
    /**
     * Special flags to be used during the transformation process. Passed
     * into the engine as processing instructions.
     */
    enum Flags
    {
        TransformAllMessages = 1
    };

    /**
     * Constructor.
     *
     * Constructs a new XSLT parser using the provided XSLT document
     */
    XSLT( const TQString &xsltDocument, TQObject *parent = 0L );

    virtual ~XSLT();

    /**
     * Set the XSLT document
     *
     * @return an ORed set of @ref Flags, or 0 if none
     */
    void setXSLT( const TQString &document );

    /**
     * Transforms the XML string using the XSLT document, synchronously
     *
     * @param xmlString The source XML
     * @return The result of the transformation
     */
    TQString transform( const TQString &xmlString );

    /**
     * Transforms the XML string using the XSLT document, asynchronously
     *
     * @param xmlString The source XML
     * @param target The TQObject that contains the slot to be executed when processing is complete
     * @param slotCompleted A slot that accepts a TQVariant & paramater, that is the result
     * of the transformation
     */
    void transformAsync( const TQString &xmlString, TQObject *target, const char *slotCompleted );

    /**
     * Check whether the XSLT document is valid
     *
     * @return Whether the document represents a valid XSLT stylesheet
     */
    bool isValid() const;

    /**
     * @return An ORed list of Flags that the current stylesheet provides via processing instructions
     */
    unsigned int flags() const;

    /**
     * Sets flags to be used for the transformation.
     *
     * @param flags An ORed list of flags
     */
    void setFlags( unsigned int flags );

    inline XSLT::Flags flagsProperty() const { return (XSLT::Flags)flags(); }
    inline void setFlagsProperty( XSLT::Flags newflags ) { setFlags((XSLT::Flags)newflags); }

private:
    XSLTPrivate *d;
};

#endif