Changeset 597
- Timestamp:
- 04/22/07 03:16:11 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/xml/stubDomXMLStreamWriter.php
r428 r597 4 4 * 5 5 * @author Stephan Schmidt <schst@stubbles.net> 6 * @author Frank Kleine <mikey@stubbles.net> 6 7 * @package stubbles 7 8 * @subpackage xml … … 19 20 class stubDomXMLStreamWriter extends stubAbstractXMLStreamWriter implements stubXMLStreamWriter { 20 21 21 /**22 * List of supported features23 *24 * @var array25 */26 protected $features = array(stubXMLStreamWriter::FEATURE_AS_DOM,27 stubXMLStreamWriter::FEATURE_IMPORT_WRITER);28 22 /** 23 * List of supported features 24 * 25 * @var array 26 */ 27 protected $features = array(stubXMLStreamWriter::FEATURE_AS_DOM, 28 stubXMLStreamWriter::FEATURE_IMPORT_WRITER); 29 29 30 /** 30 31 * DOM Document … … 96 97 * @param string $data 97 98 */ 98 public function writeText($data) { 99 $textNode = $this->doc->createTextNode($data); 99 public function writeText($data) 100 { 101 // data has to be encoded even if document encoding is not UTF-8 102 // (see http://php.net/manual/en/function.dom-domdocument-save.php#67952) 103 $textNode = $this->doc->createTextNode(utf8_encode($data)); 100 104 $this->addToDom($textNode); 101 105 } trunk/src/test/php/net/stubbles/xml/stubDomXMLStreamWriterTestCase.php
r429 r597 75 75 76 76 $this->assertEqual('<?xml version="1.0" encoding="ISO-8859-1"?>' . "\n". '<root>This is text.</root>', $writer->asXML()); 77 } 78 79 /** 80 * Test creating a document with a text node containing german umlauts. 81 */ 82 public function testTextWithGermanUmlauts() { 83 $writer = new stubDomXMLStreamWriter(); 84 $writer->writeStartElement('root'); 85 $writer->writeText('This is text containg äöü.'); 86 $writer->writeEndElement(); 87 88 $this->assertEqual('<?xml version="1.0" encoding="ISO-8859-1"?>' . "\n". '<root>This is text containg äöü.</root>', $writer->asXML()); 77 89 } 78 90
