Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/*
3
 *  $Id: XsltTask.php 144 2007-02-05 15:19:00Z hans $
4
 *
5
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
8
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
9
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
10
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
11
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
12
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
13
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
14
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
15
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16
 *
17
 * This software consists of voluntary contributions made by many individuals
18
 * and is licensed under the LGPL. For more information please see
19
 * <http://phing.info>.
20
 */
21
 
22
require_once 'phing/tasks/system/CopyTask.php';
23
include_once 'phing/system/io/FileReader.php';
24
include_once 'phing/system/io/FileWriter.php';
25
include_once 'phing/filters/XsltFilter.php';
26
 
27
/**
28
 * Implements an XSLT processing filter while copying files.
29
 *
30
 * This is a shortcut for calling the <copy> task with the XSLTFilter used
31
 * in the <filterchains> section.
32
 *
33
 * @author    Andreas Aderhold, andi@binarycloud.com
34
 * @version   $Revision: 1.8 $
35
 * @package   phing.tasks.system
36
 */
37
class XsltTask extends CopyTask {
38
 
39
    /** XSLTFilter object that we use to handle transformation. */
40
    private $xsltFilter;
41
 
42
    /** Parameters to pass to XSLT procesor. */
43
    private $parameters = array();
44
 
45
    /**
46
     * Setup the filterchains w/ XSLTFilter that we will use while copying the files.
47
     */
48
    function init() {
49
        $xf = new XsltFilter();
50
        $chain = $this->createFilterChain($this->getProject());
51
        $chain->addXsltFilter($xf);
52
        $this->xsltFilter = $xf;
53
    }
54
 
55
    /**
56
     * Set any XSLT Param and invoke CopyTask::main()
57
     * @see CopyTask::main()
58
     */
59
    function main() {
60
        $this->log("Doing XSLT transformation using stylesheet " . $this->xsltFilter->getStyle(), Project::MSG_VERBOSE);
61
        $this->xsltFilter->setParams($this->parameters);
62
        parent::main();
63
    }
64
 
65
    /**
66
     * Set the stylesheet to use.
67
     * @param PhingFile $style
68
     */
69
    function setStyle(PhingFile $style) {
70
        $this->xsltFilter->setStyle($style);
71
    }
72
 
73
    /**
74
     * Support nested <param> tags useing XSLTParam class.
75
     * @return XSLTParam
76
     */
77
    function createParam() {
78
        $num = array_push($this->parameters, new XSLTParam());
79
        return $this->parameters[$num-1];
80
    }
81
}