Index: src/OFXMLElement.h ================================================================== --- src/OFXMLElement.h +++ src/OFXMLElement.h @@ -24,10 +24,11 @@ OFString *defaultNamespace; OFMutableArray *attributes; OFMutableDictionary *namespaces; OFMutableArray *children; OFString *characters; + OFString *cdata; OFMutableString *comment; } /** * \param name The name for the element @@ -71,10 +72,18 @@ * \return A new autoreleased OFXMLElement consisting of the specified * characters */ + elementWithCharacters: (OFString*)chars; +/** + * Creates a new element, only consisting of the specified CDATA. + * + * \param cdata The CDATA the element represents + * \return A new autoreleased OFXMLElement consisting of the specified CDATA + */ ++ elementWithCDATA: (OFString*)cdata; + /** * Creates a new element, only consisting of the specified comment. * * \param comment The comment the element represents * \return A new autoreleased OFXMLElement consisting of the specified comment @@ -135,10 +144,19 @@ * \param chars The characters the element represents * \return An initialized OFXMLElement consisting of the specified characters */ - initWithCharacters: (OFString*)chars; +/** + * Initializes an already allocated OFXMLElement so that it only consists of the + * specified CDATA. + * + * \param cdata The CDATA the element represents + * \return An initialized OFXMLElement consisting of the specified CDATA + */ +- initWithCDATA: (OFString*)cdata; + /** * Initializes an already allocated OFXMLElement so that it only consists of the * specified comment. * * \param comment The comment the element represents Index: src/OFXMLElement.m ================================================================== --- src/OFXMLElement.m +++ src/OFXMLElement.m @@ -53,10 +53,15 @@ + elementWithCharacters: (OFString*)chars { return [[[self alloc] initWithCharacters: chars] autorelease]; } + ++ elementWithCDATA: (OFString*)cdata +{ + return [[[self alloc] initWithCDATA: cdata] autorelease]; +} + elementWithComment: (OFString*)comment { return [[[self alloc] initWithComment: comment] autorelease]; } @@ -119,10 +124,19 @@ characters = [chars copy]; return self; } + +- initWithCDATA: (OFString*)cdata_ +{ + self = [super init]; + + cdata = [cdata_ copy]; + + return self; +} - initWithComment: (OFString*)comment_ { self = [super init]; @@ -144,10 +158,14 @@ OFString *def_ns; if (characters != nil) return [characters stringByXMLEscaping]; + if (cdata != nil) + return [OFString stringWithFormat: @"", + [cdata cString]]; + if (comment != nil) { OFMutableString *str; str = [OFMutableString stringWithString: @""]) TEST(@"-[addAttributeWithName:stringValue:]",