Changeset 204
- Timestamp:
- 02/02/07 16:59:03 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/xml/stubXMLXIncludeStreamWrapper.php
r199 r204 127 127 protected function processFile() 128 128 { 129 $xslProcessorClassName = get_class(self::$xslProcessor); 130 $xslProcessor = new $xslProcessorClassName(); 131 foreach (self::$xslProcessor->getParameterNamespaces() as $nameSpace) { 132 $xslProcessor->setParameters($nameSpace, self::$xslProcessor->getParameters($nameSpace)); 133 } 134 135 foreach (self::$xslProcessor->getStylesheets() as $stylesheet) { 136 $xslProcessor->importXSLStylesheet($stylesheet); 137 } 138 129 $xslProcessor = clone self::$xslProcessor; 139 130 $xslProcessor->setXMLDocument(DOMDocument::load($this->fileName)); 140 131 $resultDoc = $xslProcessor->transformToDoc(); trunk/src/main/php/net/stubbles/xml/xsl/stubXSLProcessor.php
r200 r204 231 231 232 232 /** 233 * does some corrections after cloning 234 */ 235 public function __clone() 236 { 237 $this->createXSLTProcessor(); 238 foreach ($this->parameters as $nameSpace => $params) { 239 $this->xsltProcessor->setParameter($nameSpace, $params); 240 } 241 242 foreach ($this->stylesheets as $stylesheet) { 243 $this->xsltProcessor->importStylesheet($stylesheet); 244 } 245 246 $this->document = null; 247 } 248 249 /** 233 250 * transoforms the document into another DOMDocument 234 251 * trunk/src/test/php/net/stubbles/xml/xsl/stubXSLProcessorTestCase.php
r200 r204 17 17 { 18 18 parent::registerCallbacks(); 19 } 20 21 public function getXMLDocument() 22 { 23 return $this->document; 19 24 } 20 25 … … 165 170 166 171 /** 172 * test that cloning works as expected 173 */ 174 public function testClone() 175 { 176 $anotherMockXSLTProcessor = new MockXSLTProcessor(); 177 TeststubXSLProcessor::$mockXSLTProcessor = $anotherMockXSLTProcessor; 178 $this->xslProcessor->setParameter('foo', 'bar', 'baz'); 179 $stylesheet = new DOMDocument(); 180 $this->xslProcessor->importXSLStylesheet($stylesheet); 181 $this->mockXSLTProcessor->expectNever('setParameter'); 182 $anotherMockXSLTProcessor->expect('setParameter', array('foo', array('bar' => 'baz'))); 183 $this->mockXSLTProcessor->expectNever('importStylesheet'); 184 $anotherMockXSLTProcessor->expect('importStylesheet', array($stylesheet)); 185 $clonedXSLProcessor = clone $this->xslProcessor; 186 $this->assertReference($this->xslProcessor->getXMLDocument(), $this->document); 187 $this->assertNull($clonedXSLProcessor->getXMLDocument()); 188 } 189 190 /** 167 191 * test transforming a document 168 192 */
