Changeset 552
- Timestamp:
- 04/17/07 21:51:01 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/xml/serializer/stubXMLSerializer.php
r445 r552 8 8 */ 9 9 stubClassLoader::load('net.stubbles.xml.serializer.annotations.stubXMLTagAnnotation', 10 'net.stubbles.xml.serializer.annotations.stubXMLFragmentAnnotation', 10 11 'net.stubbles.xml.serializer.annotations.stubXMLAttributeAnnotation', 11 12 'net.stubbles.xml.serializer.annotations.stubXMLIgnoreAnnotation', … … 152 153 continue; 153 154 } 155 if ($property->hasAnnotation('XMLFragment')) { 156 $xmlFragment = $property->getAnnotation('XMLFragment'); 157 $tagName = $xmlFragment->getTagName(); 158 if ($tagName != null) { 159 $xmlWriter->writeStartElement($tagName); 160 $xmlWriter->writeXmlFragment($propValue); 161 $xmlWriter->writeEndElement(); 162 } else { 163 $xmlWriter->writeXmlFragment($propValue); 164 } 165 continue; 166 } 154 167 if ($property->hasAnnotation('XMLTag')) { 155 168 $xmlTag = $property->getAnnotation('XMLTag'); … … 211 224 continue; 212 225 } 226 if ($method->hasAnnotation('XMLFragment')) { 227 $xmlFragment = $method->getAnnotation('XMLFragment'); 228 $tagName = $xmlFragment->getTagName(); 229 if ($tagName != null) { 230 $xmlWriter->writeStartElement($tagName); 231 $xmlWriter->writeXmlFragment($returnValue); 232 $xmlWriter->writeEndElement(); 233 } else { 234 $xmlWriter->writeXmlFragment($returnValue); 235 } 236 continue; 237 } 213 238 if ($method->hasAnnotation('XMLTag')) { 214 239 $xmlTag = $method->getAnnotation('XMLTag'); trunk/src/test/php/net/stubbles/xml/stubXMLSerializerTestCase.php
r492 r552 122 122 return "bar"; 123 123 } 124 } 125 126 /** 127 * Simple Test class to test the XMLSerializer 128 * 129 * @XMLTag(tagName='test') 130 */ 131 class XMLSerializerFragmentTest { 132 /** 133 * Property containing XML 134 * 135 * @XMLFragment(tagName='xml'); 136 * @var string 137 */ 138 public $xml = '<foo>bar</foo>'; 124 139 } 125 140 … … 288 303 289 304 /** 305 * Test serializing an object with an xml fragment 306 */ 307 public function testObjectFragmentProperty() { 308 $writer = new stubDomXMLStreamWriter(); 309 $obj = new XMLSerializerFragmentTest(); 310 $this->serializer->serialize($obj, $writer); 311 $this->assertEqual('<?xml version="1.0" encoding="ISO-8859-1"?>' . "\n" . '<test><xml><foo>bar</foo></xml></test>', $writer->asXML()); 312 } 313 314 /** 290 315 * Test serializing an object with a method matcher 291 316 */
