ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilXML2FO.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
34 class ilXML2FO
35 {
36  var $xslt = null;
37  var $xml = null;
38  var $fo_string = null;
39 
40  var $xslt_handler = null;
41  var $xslt_args = null;
42 
43  function ilXML2FO()
44  {
45 
46  }
47 
48  function setXMLString($a_xml)
49  {
50  $this->xml = $a_xml;
51  }
52  function getXMLString()
53  {
54  return $this->xml;
55  }
56  function setXSLTLocation($xslt_location)
57  {
58  $this->xslt = $xslt_location;
59  }
60  function getXSLTLocation()
61  {
62  return $this->xslt;
63  }
64  function getFOString()
65  {
66  #return file_get_contents('./Services/Transformation/fo.xml');
67  return $this->fo_string;
68  }
69 
70 
71  function transform()
72  {
73  global $ilLog;
74 
75  $this->__init();
76 
77  $this->fo_string = @xslt_process($this->xslt_handler,
78  "arg:/_xml",
79  "arg:/_xsl",
80  null,
81  $this->xslt_args,
82  null);
83 
84 
85  if(strlen($error_msg = xslt_error($this->xslt_handler)))
86  {
87  $ilLog->write("Error generating pdf: ".$error_msg);
88  return false;
89  }
90 
91  xslt_free($this->xslt_handler);
92 
93  return true;
94  }
95 
96  // Private
97  function __init()
98  {
99 
100  #domxml_open_mem($this->getXMLString(), DOMXML_LOAD_VALIDATING, $error);
101  #if($error)
102  #{
103  # var_dump("<pre>","XML ERROR: ".$error,htmlentities($this->getXMLString()),"<pre>");
104  #}
105 
106  $this->xslt_handler = xslt_create();
107  $this->xslt_args = array('/_xml' => $this->getXMLString(),
108  '/_xsl' => file_get_contents($this->getXSLTLocation()));
109 
110  return true;
111  }
112 
113 
114 
115 
116 }
117 ?>