Changeset 1018
- Timestamp:
- 11/09/07 18:01:44 (8 months ago)
- Files:
-
- trunk/src/main/php/net/stubbles/xml/stubAbstractXMLStreamWriter.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/xml/stubDomXMLStreamWriter.php (modified) (6 diffs)
- trunk/src/main/php/net/stubbles/xml/stubLibXmlXMLStreamWriter.php (modified) (5 diffs)
- trunk/src/main/php/net/stubbles/xml/stubXMLStreamWriter.php (modified) (3 diffs)
- trunk/src/test/php/net/stubbles/xml/stubDomXMLStreamWriterTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/xml/stubLibXmlXMLStreamWriterTestCase.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/xml/stubAbstractXMLStreamWriter.php
r678 r1018 3 3 * Abstract base class for XML stream writers 4 4 * 5 * @author Stephan Schmidt <schst@stubbles.net> 6 * @package stubbles 7 * @subpackage xml 5 * @author Stephan Schmidt <schst@stubbles.net> 6 * @author Frank Kleine <mikey@stubbles.net> 7 * @package stubbles 8 * @subpackage xml 8 9 */ 9 10 10 /** 11 11 * Abstract base class for XML stream writers 12 12 * 13 * @package stubbles14 * @subpackage xml13 * @package stubbles 14 * @subpackage xml 15 15 */ 16 abstract class stubAbstractXMLStreamWriter extends stubBaseObject { 17 16 abstract class stubAbstractXMLStreamWriter extends stubBaseObject 17 { 18 /** 19 * encoding used by the writer 20 * 21 * @var string 22 */ 23 protected $encoding; 18 24 /** 19 25 * List of supported features … … 22 28 */ 23 29 protected $features = array(); 30 31 /** 32 * returns the encoding used by the writer 33 * 34 * @return string 35 */ 36 public function getEncoding() 37 { 38 return $this->encoding; 39 } 24 40 25 41 /** trunk/src/main/php/net/stubbles/xml/stubDomXMLStreamWriter.php
r1017 r1018 18 18 * @subpackage xml 19 19 */ 20 class stubDomXMLStreamWriter extends stubAbstractXMLStreamWriter implements stubXMLStreamWriter {21 20 class stubDomXMLStreamWriter extends stubAbstractXMLStreamWriter implements stubXMLStreamWriter 21 { 22 22 /** 23 23 * List of supported features … … 27 27 protected $features = array(stubXMLStreamWriter::FEATURE_AS_DOM, 28 28 stubXMLStreamWriter::FEATURE_IMPORT_WRITER); 29 30 29 /** 31 30 * DOM Document … … 34 33 */ 35 34 protected $doc; 36 37 35 /** 38 36 * Stores al opened elements … … 41 39 */ 42 40 protected $elementStack = array(); 43 44 41 /** 45 42 * XML version … … 48 45 */ 49 46 protected $xmlVersion; 50 51 /**52 * XML encoding53 *54 * @var string55 */56 protected $encoding;57 47 58 48 /** … … 64 54 public function __construct($xmlVersion = '1.0', $encoding = 'UTF-8') { 65 55 $this->xmlVersion = $xmlVersion; 66 $this->encoding = $encoding;67 $this->doc = new DOMDocument($xmlVersion, $encoding);56 $this->encoding = $encoding; 57 $this->doc = new DOMDocument($xmlVersion, $encoding); 68 58 } 69 59 trunk/src/main/php/net/stubbles/xml/stubLibXmlXMLStreamWriter.php
r1017 r1018 17 17 * @subpackage xml 18 18 */ 19 class stubLibXmlXMLStreamWriter extends stubAbstractXMLStreamWriter implements stubXMLStreamWriter {20 19 class stubLibXmlXMLStreamWriter extends stubAbstractXMLStreamWriter implements stubXMLStreamWriter 20 { 21 21 /** 22 22 * List of supported features … … 25 25 */ 26 26 protected $features = array(stubXMLStreamWriter::FEATURE_AS_DOM); 27 28 27 /** 29 28 * Writer … … 32 31 */ 33 32 protected $writer; 34 35 33 /** 36 34 * XML version … … 39 37 */ 40 38 protected $xmlVersion; 41 42 /**43 * XML encoding44 *45 * @var string46 */47 protected $encoding;48 39 49 40 /** … … 55 46 public function __construct($xmlVersion = '1.0', $encoding = 'UTF-8') { 56 47 $this->xmlVersion = $xmlVersion; 57 $this->encoding = $encoding;58 $this->writer = new XMLWriter();48 $this->encoding = $encoding; 49 $this->writer = new XMLWriter(); 59 50 $this->writer->openMemory(); 60 51 $this->writer->startDocument($xmlVersion, $encoding); trunk/src/main/php/net/stubbles/xml/stubXMLStreamWriter.php
r760 r1018 3 3 * Interface to create XML documents 4 4 * 5 * @author Stephan Schmidt <schst@stubbles.net> 6 * @package stubbles 7 * @subpackage xml 5 * @author Stephan Schmidt <schst@stubbles.net> 6 * @author Frank Kleine <mikey@stubbles.net> 7 * @package stubbles 8 * @subpackage xml 8 9 */ 9 10 stubClassLoader::load('net.stubbles.xml.stubXMLException'); … … 11 12 * Interface to create XML documents 12 13 * 13 * @package stubbles14 * @subpackage xml14 * @package stubbles 15 * @subpackage xml 15 16 */ 16 17 interface stubXMLStreamWriter extends stubObject { … … 36 37 * @param string $encoding 37 38 */ 38 #public function __construct($xmlVersion = '1.0', $encoding = 'ISO-8859-1'); 39 #public function __construct($xmlVersion = '1.0', $encoding = 'UTF-8'); 40 41 /** 42 * returns the encoding used by the writer 43 * 44 * @return string 45 */ 46 public function getEncoding(); 39 47 40 48 /** trunk/src/test/php/net/stubbles/xml/stubDomXMLStreamWriterTestCase.php
r1017 r1018 24 24 $writer = new stubDomXMLStreamWriter(); 25 25 $this->assertEqual('<?xml version="1.0" encoding="UTF-8"?>', $writer->asXML()); 26 $this->assertEqual($writer->getEncoding(), 'UTF-8'); 27 $writer = new stubDomXMLStreamWriter('1.0', 'ISO-8859-1'); 28 $this->assertEqual($writer->getEncoding(), 'ISO-8859-1'); 26 29 } 27 30 trunk/src/test/php/net/stubbles/xml/stubLibXmlXMLStreamWriterTestCase.php
r1017 r1018 24 24 $writer = new stubLibXmlXMLStreamWriter(); 25 25 $this->assertEqual('<?xml version="1.0" encoding="UTF-8"?>', $writer->asXML()); 26 $this->assertEqual($writer->getEncoding(), 'UTF-8'); 27 $writer = new stubLibXmlXMLStreamWriter('1.0', 'ISO-8859-1'); 28 $this->assertEqual($writer->getEncoding(), 'ISO-8859-1'); 26 29 } 27 30
