Overview
Comment: | Improve serialization of OFXMLElement.
It does not store the namespaces for the prefixes "xml" and "xmlns" |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
0a083111c79b504793703d06d991d3c9 |
User & Date: | js on 2011-12-12 13:32:50 |
Other Links: | manifest | tags |
Context
2011-12-12
| ||
20:17 | Remove imports from ObjFW.h that don't exist anymore. check-in: 3df0629692 user: js tags: trunk | |
13:32 | Improve serialization of OFXMLElement. check-in: 0a083111c7 user: js tags: trunk | |
2011-12-11
| ||
01:59 | Allow comments in JSON. check-in: 6203c9e8f2 user: js tags: trunk | |
Changes
Modified src/OFXMLElement.m from [d295443a31] to [7304a0b96d].
︙ | ︙ | |||
314 315 316 317 318 319 320 321 322 323 324 325 326 327 | namespace: OF_SERIALIZATION_NS] elementsForNamespace: OF_SERIALIZATION_NS] firstObject]; attributes = [[attributesElement objectByDeserializing] copy]; namespaces = [[namespacesElement objectByDeserializing] copy]; children = [[childrenElement objectByDeserializing] copy]; if (name == nil) @throw [OFInvalidArgumentException exceptionWithClass: isa selector: _cmd]; [pool release]; } @catch (id e) { | > > > > > > > > | 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 | namespace: OF_SERIALIZATION_NS] elementsForNamespace: OF_SERIALIZATION_NS] firstObject]; attributes = [[attributesElement objectByDeserializing] copy]; namespaces = [[namespacesElement objectByDeserializing] copy]; children = [[childrenElement objectByDeserializing] copy]; if (namespaces == nil) namespaces = [[OFMutableDictionary alloc] init]; [namespaces setObject: @"xml" forKey: @"http://www.w3.org/XML/1998/namespace"]; [namespaces setObject: @"xmlns" forKey: @"http://www.w3.org/2000/xmlns/"]; if (name == nil) @throw [OFInvalidArgumentException exceptionWithClass: isa selector: _cmd]; [pool release]; } @catch (id e) { |
︙ | ︙ | |||
710 711 712 713 714 715 716 717 718 719 720 721 | [attributesElement addChild: [attributes XMLElementBySerializing]]; [element addChild: attributesElement]; } if (namespaces != nil) { OFXMLElement *namespacesElement; namespacesElement = [OFXMLElement elementWithName: @"namespaces" namespace: OF_SERIALIZATION_NS]; [namespacesElement addChild: | > > > > > > > > | > | 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 | [attributesElement addChild: [attributes XMLElementBySerializing]]; [element addChild: attributesElement]; } if (namespaces != nil) { OFXMLElement *namespacesElement; OFMutableDictionary *namespacesCopy = [[namespaces mutableCopy] autorelease]; [namespacesCopy removeObjectForKey: @"http://www.w3.org/XML/1998/namespace"]; [namespacesCopy removeObjectForKey: @"http://www.w3.org/2000/xmlns/"]; if ([namespacesCopy count] > 0) { namespacesElement = [OFXMLElement elementWithName: @"namespaces" namespace: OF_SERIALIZATION_NS]; [namespacesElement addChild: [namespacesCopy XMLElementBySerializing]]; [element addChild: namespacesElement]; } } if (children != nil) { OFXMLElement *childrenElement; childrenElement = [OFXMLElement elementWithName: @"children" namespace: OF_SERIALIZATION_NS]; |
︙ | ︙ |
Modified tests/serialization.xml from [12b8649327] to [56f53a7b7a].
︙ | ︙ | |||
29 30 31 32 33 34 35 | <key> <OFList> <OFString>Hello</OFString> <OFString>Wo
ld! How are you?</OFString> <OFURL>https://webkeks.org/</OFURL> <OFXMLElement name='x'> | < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | <key> <OFList> <OFString>Hello</OFString> <OFString>Wo
ld! How are you?</OFString> <OFURL>https://webkeks.org/</OFURL> <OFXMLElement name='x'> <children> <OFMutableArray> <OFXMLElement name='y'/> <OFXMLCDATA><![CDATA[<]]></OFXMLCDATA> </OFMutableArray> </children> </OFXMLElement> <OFSet> <OFString>foo</OFString> <OFString>bar</OFString> |
︙ | ︙ |