Browse files

Organizing the project structure (finally)

  • Loading branch information...
1 parent 34b9de1 commit 18ce4d66169c2ce983fb604714cecab1c923eb16 @robbiehanson committed Sep 17, 2010
Showing with 0 additions and 35,700 deletions.
  1. 0 { → Categories}/DDNumber.h
  2. 0 { → Categories}/DDNumber.m
  3. 0 { → Categories}/NSDataAdditions.h
  4. 0 { → Categories}/NSDataAdditions.m
  5. 0 { → Categories}/NSXMLElementAdditions.h
  6. 0 { → Categories}/NSXMLElementAdditions.m
  7. 0 { → Core}/XMPP.h
  8. 0 { → Core}/XMPPElement.h
  9. 0 { → Core}/XMPPElement.m
  10. 0 { → Core}/XMPPIQ.h
  11. 0 { → Core}/XMPPIQ.m
  12. 0 { → Core}/XMPPJID.h
  13. 0 { → Core}/XMPPJID.m
  14. 0 { → Core}/XMPPMessage.h
  15. 0 { → Core}/XMPPMessage.m
  16. 0 { → Core}/XMPPModule.h
  17. 0 { → Core}/XMPPModule.m
  18. 0 { → Core}/XMPPParser.h
  19. 0 { → Core}/XMPPParser.m
  20. 0 { → Core}/XMPPPresence.h
  21. 0 { → Core}/XMPPPresence.m
  22. 0 { → Core}/XMPPReconnect.h
  23. 0 { → Core}/XMPPReconnect.m
  24. 0 { → Core}/XMPPStream.h
  25. 0 { → Core}/XMPPStream.m
  26. +0 −83 English.lproj/ChatWindow.nib/classes.nib
  27. +0 −18 English.lproj/ChatWindow.nib/info.nib
  28. BIN English.lproj/ChatWindow.nib/keyedobjects.nib
  29. BIN English.lproj/InfoPlist.strings
  30. +0 −4,621 English.lproj/MainMenu.nib/designable.nib
  31. BIN English.lproj/MainMenu.nib/keyedobjects.nib
  32. 0 { → Extensions/XEP-0060}/XMPPPubSub.h
  33. 0 { → Extensions/XEP-0060}/XMPPPubSub.m
  34. 0 { → Extensions/XEP-0065}/TURNSocket.h
  35. 0 { → Extensions/XEP-0065}/TURNSocket.m
  36. 0 { → Extensions/XEP-0100}/XMPPTransports.h
  37. 0 { → Extensions/XEP-0100}/XMPPTransports.m
  38. 0 { → Extensions/XEP-0115}/XMPPCapabilities.h
  39. 0 { → Extensions/XEP-0115}/XMPPCapabilities.m
  40. 0 { → Extensions/XEP-0115}/XMPPCapabilitiesCoreDataStorage.h
  41. 0 { → Extensions/XEP-0115}/XMPPCapabilitiesCoreDataStorage.m
  42. 0 { → Extensions/XEP-0115}/XMPPCapsCoreDataStorageObject.h
  43. 0 { → Extensions/XEP-0115}/XMPPCapsCoreDataStorageObject.m
  44. 0 { → Extensions/XEP-0115}/XMPPCapsResourceCoreDataStorageObject.h
  45. 0 { → Extensions/XEP-0115}/XMPPCapsResourceCoreDataStorageObject.m
  46. 0 { → Extensions/XEP-0199}/XMPPPing.h
  47. 0 { → Extensions/XEP-0199}/XMPPPing.m
  48. +0 −70 KissXML/DDXML.h
  49. +0 −67 KissXML/DDXMLDocument.h
  50. +0 −111 KissXML/DDXMLDocument.m
  51. +0 −49 KissXML/DDXMLElement.h
  52. +0 −629 KissXML/DDXMLElement.m
  53. +0 −170 KissXML/DDXMLNode.h
  54. +0 −1,808 KissXML/DDXMLNode.m
  55. +0 −79 KissXML/DDXMLPrivate.h
  56. +0 −14 KissXML/NSStringAdditions.h
  57. +0 −29 KissXML/NSStringAdditions.m
  58. +0 −6 Testing/MulticastDelegateTest/Class1.h
  59. +0 −44 Testing/MulticastDelegateTest/Class1.m
  60. +0 −6 Testing/MulticastDelegateTest/Class2.h
  61. +0 −44 Testing/MulticastDelegateTest/Class2.m
  62. +0 −2 Testing/MulticastDelegateTest/English.lproj/InfoPlist.strings
  63. +0 −4,119 Testing/MulticastDelegateTest/English.lproj/MainMenu.xib
  64. +0 −32 Testing/MulticastDelegateTest/MulticastDelegateTest-Info.plist
  65. +0 −302 Testing/MulticastDelegateTest/MulticastDelegateTest.xcodeproj/project.pbxproj
  66. +0 −20 Testing/MulticastDelegateTest/MulticastDelegateTestAppDelegate.h
  67. +0 −146 Testing/MulticastDelegateTest/MulticastDelegateTestAppDelegate.m
  68. +0 −7 Testing/MulticastDelegateTest/MulticastDelegateTest_Prefix.pch
  69. +0 −18 Testing/MulticastDelegateTest/MyProtocol.h
  70. +0 −14 Testing/MulticastDelegateTest/main.m
  71. +0 −2 Testing/ParserTestMac/English.lproj/InfoPlist.strings
  72. +0 −4,119 Testing/ParserTestMac/English.lproj/MainMenu.xib
  73. +0 −32 Testing/ParserTestMac/ParserTestMac-Info.plist
  74. +0 −310 Testing/ParserTestMac/ParserTestMac.xcodeproj/project.pbxproj
  75. +0 −18 Testing/ParserTestMac/ParserTestMacAppDelegate.h
  76. +0 −212 Testing/ParserTestMac/ParserTestMacAppDelegate.m
  77. +0 −7 Testing/ParserTestMac/ParserTestMac_Prefix.pch
  78. +0 −14 Testing/ParserTestMac/main.m
  79. +0 −11 Testing/ParserTestPhone/Classes/ParserTestPhoneAppDelegate.h
  80. +0 −222 Testing/ParserTestPhone/Classes/ParserTestPhoneAppDelegate.m
  81. +0 −191 Testing/ParserTestPhone/MainWindow.xib
  82. +0 −30 Testing/ParserTestPhone/ParserTestPhone-Info.plist
  83. +0 −309 Testing/ParserTestPhone/ParserTestPhone.xcodeproj/project.pbxproj
  84. +0 −8 Testing/ParserTestPhone/ParserTestPhone_Prefix.pch
  85. +0 −17 Testing/ParserTestPhone/main.m
  86. +0 −2 Testing/TestCapabilitiesHashing/Mac/TestCapabilitiesHashing/English.lproj/InfoPlist.strings
  87. +0 −4,119 Testing/TestCapabilitiesHashing/Mac/TestCapabilitiesHashing/English.lproj/MainMenu.xib
  88. +0 −32 Testing/TestCapabilitiesHashing/Mac/TestCapabilitiesHashing/TestCapabilitiesHashing-Info.plist
  89. +0 −312 ...CapabilitiesHashing/Mac/TestCapabilitiesHashing/TestCapabilitiesHashing.xcodeproj/project.pbxproj
  90. +0 −1,427 ...tCapabilitiesHashing/Mac/TestCapabilitiesHashing/TestCapabilitiesHashing.xcodeproj/robbie.mode1v3
  91. +0 −197 ...tCapabilitiesHashing/Mac/TestCapabilitiesHashing/TestCapabilitiesHashing.xcodeproj/robbie.pbxuser
  92. +0 −7 Testing/TestCapabilitiesHashing/Mac/TestCapabilitiesHashing/TestCapabilitiesHashing_Prefix.pch
  93. +0 −14 Testing/TestCapabilitiesHashing/Mac/TestCapabilitiesHashing/main.m
  94. +0 −38 Testing/TestCapabilitiesHashing/TestCapabilitiesHashingAppDelegate.h
  95. +0 −518 Testing/TestCapabilitiesHashing/TestCapabilitiesHashingAppDelegate.m
  96. +0 −16 ...apabilitiesHashing/iPhone/TestCapabilitiesHashing/Classes/TestCapabilitiesHashingViewController.h
  97. +0 −65 ...apabilitiesHashing/iPhone/TestCapabilitiesHashing/Classes/TestCapabilitiesHashingViewController.m
  98. +0 −219 Testing/TestCapabilitiesHashing/iPhone/TestCapabilitiesHashing/MainWindow.xib
  99. +0 −30 Testing/TestCapabilitiesHashing/iPhone/TestCapabilitiesHashing/TestCapabilitiesHashing-Info.plist
  100. +0 −327 ...abilitiesHashing/iPhone/TestCapabilitiesHashing/TestCapabilitiesHashing.xcodeproj/project.pbxproj
  101. +0 −151 .../TestCapabilitiesHashing/iPhone/TestCapabilitiesHashing/TestCapabilitiesHashingViewController.xib
  102. +0 −8 Testing/TestCapabilitiesHashing/iPhone/TestCapabilitiesHashing/TestCapabilitiesHashing_Prefix.pch
  103. +0 −17 Testing/TestCapabilitiesHashing/iPhone/TestCapabilitiesHashing/main.m
  104. 0 { → Utilities}/DDLog.h
  105. 0 { → Utilities}/LibIDN.h
  106. 0 { → Utilities}/LibIDN.m
  107. 0 { → Utilities}/MulticastDelegate.h
  108. 0 { → Utilities}/MulticastDelegate.m
  109. 0 { → Utilities}/RFSRVResolver.h
  110. 0 { → Utilities}/RFSRVResolver.m
  111. 0 { → Vendor/AsyncSocket}/AsyncSocket.h
  112. 0 { → Vendor/AsyncSocket}/AsyncSocket.m
  113. 0 { → Vendor/SSCrypto}/SSCrypto.h
  114. 0 { → Vendor/SSCrypto}/SSCrypto.m
  115. BIN XMPPCapabilities.xcdatamodel/elements
  116. BIN XMPPCapabilities.xcdatamodel/layout
  117. +0 −17 XMPPResource.h
  118. +0 −35 XMPPResourceCoreDataStorage.h
  119. +0 −199 XMPPResourceCoreDataStorage.m
  120. +0 −23 XMPPResourceMemoryStorage.h
  121. +0 −178 XMPPResourceMemoryStorage.m
  122. +0 −92 XMPPRoster.h
  123. +0 −432 XMPPRoster.m
  124. BIN XMPPRoster.xcdatamodel/elements
  125. BIN XMPPRoster.xcdatamodel/layout
  126. +0 −25 XMPPRosterCoreDataStorage.h
  127. +0 −343 XMPPRosterCoreDataStorage.m
  128. +0 −48 XMPPRosterMemoryStorage.h
  129. +0 −319 XMPPRosterMemoryStorage.m
  130. +0 −12 XMPPRosterPrivate.h
  131. +0 −1,144 XMPPStream.xcodeproj/project.pbxproj
  132. +0 −35 XMPPUser.h
  133. +0 −42 XMPPUserCoreDataStorage.h
  134. +0 −334 XMPPUserCoreDataStorage.m
  135. +0 −35 XMPPUserMemoryStorage.h
  136. +0 −369 XMPPUserMemoryStorage.m
  137. 0 { → Xcode/DesktopXMPP}/AppDelegate.h
  138. 0 { → Xcode/DesktopXMPP}/AppDelegate.m
  139. 0 { → Xcode/DesktopXMPP}/ChatController.h
  140. 0 { → Xcode/DesktopXMPP}/ChatController.m
  141. 0 { → Xcode/DesktopXMPP}/ChatWindowManager.h
  142. 0 { → Xcode/DesktopXMPP}/ChatWindowManager.m
  143. 0 { → Xcode/DesktopXMPP}/Info-Framework.plist
  144. 0 { → Xcode/DesktopXMPP}/Info-Mini.plist
  145. 0 { → Xcode/DesktopXMPP}/Info.plist
  146. 0 { → Xcode/DesktopXMPP}/RequestController.h
  147. 0 { → Xcode/DesktopXMPP}/RequestController.m
  148. 0 { → Xcode/DesktopXMPP}/RosterController.h
  149. 0 { → Xcode/DesktopXMPP}/RosterController.m
  150. 0 { → Xcode/DesktopXMPP}/XMPP.exp
  151. 0 { → Xcode/DesktopXMPP}/XMPPStream_Prefix.pch
  152. 0 { → Xcode/DesktopXMPP}/main.m
  153. +0 −19 iPhone/ServerlessDemo/Classes/BonjourClient.h
  154. +0 −322 iPhone/ServerlessDemo/Classes/BonjourClient.m
  155. +0 −27 iPhone/ServerlessDemo/Classes/ChatViewController.h
  156. +0 −754 iPhone/ServerlessDemo/Classes/ChatViewController.m
  157. +0 −534 iPhone/ServerlessDemo/Classes/ChatViewController.xib
  158. +0 −15 iPhone/ServerlessDemo/Classes/RootViewController.h
  159. +0 −367 iPhone/ServerlessDemo/Classes/RootViewController.m
  160. +0 −33 iPhone/ServerlessDemo/Classes/ServerlessDemoAppDelegate.h
  161. +0 −221 iPhone/ServerlessDemo/Classes/ServerlessDemoAppDelegate.m
  162. +0 −8 iPhone/ServerlessDemo/DDString.h
  163. +0 −11 iPhone/ServerlessDemo/DDString.m
  164. BIN iPhone/ServerlessDemo/Images/BlueBubble.png
  165. BIN iPhone/ServerlessDemo/Images/GreenBubble.png
  166. BIN iPhone/ServerlessDemo/Images/UnreadIndicator.png
  167. +0 −272 iPhone/ServerlessDemo/MainWindow.xib
  168. +0 −24 iPhone/ServerlessDemo/Message.h
  169. +0 −43 iPhone/ServerlessDemo/Message.m
  170. +0 −380 iPhone/ServerlessDemo/RootViewController.xib
  171. +0 −30 iPhone/ServerlessDemo/ServerlessDemo-Info.plist
  172. BIN iPhone/ServerlessDemo/ServerlessDemo.xcdatamodel/elements
  173. BIN iPhone/ServerlessDemo/ServerlessDemo.xcdatamodel/layout
  174. +0 −528 iPhone/ServerlessDemo/ServerlessDemo.xcodeproj/project.pbxproj
  175. +0 −16 iPhone/ServerlessDemo/ServerlessDemo_Prefix.pch
  176. +0 −53 iPhone/ServerlessDemo/Service.h
  177. +0 −151 iPhone/ServerlessDemo/Service.m
  178. +0 −21 iPhone/ServerlessDemo/StreamController.h
  179. +0 −262 iPhone/ServerlessDemo/StreamController.m
  180. +0 −17 iPhone/ServerlessDemo/main.m
  181. +0 −10 iPhoneXMPP/Classes/RootViewController.h
  182. +0 −160 iPhoneXMPP/Classes/RootViewController.m
  183. +0 −33 iPhoneXMPP/Classes/iPhoneXMPPAppDelegate.h
  184. +0 −212 iPhoneXMPP/Classes/iPhoneXMPPAppDelegate.m
  185. +0 −268 iPhoneXMPP/MainWindow.xib
  186. +0 −380 iPhoneXMPP/RootViewController.xib
  187. +0 −30 iPhoneXMPP/iPhoneXMPP-Info.plist
  188. +0 −530 iPhoneXMPP/iPhoneXMPP.xcodeproj/project.pbxproj
  189. +0 −14 iPhoneXMPP/iPhoneXMPP_Prefix.pch
  190. +0 −17 iPhoneXMPP/main.m
  191. +0 −524 libidn/idn-int.h
  192. BIN libidn/libidn-1.15.tar.gz
  193. BIN libidn/libidn.a
  194. +0 −223 libidn/stringprep.h
View
0 DDNumber.h → Categories/DDNumber.h
File renamed without changes.
View
0 DDNumber.m → Categories/DDNumber.m
File renamed without changes.
View
0 NSDataAdditions.h → Categories/NSDataAdditions.h
File renamed without changes.
View
0 NSDataAdditions.m → Categories/NSDataAdditions.m
File renamed without changes.
View
0 NSXMLElementAdditions.h → Categories/NSXMLElementAdditions.h
File renamed without changes.
View
0 NSXMLElementAdditions.m → Categories/NSXMLElementAdditions.m
File renamed without changes.
View
0 XMPP.h → Core/XMPP.h
File renamed without changes.
View
0 XMPPElement.h → Core/XMPPElement.h
File renamed without changes.
View
0 XMPPElement.m → Core/XMPPElement.m
File renamed without changes.
View
0 XMPPIQ.h → Core/XMPPIQ.h
File renamed without changes.
View
0 XMPPIQ.m → Core/XMPPIQ.m
File renamed without changes.
View
0 XMPPJID.h → Core/XMPPJID.h
File renamed without changes.
View
0 XMPPJID.m → Core/XMPPJID.m
File renamed without changes.
View
0 XMPPMessage.h → Core/XMPPMessage.h
File renamed without changes.
View
0 XMPPMessage.m → Core/XMPPMessage.m
File renamed without changes.
View
0 XMPPModule.h → Core/XMPPModule.h
File renamed without changes.
View
0 XMPPModule.m → Core/XMPPModule.m
File renamed without changes.
View
0 XMPPParser.h → Core/XMPPParser.h
File renamed without changes.
View
0 XMPPParser.m → Core/XMPPParser.m
File renamed without changes.
View
0 XMPPPresence.h → Core/XMPPPresence.h
File renamed without changes.
View
0 XMPPPresence.m → Core/XMPPPresence.m
File renamed without changes.
View
0 XMPPReconnect.h → Core/XMPPReconnect.h 100644 → 100755
File renamed without changes.
View
0 XMPPReconnect.m → Core/XMPPReconnect.m 100644 → 100755
File renamed without changes.
View
0 XMPPStream.h → Core/XMPPStream.h
File renamed without changes.
View
0 XMPPStream.m → Core/XMPPStream.m
File renamed without changes.
View
83 English.lproj/ChatWindow.nib/classes.nib
@@ -1,83 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>IBClasses</key>
- <array>
- <dict>
- <key>ACTIONS</key>
- <dict>
- <key>sendMessage</key>
- <string>id</string>
- </dict>
- <key>CLASS</key>
- <string>ChatController</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>OUTLETS</key>
- <dict>
- <key>messageField</key>
- <string>id</string>
- <key>messageView</key>
- <string>id</string>
- </dict>
- <key>SUPERCLASS</key>
- <string>NSWindowController</string>
- </dict>
- <dict>
- <key>CLASS</key>
- <string>XMPPClient</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>SUPERCLASS</key>
- <string>NSObject</string>
- </dict>
- <dict>
- <key>CLASS</key>
- <string>XMPPStream</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>OUTLETS</key>
- <dict>
- <key>delegate</key>
- <string>id</string>
- </dict>
- <key>SUPERCLASS</key>
- <string>NSObject</string>
- </dict>
- <dict>
- <key>ACTIONS</key>
- <dict>
- <key>xmppClientConnecting</key>
- <string>XMPPClient</string>
- <key>xmppClientDidAuthenticate</key>
- <string>XMPPClient</string>
- <key>xmppClientDidConnect</key>
- <string>XMPPClient</string>
- <key>xmppClientDidDisconnect</key>
- <string>XMPPClient</string>
- <key>xmppClientDidNotConnect</key>
- <string>XMPPClient</string>
- <key>xmppClientDidRegister</key>
- <string>XMPPClient</string>
- <key>xmppClientDidUpdateRoster</key>
- <string>XMPPClient</string>
- <key>xmppStreamDidAuthenticate</key>
- <string>XMPPStream</string>
- <key>xmppStreamDidClose</key>
- <string>XMPPStream</string>
- <key>xmppStreamDidOpen</key>
- <string>XMPPStream</string>
- <key>xmppStreamDidRegister</key>
- <string>XMPPStream</string>
- </dict>
- <key>CLASS</key>
- <string>NSObject</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- </dict>
- </array>
- <key>IBVersion</key>
- <string>1</string>
-</dict>
-</plist>
View
18 English.lproj/ChatWindow.nib/info.nib
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>IBFramework Version</key>
- <string>629</string>
- <key>IBLastKnownRelativeProjectPath</key>
- <string>../../XMPPStream.xcodeproj</string>
- <key>IBOldestOS</key>
- <integer>5</integer>
- <key>IBOpenObjects</key>
- <array/>
- <key>IBSystem Version</key>
- <string>9C7010</string>
- <key>targetFramework</key>
- <string>IBCocoaFramework</string>
-</dict>
-</plist>
View
BIN English.lproj/ChatWindow.nib/keyedobjects.nib
Binary file not shown.
View
BIN English.lproj/InfoPlist.strings
Binary file not shown.
View
4,621 English.lproj/MainMenu.nib/designable.nib
0 additions, 4,621 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
BIN English.lproj/MainMenu.nib/keyedobjects.nib
Binary file not shown.
View
0 XMPPPubSub.h → Extensions/XEP-0060/XMPPPubSub.h
File renamed without changes.
View
0 XMPPPubSub.m → Extensions/XEP-0060/XMPPPubSub.m
File renamed without changes.
View
0 TURNSocket.h → Extensions/XEP-0065/TURNSocket.h
File renamed without changes.
View
0 TURNSocket.m → Extensions/XEP-0065/TURNSocket.m
File renamed without changes.
View
0 XMPPTransports.h → Extensions/XEP-0100/XMPPTransports.h
File renamed without changes.
View
0 XMPPTransports.m → Extensions/XEP-0100/XMPPTransports.m
File renamed without changes.
View
0 XMPPCapabilities.h → Extensions/XEP-0115/XMPPCapabilities.h
File renamed without changes.
View
0 XMPPCapabilities.m → Extensions/XEP-0115/XMPPCapabilities.m
File renamed without changes.
View
0 XMPPCapabilitiesCoreDataStorage.h → ...EP-0115/XMPPCapabilitiesCoreDataStorage.h
File renamed without changes.
View
0 XMPPCapabilitiesCoreDataStorage.m → ...EP-0115/XMPPCapabilitiesCoreDataStorage.m
File renamed without changes.
View
0 XMPPCapsCoreDataStorageObject.h → .../XEP-0115/XMPPCapsCoreDataStorageObject.h
File renamed without changes.
View
0 XMPPCapsCoreDataStorageObject.m → .../XEP-0115/XMPPCapsCoreDataStorageObject.m
File renamed without changes.
View
0 XMPPCapsResourceCoreDataStorageObject.h → ...5/XMPPCapsResourceCoreDataStorageObject.h
File renamed without changes.
View
0 XMPPCapsResourceCoreDataStorageObject.m → ...5/XMPPCapsResourceCoreDataStorageObject.m
File renamed without changes.
View
0 XMPPPing.h → Extensions/XEP-0199/XMPPPing.h
File renamed without changes.
View
0 XMPPPing.m → Extensions/XEP-0199/XMPPPing.m
File renamed without changes.
View
70 KissXML/DDXML.h
@@ -1,70 +0,0 @@
-#if TARGET_OS_IPHONE
-
-#import "DDXMLNode.h"
-#import "DDXMLElement.h"
-#import "DDXMLDocument.h"
-
-#ifndef NSXMLNode
- #define NSXMLNode DDXMLNode
-#endif
-#ifndef NSXMLElement
- #define NSXMLElement DDXMLElement
-#endif
-#ifndef NSXMLDocument
- #define NSXMLDocument DDXMLDocument
-#endif
-
-#ifndef NSXMLInvalidKind
- #define NSXMLInvalidKind DDXMLInvalidKind
-#endif
-#ifndef NSXMLDocumentKind
- #define NSXMLDocumentKind DDXMLDocumentKind
-#endif
-#ifndef NSXMLElementKind
- #define NSXMLElementKind DDXMLElementKind
-#endif
-#ifndef NSXMLAttributeKind
- #define NSXMLAttributeKind DDXMLAttributeKind
-#endif
-#ifndef NSXMLNamespaceKind
- #define NSXMLNamespaceKind DDXMLNamespaceKind
-#endif
-#ifndef NSXMLProcessingInstructionKind
- #define NSXMLProcessingInstructionKind DDXMLProcessingInstructionKind
-#endif
-#ifndef NSXMLCommentKind
- #define NSXMLCommentKind DDXMLCommentKind
-#endif
-#ifndef NSXMLTextKind
- #define NSXMLTextKind DDXMLTextKind
-#endif
-#ifndef NSXMLDTDKind
- #define NSXMLDTDKind DDXMLDTDKind
-#endif
-#ifndef NSXMLEntityDeclarationKind
- #define NSXMLEntityDeclarationKind DDXMLEntityDeclarationKind
-#endif
-#ifndef NSXMLAttributeDeclarationKind
- #define NSXMLAttributeDeclarationKind DDXMLAttributeDeclarationKind
-#endif
-#ifndef NSXMLElementDeclarationKind
- #define NSXMLElementDeclarationKind DDXMLElementDeclarationKind
-#endif
-#ifndef NSXMLNotationDeclarationKind
- #define NSXMLNotationDeclarationKind DDXMLNotationDeclarationKind
-#endif
-
-#ifndef NSXMLNodeOptionsNone
- #define NSXMLNodeOptionsNone DDXMLNodeOptionsNone
-#endif
-#ifndef NSXMLNodeExpandEmptyElement
- #define NSXMLNodeExpandEmptyElement DDXMLNodeExpandEmptyElement
-#endif
-#ifndef NSXMLNodeCompactEmptyElement
- #define NSXMLNodeCompactEmptyElement DDXMLNodeCompactEmptyElement
-#endif
-#ifndef NSXMLNodePrettyPrint
- #define NSXMLNodePrettyPrint DDXMLNodePrettyPrint
-#endif
-
-#endif
View
67 KissXML/DDXMLDocument.h
@@ -1,67 +0,0 @@
-#import <Foundation/Foundation.h>
-#import "DDXMLElement.h"
-#import "DDXMLNode.h"
-
-
-enum {
- DDXMLDocumentXMLKind = 0,
- DDXMLDocumentXHTMLKind,
- DDXMLDocumentHTMLKind,
- DDXMLDocumentTextKind
-};
-typedef NSUInteger DDXMLDocumentContentKind;
-
-@interface DDXMLDocument : DDXMLNode
-{
-}
-
-- (id)initWithXMLString:(NSString *)string options:(NSUInteger)mask error:(NSError **)error;
-//- (id)initWithContentsOfURL:(NSURL *)url options:(NSUInteger)mask error:(NSError **)error;
-- (id)initWithData:(NSData *)data options:(NSUInteger)mask error:(NSError **)error;
-//- (id)initWithRootElement:(DDXMLElement *)element;
-
-//+ (Class)replacementClassForClass:(Class)cls;
-
-//- (void)setCharacterEncoding:(NSString *)encoding; //primitive
-//- (NSString *)characterEncoding; //primitive
-
-//- (void)setVersion:(NSString *)version;
-//- (NSString *)version;
-
-//- (void)setStandalone:(BOOL)standalone;
-//- (BOOL)isStandalone;
-
-//- (void)setDocumentContentKind:(DDXMLDocumentContentKind)kind;
-//- (DDXMLDocumentContentKind)documentContentKind;
-
-//- (void)setMIMEType:(NSString *)MIMEType;
-//- (NSString *)MIMEType;
-
-//- (void)setDTD:(DDXMLDTD *)documentTypeDeclaration;
-//- (DDXMLDTD *)DTD;
-
-//- (void)setRootElement:(DDXMLNode *)root;
-- (DDXMLElement *)rootElement;
-
-//- (void)insertChild:(DDXMLNode *)child atIndex:(NSUInteger)index;
-
-//- (void)insertChildren:(NSArray *)children atIndex:(NSUInteger)index;
-
-//- (void)removeChildAtIndex:(NSUInteger)index;
-
-//- (void)setChildren:(NSArray *)children;
-
-//- (void)addChild:(DDXMLNode *)child;
-
-//- (void)replaceChildAtIndex:(NSUInteger)index withNode:(DDXMLNode *)node;
-
-- (NSData *)XMLData;
-- (NSData *)XMLDataWithOptions:(NSUInteger)options;
-
-//- (id)objectByApplyingXSLT:(NSData *)xslt arguments:(NSDictionary *)arguments error:(NSError **)error;
-//- (id)objectByApplyingXSLTString:(NSString *)xslt arguments:(NSDictionary *)arguments error:(NSError **)error;
-//- (id)objectByApplyingXSLTAtURL:(NSURL *)xsltURL arguments:(NSDictionary *)argument error:(NSError **)error;
-
-//- (BOOL)validateAndReturnError:(NSError **)error;
-
-@end
View
111 KissXML/DDXMLDocument.m
@@ -1,111 +0,0 @@
-#import "DDXMLDocument.h"
-#import "NSStringAdditions.h"
-#import "DDXMLPrivate.h"
-
-
-@implementation DDXMLDocument
-
-/**
- * Returns a DDXML wrapper object for the given primitive node.
- * The given node MUST be non-NULL and of the proper type.
- *
- * If the wrapper object already exists, it is retained/autoreleased and returned.
- * Otherwise a new wrapper object is alloc/init/autoreleased and returned.
-**/
-+ (id)nodeWithPrimitive:(xmlKindPtr)kindPtr
-{
- // If a wrapper object already exists, the _private variable is pointing to it.
-
- xmlDocPtr doc = (xmlDocPtr)kindPtr;
- if(doc->_private == NULL)
- return [[[DDXMLDocument alloc] initWithCheckedPrimitive:kindPtr] autorelease];
- else
- return [[((DDXMLDocument *)(doc->_private)) retain] autorelease];
-}
-
-/**
- * Returns a DDXML wrapper object for the given primitive node.
- * The given node MUST be non-NULL and of the proper type.
- *
- * The given node is checked, meaning a wrapper object for it does not already exist.
-**/
-- (id)initWithCheckedPrimitive:(xmlKindPtr)kindPtr
-{
- self = [super initWithCheckedPrimitive:kindPtr];
- return self;
-}
-
-/**
- * Initializes and returns a DDXMLDocument object created from an NSData object.
- *
- * Returns an initialized DDXMLDocument object, or nil if initialization fails
- * because of parsing errors or other reasons.
-**/
-- (id)initWithXMLString:(NSString *)string options:(NSUInteger)mask error:(NSError **)error
-{
- return [self initWithData:[string dataUsingEncoding:NSUTF8StringEncoding] options:mask error:error];
-}
-
-/**
- * Initializes and returns a DDXMLDocument object created from an NSData object.
- *
- * Returns an initialized DDXMLDocument object, or nil if initialization fails
- * because of parsing errors or other reasons.
-**/
-- (id)initWithData:(NSData *)data options:(NSUInteger)mask error:(NSError **)error
-{
- if(data == nil || [data length] == 0)
- {
- if(error) *error = [NSError errorWithDomain:@"DDXMLErrorDomain" code:0 userInfo:nil];
-
- [self release];
- return nil;
- }
-
- // Even though xmlKeepBlanksDefault(0) is called in DDXMLNode's initialize method,
- // it has been documented that this call seems to get reset on the iPhone:
- // http://code.google.com/p/kissxml/issues/detail?id=8
- //
- // Therefore, we call it again here just to be safe.
- xmlKeepBlanksDefault(0);
-
- xmlDocPtr doc = xmlParseMemory([data bytes], [data length]);
- if(doc == NULL)
- {
- if(error) *error = [NSError errorWithDomain:@"DDXMLErrorDomain" code:1 userInfo:nil];
-
- [self release];
- return nil;
- }
-
- return [self initWithCheckedPrimitive:(xmlKindPtr)doc];
-}
-
-/**
- * Returns the root element of the receiver.
-**/
-- (DDXMLElement *)rootElement
-{
- xmlDocPtr doc = (xmlDocPtr)genericPtr;
-
- // doc->children is a list containing possibly comments, DTDs, etc...
-
- xmlNodePtr rootNode = xmlDocGetRootElement(doc);
-
- if(rootNode != NULL)
- return [DDXMLElement nodeWithPrimitive:(xmlKindPtr)rootNode];
- else
- return nil;
-}
-
-- (NSData *)XMLData
-{
- return [[self XMLString] dataUsingEncoding:NSUTF8StringEncoding];
-}
-
-- (NSData *)XMLDataWithOptions:(NSUInteger)options
-{
- return [[self XMLStringWithOptions:options] dataUsingEncoding:NSUTF8StringEncoding];
-}
-
-@end
View
49 KissXML/DDXMLElement.h
@@ -1,49 +0,0 @@
-#import <Foundation/Foundation.h>
-#import "DDXMLNode.h"
-
-
-@interface DDXMLElement : DDXMLNode
-{
-}
-
-- (id)initWithName:(NSString *)name;
-- (id)initWithName:(NSString *)name URI:(NSString *)URI;
-- (id)initWithName:(NSString *)name stringValue:(NSString *)string;
-- (id)initWithXMLString:(NSString *)string error:(NSError **)error;
-
-#pragma mark --- Elements by name ---
-
-- (NSArray *)elementsForName:(NSString *)name;
-- (NSArray *)elementsForLocalName:(NSString *)localName URI:(NSString *)URI;
-
-#pragma mark --- Attributes ---
-
-- (void)addAttribute:(DDXMLNode *)attribute;
-- (void)removeAttributeForName:(NSString *)name;
-- (void)setAttributes:(NSArray *)attributes;
-//- (void)setAttributesAsDictionary:(NSDictionary *)attributes;
-- (NSArray *)attributes;
-- (DDXMLNode *)attributeForName:(NSString *)name;
-//- (DDXMLNode *)attributeForLocalName:(NSString *)localName URI:(NSString *)URI;
-
-#pragma mark --- Namespaces ---
-
-- (void)addNamespace:(DDXMLNode *)aNamespace;
-- (void)removeNamespaceForPrefix:(NSString *)name;
-- (void)setNamespaces:(NSArray *)namespaces;
-- (NSArray *)namespaces;
-- (DDXMLNode *)namespaceForPrefix:(NSString *)prefix;
-- (DDXMLNode *)resolveNamespaceForName:(NSString *)name;
-- (NSString *)resolvePrefixForNamespaceURI:(NSString *)namespaceURI;
-
-#pragma mark --- Children ---
-
-- (void)insertChild:(DDXMLNode *)child atIndex:(NSUInteger)index;
-//- (void)insertChildren:(NSArray *)children atIndex:(NSUInteger)index;
-- (void)removeChildAtIndex:(NSUInteger)index;
-- (void)setChildren:(NSArray *)children;
-- (void)addChild:(DDXMLNode *)child;
-//- (void)replaceChildAtIndex:(NSUInteger)index withNode:(DDXMLNode *)node;
-//- (void)normalizeAdjacentTextNodesPreservingCDATA:(BOOL)preserve;
-
-@end
View
629 KissXML/DDXMLElement.m
@@ -1,629 +0,0 @@
-#import "DDXMLElement.h"
-#import "NSStringAdditions.h"
-#import "DDXMLPrivate.h"
-
-
-@implementation DDXMLElement
-
-/**
- * Returns a DDXML wrapper object for the given primitive node.
- * The given node MUST be non-NULL and of the proper type.
- *
- * If the wrapper object already exists, it is retained/autoreleased and returned.
- * Otherwise a new wrapper object is alloc/init/autoreleased and returned.
-**/
-+ (id)nodeWithPrimitive:(xmlKindPtr)kindPtr
-{
- // If a wrapper object already exists, the _private variable is pointing to it.
-
- xmlNodePtr node = (xmlNodePtr)kindPtr;
- if(node->_private == NULL)
- return [[[DDXMLElement alloc] initWithCheckedPrimitive:kindPtr] autorelease];
- else
- return [[((DDXMLElement *)(node->_private)) retain] autorelease];
-}
-
-/**
- * Returns a DDXML wrapper object for the given primitive node.
- * The given node MUST be non-NULL and of the proper type.
- *
- * The given node is checked, meaning a wrapper object for it does not already exist.
-**/
-- (id)initWithCheckedPrimitive:(xmlKindPtr)kindPtr
-{
- self = [super initWithCheckedPrimitive:kindPtr];
- return self;
-}
-
-- (id)initWithName:(NSString *)name
-{
- // Note: Make every guarantee that genericPtr is not null
-
- xmlNodePtr node = xmlNewNode(NULL, [name xmlChar]);
- if(node == NULL)
- {
- [self release];
- return nil;
- }
-
- return [self initWithCheckedPrimitive:(xmlKindPtr)node];
-}
-
-- (id)initWithName:(NSString *)name URI:(NSString *)URI
-{
- // Note: Make every guarantee that genericPtr is not null
-
- xmlNodePtr node = xmlNewNode(NULL, [name xmlChar]);
- if(node == NULL)
- {
- [self release];
- return nil;
- }
-
- DDXMLElement *result = [self initWithCheckedPrimitive:(xmlKindPtr)node];
- [result setURI:URI];
-
- return result;
-}
-
-- (id)initWithName:(NSString *)name stringValue:(NSString *)string
-{
- // Note: Make every guarantee that genericPtr is not null
-
- xmlNodePtr node = xmlNewNode(NULL, [name xmlChar]);
- if(node == NULL)
- {
- [self release];
- return nil;
- }
-
- DDXMLElement *result = [self initWithCheckedPrimitive:(xmlKindPtr)node];
- [result setStringValue:string];
-
- return result;
-}
-
-- (id)initWithXMLString:(NSString *)string error:(NSError **)error
-{
- DDXMLDocument *doc = [[DDXMLDocument alloc] initWithXMLString:string options:0 error:error];
- if(doc == nil)
- {
- [self release];
- return nil;
- }
-
- DDXMLElement *result = [doc rootElement];
- [result detach];
- [doc release];
-
- [self release];
- return [result retain];
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-#pragma mark Elements by name
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-/**
- * Returns the child element nodes (as DDXMLElement objects) of the receiver that have a specified name.
- *
- * If name is a qualified name, then this method invokes elementsForLocalName:URI: with the URI parameter set to
- * the URI associated with the prefix. Otherwise comparison is based on string equality of the qualified or
- * non-qualified name.
-**/
-- (NSArray *)elementsForName:(NSString *)name
-{
- if(name == nil) return [NSArray array];
-
- // We need to check to see if name has a prefix.
- // If it does have a prefix, we need to figure out what the corresponding URI is for that prefix,
- // and then search for any elements that have the same name (including prefix) OR have the same URI.
- // Otherwise we loop through the children as usual and do a string compare on the name
-
- NSString *prefix = [[self class] prefixForName:name];
- if([prefix length] > 0)
- {
- xmlNodePtr node = (xmlNodePtr)genericPtr;
- xmlNsPtr ns = xmlSearchNs(node->doc, node, [prefix xmlChar]);
- if(ns != NULL)
- {
- NSString *uri = [NSString stringWithUTF8String:((const char *)ns->href)];
- return [self elementsWithName:name uri:uri];
- }
-
- // Note: We used xmlSearchNs instead of resolveNamespaceForName: - avoid creating wrapper objects when possible
- }
-
- return [self elementsWithName:name uri:nil];
-}
-
-- (NSArray *)elementsForLocalName:(NSString *)localName URI:(NSString *)URI
-{
- if(localName == nil) return [NSArray array];
-
- // We need to figure out what the prefix is for this URI.
- // Then we search for elements that are named prefix:localName OR (named localName AND have the given URI).
-
- NSString *prefix = [self resolvePrefixForNamespaceURI:URI];
- if(prefix != nil)
- {
- NSString *name = [NSString stringWithFormat:@"%@:%@", prefix, localName];
-
- return [self elementsWithName:name uri:URI];
- }
- else
- {
- return [self elementsWithName:localName uri:URI];
- }
-}
-
-/**
- * Helper method elementsForName and elementsForLocalName:URI: so work isn't duplicated.
- * The name parameter is required, URI is optional.
-**/
-- (NSArray *)elementsWithName:(NSString *)name uri:(NSString *)uri
-{
- // Supplied: name, !uri : match: name
- // Supplied: p:name, uri : match: p:name || (name && uri)
- // Supplied: name, uri : match: name && uri
-
- NSMutableArray *result = [NSMutableArray array];
-
- xmlNodePtr node = (xmlNodePtr)genericPtr;
-
- BOOL hasPrefix = [[[self class] prefixForName:name] length] > 0;
- NSString *localName = [[self class] localNameForName:name];
-
- xmlNodePtr child = node->children;
- while(child != NULL)
- {
- if(child->type == XML_ELEMENT_NODE)
- {
- BOOL match = NO;
- if(uri == nil)
- {
- match = xmlStrEqual(child->name, [name xmlChar]);
- }
- else
- {
- BOOL nameMatch = xmlStrEqual(child->name, [name xmlChar]);
- BOOL localNameMatch = xmlStrEqual(child->name, [localName xmlChar]);
-
- BOOL uriMatch = NO;
- if(child->ns != NULL)
- {
- uriMatch = xmlStrEqual(child->ns->href, [uri xmlChar]);
- }
-
- if(hasPrefix)
- match = nameMatch || (localNameMatch && uriMatch);
- else
- match = nameMatch && uriMatch;
- }
-
- if(match)
- {
- [result addObject:[DDXMLElement nodeWithPrimitive:(xmlKindPtr)child]];
- }
- }
-
- child = child->next;
- }
-
- return result;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-#pragma mark Attributes
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-- (void)addAttribute:(DDXMLNode *)attribute
-{
- // NSXML version uses this same assertion
- DDCheck([attribute hasParent] == NO, @"Cannot add an attribute with a parent; detach or copy first");
- DDCheck([attribute isXmlAttrPtr], @"Not an attribute");
-
- // xmlNodePtr xmlAddChild(xmlNodePtr parent, xmlNodePtr cur)
- // Add a new node to @parent, at the end of the child (or property) list merging
- // adjacent TEXT nodes (in which case @cur is freed). If the new node is ATTRIBUTE, it is added
- // into properties instead of children. If there is an attribute with equal name, it is first destroyed.
-
- [self removeAttributeForName:[attribute name]];
-
- xmlAddChild((xmlNodePtr)genericPtr, (xmlNodePtr)attribute->genericPtr);
-}
-
-- (void)removeAttribute:(xmlAttrPtr)attr
-{
- [[self class] removeAttribute:attr fromNode:(xmlNodePtr)genericPtr];
-}
-
-- (void)removeAllAttributes
-{
- [[self class] removeAllAttributesFromNode:(xmlNodePtr)genericPtr];
-}
-
-- (void)removeAttributeForName:(NSString *)name
-{
- // If we use xmlUnsetProp, then the attribute will be automatically freed.
- // We don't want this unless no other wrapper objects have a reference to the property.
-
- xmlAttrPtr attr = ((xmlNodePtr)genericPtr)->properties;
- while(attr != NULL)
- {
- if(xmlStrEqual(attr->name, [name xmlChar]))
- {
- [self removeAttribute:attr];
- return;
- }
- attr = attr->next;
- }
-}
-
-- (NSArray *)attributes
-{
- NSMutableArray *result = [NSMutableArray array];
-
- xmlAttrPtr attr = ((xmlNodePtr)genericPtr)->properties;
- while(attr != NULL)
- {
- [result addObject:[DDXMLNode nodeWithPrimitive:(xmlKindPtr)attr]];
-
- attr = attr->next;
- }
-
- return result;
-}
-
-- (DDXMLNode *)attributeForName:(NSString *)name
-{
- const xmlChar *attrName = [name xmlChar];
-
- xmlAttrPtr attr = ((xmlNodePtr)genericPtr)->properties;
- while(attr != NULL)
- {
- if(attr->ns && attr->ns->prefix)
- {
- // If the attribute name was originally something like "xml:quack",
- // then attr->name is "quack" and attr->ns->prefix is "xml".
- //
- // So if the user is searching for "xml:quack" we need to take the prefix into account.
- // Note that "xml:quack" is what would be printed if we output the attribute.
-
- if(xmlStrQEqual(attr->ns->prefix, attr->name, attrName))
- {
- return [DDXMLNode nodeWithPrimitive:(xmlKindPtr)attr];
- }
- }
- else
- {
- if(xmlStrEqual(attr->name, attrName))
- {
- return [DDXMLNode nodeWithPrimitive:(xmlKindPtr)attr];
- }
- }
-
- attr = attr->next;
- }
- return nil;
-}
-
-/**
- * Sets the list of attributes for the element.
- * Any previously set attributes are removed.
-**/
-- (void)setAttributes:(NSArray *)attributes
-{
- [self removeAllAttributes];
-
- NSUInteger i;
- for(i = 0; i < [attributes count]; i++)
- {
- DDXMLNode *attribute = [attributes objectAtIndex:i];
- [self addAttribute:attribute];
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-#pragma mark Namespaces
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-- (void)addNamespace:(DDXMLNode *)namespace
-{
- // NSXML version uses this same assertion
- DDCheck([namespace hasParent] == NO, @"Cannot add a namespace with a parent; detach or copy first");
- DDCheck([namespace isXmlNsPtr], @"Not a namespace");
-
- // Beware: [namespace prefix] does NOT return what you might expect. Use [namespace name] instead.
-
- [self removeNamespaceForPrefix:[namespace name]];
-
- xmlNsPtr currentNs = ((xmlNodePtr)genericPtr)->nsDef;
- if(currentNs == NULL)
- {
- ((xmlNodePtr)genericPtr)->nsDef = (xmlNsPtr)namespace->genericPtr;
- }
- else
- {
- while(currentNs != NULL)
- {
- if(currentNs->next == NULL)
- {
- currentNs->next = (xmlNsPtr)namespace->genericPtr;
- break; // Yes this break is needed
- }
- currentNs = currentNs->next;
- }
- }
-
- // The xmlNs structure doesn't contain a reference to the parent, so we manage our own reference
- namespace->nsParentPtr = (xmlNodePtr)genericPtr;
-
- // Did we just add a default namespace
- if([[namespace name] isEqualToString:@""])
- {
- ((xmlNodePtr)genericPtr)->ns = (xmlNsPtr)namespace->genericPtr;
-
- // Note: The removeNamespaceForPrefix method above properly handled removing any previous default namespace
- }
-}
-
-- (void)removeNamespace:(xmlNsPtr)ns
-{
- [[self class] removeNamespace:ns fromNode:(xmlNodePtr)genericPtr];
-}
-
-- (void)removeAllNamespaces
-{
- [[self class] removeAllNamespacesFromNode:(xmlNodePtr)genericPtr];
-}
-
-- (void)removeNamespaceForPrefix:(NSString *)name
-{
- // If name is nil or the empty string, the user is wishing to remove the default namespace
- const xmlChar *xmlName = [name length] > 0 ? [name xmlChar] : NULL;
-
- xmlNsPtr ns = ((xmlNodePtr)genericPtr)->nsDef;
- while(ns != NULL)
- {
- if(xmlStrEqual(ns->prefix, xmlName))
- {
- [self removeNamespace:ns];
- break;
- }
- ns = ns->next;
- }
-
- // Note: The removeNamespace method properly handles the situation where the namespace is the default namespace
-}
-
-- (NSArray *)namespaces
-{
- NSMutableArray *result = [NSMutableArray array];
-
- xmlNsPtr ns = ((xmlNodePtr)genericPtr)->nsDef;
- while(ns != NULL)
- {
- [result addObject:[DDXMLNode nodeWithPrimitive:ns nsParent:(xmlNodePtr)genericPtr]];
-
- ns = ns->next;
- }
-
- return result;
-}
-
-- (DDXMLNode *)namespaceForPrefix:(NSString *)prefix
-{
- // If the prefix is nil or the empty string, the user is requesting the default namespace
-
- if([prefix length] == 0)
- {
- // Requesting the default namespace
- xmlNsPtr ns = ((xmlNodePtr)genericPtr)->ns;
- if(ns != NULL)
- {
- return [DDXMLNode nodeWithPrimitive:ns nsParent:(xmlNodePtr)genericPtr];
- }
- }
- else
- {
- xmlNsPtr ns = ((xmlNodePtr)genericPtr)->nsDef;
- while(ns != NULL)
- {
- if(xmlStrEqual(ns->prefix, [prefix xmlChar]))
- {
- return [DDXMLNode nodeWithPrimitive:ns nsParent:(xmlNodePtr)genericPtr];
- }
- ns = ns->next;
- }
- }
-
- return nil;
-}
-
-- (void)setNamespaces:(NSArray *)namespaces
-{
- [self removeAllNamespaces];
-
- NSUInteger i;
- for(i = 0; i < [namespaces count]; i++)
- {
- DDXMLNode *namespace = [namespaces objectAtIndex:i];
- [self addNamespace:namespace];
- }
-}
-
-/**
- * Recursively searches the given node for the given namespace
-**/
-+ (DDXMLNode *)resolveNamespaceForPrefix:(NSString *)prefix atNode:(xmlNodePtr)nodePtr
-{
- if(nodePtr == NULL) return nil;
-
- xmlNsPtr ns = nodePtr->nsDef;
- while(ns != NULL)
- {
- if(xmlStrEqual(ns->prefix, [prefix xmlChar]))
- {
- return [DDXMLNode nodeWithPrimitive:ns nsParent:nodePtr];
- }
- ns = ns->next;
- }
-
- return [self resolveNamespaceForPrefix:prefix atNode:nodePtr->parent];
-}
-
-/**
- * Returns the namespace node with the prefix matching the given qualified name.
- * Eg: You pass it "a:dog", it returns the namespace (defined in this node or parent nodes) that has the "a" prefix.
-**/
-- (DDXMLNode *)resolveNamespaceForName:(NSString *)name
-{
- // If the user passes nil or an empty string for name, they're looking for the default namespace.
- if([name length] == 0)
- {
- return [[self class] resolveNamespaceForPrefix:nil atNode:(xmlNodePtr)genericPtr];
- }
-
- NSString *prefix = [[self class] prefixForName:name];
-
- if([prefix length] > 0)
- {
- // Unfortunately we can't use xmlSearchNs because it returns an xmlNsPtr.
- // This gives us mostly what we want, except we also need to know the nsParent.
- // So we do the recursive search ourselves.
-
- return [[self class] resolveNamespaceForPrefix:prefix atNode:(xmlNodePtr)genericPtr];
- }
-
- return nil;
-}
-
-/**
- * Recursively searches the given node for a namespace with the given URI, and a set prefix.
-**/
-+ (NSString *)resolvePrefixForURI:(NSString *)uri atNode:(xmlNodePtr)nodePtr
-{
- if(nodePtr == NULL) return nil;
-
- xmlNsPtr ns = nodePtr->nsDef;
- while(ns != NULL)
- {
- if(xmlStrEqual(ns->href, [uri xmlChar]))
- {
- if(ns->prefix != NULL)
- {
- return [NSString stringWithUTF8String:((const char *)ns->prefix)];
- }
- }
- ns = ns->next;
- }
-
- return [self resolvePrefixForURI:uri atNode:nodePtr->parent];
-}
-
-/**
- * Returns the prefix associated with the specified URI.
- * Returns a string that is the matching prefix or nil if it finds no matching prefix.
-**/
-- (NSString *)resolvePrefixForNamespaceURI:(NSString *)namespaceURI
-{
- // We can't use xmlSearchNsByHref because it will return xmlNsPtr's with NULL prefixes.
- // We're looking for a definitive prefix for the given URI.
-
- return [[self class] resolvePrefixForURI:namespaceURI atNode:(xmlNodePtr)genericPtr];
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-#pragma mark Children
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-- (void)removeChild:(xmlNodePtr)child
-{
- [[self class] removeChild:child fromNode:(xmlNodePtr)genericPtr];
-}
-
-- (void)removeAllChildren
-{
- [[self class] removeAllChildrenFromNode:(xmlNodePtr)genericPtr];
-}
-
-- (void)removeChildAtIndex:(NSUInteger)index
-{
- NSUInteger i = 0;
-
- xmlNodePtr child = ((xmlNodePtr)genericPtr)->children;
- while(child != NULL)
- {
- // Ignore all but element, comment, text, or processing instruction nodes
- if([[self class] isXmlNodePtr:(xmlKindPtr)child])
- {
- if(i == index)
- {
- [self removeChild:child];
- return;
- }
-
- i++;
- }
- child = child->next;
- }
-}
-
-- (void)addChild:(DDXMLNode *)child
-{
- // NSXML version uses these same assertions
- DDCheck([child hasParent] == NO, @"Cannot add a child that has a parent; detach or copy first");
- DDCheck([child isXmlNodePtr], @"Elements can only have text, elements, processing instructions, and comments as children");
-
- xmlAddChild((xmlNodePtr)genericPtr, (xmlNodePtr)child->genericPtr);
-}
-
-- (void)insertChild:(DDXMLNode *)child atIndex:(NSUInteger)index
-{
- // NSXML version uses these same assertions
- DDCheck([child hasParent] == NO, @"Cannot add a child that has a parent; detach or copy first");
- DDCheck([child isXmlNodePtr], @"Elements can only have text, elements, processing instructions, and comments as children");
-
- NSUInteger i = 0;
-
- xmlNodePtr childNodePtr = ((xmlNodePtr)genericPtr)->children;
- while(childNodePtr != NULL)
- {
- // Ignore all but element, comment, text, or processing instruction nodes
- if([[self class] isXmlNodePtr:(xmlKindPtr)childNodePtr])
- {
- if(i == index)
- {
- xmlAddPrevSibling(childNodePtr, (xmlNodePtr)child->genericPtr);
- return;
- }
-
- i++;
- }
- childNodePtr = childNodePtr->next;
- }
-
- if(i == index)
- {
- xmlAddChild((xmlNodePtr)genericPtr, (xmlNodePtr)child->genericPtr);
- return;
- }
-
- // NSXML version uses this same assertion
- DDCheck(NO, @"index (%u) beyond bounds (%u)", (unsigned)index, (unsigned)++i);
-}
-
-- (void)setChildren:(NSArray *)children
-{
- [self removeAllChildren];
-
- NSUInteger i;
- for(i = 0; i < [children count]; i++)
- {
- DDXMLNode *child = [children objectAtIndex:i];
- [self addChild:child];
- }
-}
-
-@end
View
170 KissXML/DDXMLNode.h
@@ -1,170 +0,0 @@
-#import <Foundation/Foundation.h>
-#import <libxml/tree.h>
-
-@class DDXMLDocument;
-
-
-enum {
- DDXMLInvalidKind = 0,
- DDXMLDocumentKind = XML_DOCUMENT_NODE,
- DDXMLElementKind = XML_ELEMENT_NODE,
- DDXMLAttributeKind = XML_ATTRIBUTE_NODE,
- DDXMLNamespaceKind = XML_NAMESPACE_DECL,
- DDXMLProcessingInstructionKind = XML_PI_NODE,
- DDXMLCommentKind = XML_COMMENT_NODE,
- DDXMLTextKind = XML_TEXT_NODE,
- DDXMLDTDKind = XML_DTD_NODE,
- DDXMLEntityDeclarationKind = XML_ENTITY_DECL,
- DDXMLAttributeDeclarationKind = XML_ATTRIBUTE_DECL,
- DDXMLElementDeclarationKind = XML_ELEMENT_DECL,
- DDXMLNotationDeclarationKind = XML_NOTATION_NODE
-};
-typedef NSUInteger DDXMLNodeKind;
-
-enum {
- DDXMLNodeOptionsNone = 0,
- DDXMLNodeExpandEmptyElement = 1 << 1,
- DDXMLNodeCompactEmptyElement = 1 << 2,
- DDXMLNodePrettyPrint = 1 << 17,
-};
-
-/**
- * DDXMLNode can represent several underlying types, such as xmlNodePtr, xmlDocPtr, xmlAttrPtr, xmlNsPtr, etc.
- * All of these are pointers to structures, and all of those structures start with a pointer, and a type.
- * The xmlKind struct is used as a generic structure, and a stepping stone.
- * We use it to check the type of a structure, and then perform the appropriate cast.
- *
- * For example:
- * if(genericPtr->type == XML_ATTRIBUTE_NODE)
- * {
- * xmlAttrPtr attr = (xmlAttrPtr)genericPtr;
- * // Do something with attr
- * }
-**/
-struct _xmlKind {
- void * ignore;
- xmlElementType type;
-};
-typedef struct _xmlKind *xmlKindPtr;
-
-/**
- * Most xml types all start with this standard structure. In fact, all do except the xmlNsPtr.
- * We will occasionally take advantage of this to simplify code when the code wouldn't vary from type to type.
- * Obviously, you cannnot cast a xmlNsPtr to a xmlStdPtr.
-**/
-struct _xmlStd {
- void * _private;
- xmlElementType type;
- const xmlChar *name;
- struct _xmlNode *children;
- struct _xmlNode *last;
- struct _xmlNode *parent;
- struct _xmlStd *next;
- struct _xmlStd *prev;
- struct _xmlDoc *doc;
-};
-typedef struct _xmlStd *xmlStdPtr;
-
-@interface DDXMLNode : NSObject <NSCopying>
-{
- // Every DDXML object is simply a wrapper around an underlying libxml node
- xmlKindPtr genericPtr;
-
- // The xmlNsPtr type doesn't store a reference to it's parent
- // This is here to fix that problem, and make this class more compatible with the NSXML classes
- xmlNodePtr nsParentPtr;
-}
-
-//- (id)initWithKind:(DDXMLNodeKind)kind;
-
-//- (id)initWithKind:(DDXMLNodeKind)kind options:(NSUInteger)options;
-
-//+ (id)document;
-
-//+ (id)documentWithRootElement:(DDXMLElement *)element;
-
-+ (id)elementWithName:(NSString *)name;
-
-+ (id)elementWithName:(NSString *)name URI:(NSString *)URI;
-
-+ (id)elementWithName:(NSString *)name stringValue:(NSString *)string;
-
-+ (id)elementWithName:(NSString *)name children:(NSArray *)children attributes:(NSArray *)attributes;
-
-+ (id)attributeWithName:(NSString *)name stringValue:(NSString *)stringValue;
-
-+ (id)attributeWithName:(NSString *)name URI:(NSString *)URI stringValue:(NSString *)stringValue;
-
-+ (id)namespaceWithName:(NSString *)name stringValue:(NSString *)stringValue;
-
-+ (id)processingInstructionWithName:(NSString *)name stringValue:(NSString *)stringValue;
-
-+ (id)commentWithStringValue:(NSString *)stringValue;
-
-+ (id)textWithStringValue:(NSString *)stringValue;
-
-//+ (id)DTDNodeWithXMLString:(NSString *)string;
-
-#pragma mark --- Properties ---
-
-- (DDXMLNodeKind)kind;
-
-- (void)setName:(NSString *)name;
-- (NSString *)name;
-
-//- (void)setObjectValue:(id)value;
-//- (id)objectValue;
-
-- (void)setStringValue:(NSString *)string;
-//- (void)setStringValue:(NSString *)string resolvingEntities:(BOOL)resolve;
-- (NSString *)stringValue;
-
-#pragma mark --- Tree Navigation ---
-
-- (NSUInteger)index;
-
-- (NSUInteger)level;
-
-- (DDXMLDocument *)rootDocument;
-
-- (DDXMLNode *)parent;
-- (NSUInteger)childCount;
-- (NSArray *)children;
-- (DDXMLNode *)childAtIndex:(NSUInteger)index;
-
-- (DDXMLNode *)previousSibling;
-- (DDXMLNode *)nextSibling;
-
-- (DDXMLNode *)previousNode;
-- (DDXMLNode *)nextNode;
-
-- (void)detach;
-
-- (NSString *)XPath;
-
-#pragma mark --- QNames ---
-
-- (NSString *)localName;
-- (NSString *)prefix;
-
-- (void)setURI:(NSString *)URI;
-- (NSString *)URI;
-
-+ (NSString *)localNameForName:(NSString *)name;
-+ (NSString *)prefixForName:(NSString *)name;
-//+ (DDXMLNode *)predefinedNamespaceForPrefix:(NSString *)name;
-
-#pragma mark --- Output ---
-
-- (NSString *)description;
-- (NSString *)XMLString;
-- (NSString *)XMLStringWithOptions:(NSUInteger)options;
-//- (NSString *)canonicalXMLStringPreservingComments:(BOOL)comments;
-
-#pragma mark --- XPath/XQuery ---
-
-- (NSArray *)nodesForXPath:(NSString *)xpath error:(NSError **)error;
-//- (NSArray *)objectsForXQuery:(NSString *)xquery constants:(NSDictionary *)constants error:(NSError **)error;
-//- (NSArray *)objectsForXQuery:(NSString *)xquery error:(NSError **)error;
-
-@end
View
1,808 KissXML/DDXMLNode.m
@@ -1,1808 +0,0 @@
-#import "DDXMLNode.h"
-#import "DDXMLElement.h"
-#import "DDXMLDocument.h"
-#import "NSStringAdditions.h"
-#import "DDXMLPrivate.h"
-
-#import <libxml/xpath.h>
-#import <libxml/xpathInternals.h>
-
-
-@implementation DDXMLNode
-
-static void MyErrorHandler(void * userData, xmlErrorPtr error);
-
-+ (void)initialize
-{
- static BOOL initialized = NO;
- if(!initialized)
- {
- // Redirect error output to our own function (don't clog up the console)
- initGenericErrorDefaultFunc(NULL);
- xmlSetStructuredErrorFunc(NULL, MyErrorHandler);
-
- // Tell libxml not to keep ignorable whitespace (such as node indentation, formatting, etc).
- // NSXML ignores such whitespace.
- // This also has the added benefit of taking up less RAM when parsing formatted XML documents.
- xmlKeepBlanksDefault(0);
-
- initialized = YES;
- }
-}
-
-+ (id)elementWithName:(NSString *)name
-{
- return [[[DDXMLElement alloc] initWithName:name] autorelease];
-}
-
-+ (id)elementWithName:(NSString *)name stringValue:(NSString *)string
-{
- return [[[DDXMLElement alloc] initWithName:name stringValue:string] autorelease];
-}
-
-+ (id)elementWithName:(NSString *)name children:(NSArray *)children attributes:(NSArray *)attributes
-{
- DDXMLElement *result = [[[DDXMLElement alloc] initWithName:name] autorelease];
- [result setChildren:children];
- [result setAttributes:attributes];
-
- return result;
-}
-
-+ (id)elementWithName:(NSString *)name URI:(NSString *)URI
-{
- return [[[DDXMLElement alloc] initWithName:name URI:URI] autorelease];
-}
-
-+ (id)attributeWithName:(NSString *)name stringValue:(NSString *)stringValue
-{
- xmlAttrPtr attr = xmlNewProp(NULL, [name xmlChar], [stringValue xmlChar]);
-
- if(attr == NULL) return nil;
-
- return [[[DDXMLNode alloc] initWithCheckedPrimitive:(xmlKindPtr)attr] autorelease];
-}
-
-+ (id)attributeWithName:(NSString *)name URI:(NSString *)URI stringValue:(NSString *)stringValue
-{
- xmlAttrPtr attr = xmlNewProp(NULL, [name xmlChar], [stringValue xmlChar]);
-
- if(attr == NULL) return nil;
-
- DDXMLNode *result = [[[DDXMLNode alloc] initWithCheckedPrimitive:(xmlKindPtr)attr] autorelease];
- [result setURI:URI];
-
- return result;
-}
-
-+ (id)namespaceWithName:(NSString *)name stringValue:(NSString *)stringValue
-{
- // If the user passes a nil or empty string name, they are trying to create a default namespace
- const xmlChar *xmlName = [name length] > 0 ? [name xmlChar] : NULL;
-
- xmlNsPtr ns = xmlNewNs(NULL, [stringValue xmlChar], xmlName);
-
- if(ns == NULL) return nil;
-
- return [[[DDXMLNode alloc] initWithCheckedPrimitive:(xmlKindPtr)ns] autorelease];
-}
-
-+ (id)processingInstructionWithName:(NSString *)name stringValue:(NSString *)stringValue
-{
- xmlNodePtr procInst = xmlNewPI([name xmlChar], [stringValue xmlChar]);
-
- if(procInst == NULL) return nil;
-
- return [[[DDXMLNode alloc] initWithCheckedPrimitive:(xmlKindPtr)procInst] autorelease];
-}
-
-+ (id)commentWithStringValue:(NSString *)stringValue
-{
- xmlNodePtr comment = xmlNewComment([stringValue xmlChar]);
-
- if(comment == NULL) return nil;
-
- return [[[DDXMLNode alloc] initWithCheckedPrimitive:(xmlKindPtr)comment] autorelease];
-}
-
-+ (id)textWithStringValue:(NSString *)stringValue
-{
- xmlNodePtr text = xmlNewText([stringValue xmlChar]);
-
- if(text == NULL) return nil;
-
- return [[[DDXMLNode alloc] initWithCheckedPrimitive:(xmlKindPtr)text] autorelease];
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-#pragma mark Init, Dealloc
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-+ (id)nodeWithUnknownPrimitive:(xmlKindPtr)kindPtr
-{
- if(kindPtr->type == XML_DOCUMENT_NODE)
- {
- return [DDXMLDocument nodeWithPrimitive:kindPtr];
- }
- else if(kindPtr->type == XML_ELEMENT_NODE)
- {
- return [DDXMLElement nodeWithPrimitive:kindPtr];
- }
- else
- {
- return [DDXMLNode nodeWithPrimitive:kindPtr];
- }
-}
-
-/**
- * Returns a DDXML wrapper object for the given primitive node.
- * The given node MUST be non-NULL and of the proper type.
- *
- * If the wrapper object already exists, it is retained/autoreleased and returned.
- * Otherwise a new wrapper object is alloc/init/autoreleased and returned.
-**/
-+ (id)nodeWithPrimitive:(xmlKindPtr)kindPtr
-{
- // If a wrapper object already exists, the _private variable is pointing to it.
- // Warning: The _private variable is in a different location in the xmlNsPtr
-
- if([self isXmlNsPtr:kindPtr])
- {
- xmlNsPtr ns = (xmlNsPtr)kindPtr;
- if(ns->_private != NULL)
- {
- return [[((DDXMLNode *)(ns->_private)) retain] autorelease];
- }
- }
- else
- {
- xmlStdPtr node = (xmlStdPtr)kindPtr;
- if(node->_private != NULL)
- {
- return [[((DDXMLNode *)(node->_private)) retain] autorelease];
- }
- }
-
- return [[[DDXMLNode alloc] initWithCheckedPrimitive:kindPtr] autorelease];
-}
-
-/**
- * Returns a DDXML wrapper object for the given primitive node.
- * The given node MUST be non-NULL and of the proper type.
- *
- * The given node is checked, meaning a wrapper object for it does not already exist.
-**/
-- (id)initWithCheckedPrimitive:(xmlKindPtr)kindPtr
-{
- if((self = [super init]))
- {
- genericPtr = kindPtr;
- nsParentPtr = NULL;
- [self nodeRetain];
- }
- return self;
-}
-
-/**
- * Returns a DDXML wrapper object for the given primitive node.
- * The given node MUST be non-NULL and of the proper type.
- *
- * If the wrapper object already exists, it is retained/autoreleased and returned.
- * Otherwise a new wrapper object is alloc/init/autoreleased and returned.
-**/
-+ (id)nodeWithPrimitive:(xmlNsPtr)ns nsParent:(xmlNodePtr)parent
-{
- // If a wrapper object already exists, the _private variable is pointing to it.
-
- if(ns->_private == NULL)
- return [[[DDXMLNode alloc] initWithCheckedPrimitive:ns nsParent:parent] autorelease];
- else
- return [[((DDXMLNode *)(ns->_private)) retain] autorelease];
-}
-
-/**
- * Returns a DDXML wrapper object for the given primitive node.
- * The given node MUST be non-NULL and of the proper type.
- *
- * The given node is checked, meaning a wrapper object for it does not already exist.
-**/
-- (id)initWithCheckedPrimitive:(xmlNsPtr)ns nsParent:(xmlNodePtr)parent
-{
- if((self = [super init]))
- {
- genericPtr = (xmlKindPtr)ns;
- nsParentPtr = parent;
- [self nodeRetain];
- }
- return self;
-}
-
-- (void)dealloc
-{
- // Check if genericPtr is NULL
- // This may be the case if, eg, DDXMLElement calls [self release] from it's init method
- if(genericPtr != NULL)
- {
- [self nodeRelease];
- }
- [super dealloc];
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-#pragma mark Copying
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-- (id)copyWithZone:(NSZone *)zone
-{
- if([self isXmlDocPtr])
- {
- xmlDocPtr copyDocPtr = xmlCopyDoc((xmlDocPtr)genericPtr, 1);
-
- if(copyDocPtr == NULL) return nil;
-
- return [[DDXMLDocument alloc] initWithCheckedPrimitive:(xmlKindPtr)copyDocPtr];
- }
-
- if([self isXmlNodePtr])
- {
- xmlNodePtr copyNodePtr = xmlCopyNode((xmlNodePtr)genericPtr, 1);
-
- if(copyNodePtr == NULL) return nil;
-
- if([self isKindOfClass:[DDXMLElement class]])
- return [[DDXMLElement alloc] initWithCheckedPrimitive:(xmlKindPtr)copyNodePtr];
- else
- return [[DDXMLNode alloc] initWithCheckedPrimitive:(xmlKindPtr)copyNodePtr];
- }
-
- if([self isXmlAttrPtr])
- {
- xmlAttrPtr copyAttrPtr = xmlCopyProp(NULL, (xmlAttrPtr)genericPtr);
-
- if(copyAttrPtr == NULL) return nil;
-
- return [[DDXMLNode alloc] initWithCheckedPrimitive:(xmlKindPtr)copyAttrPtr];
- }
-
- if([self isXmlNsPtr])
- {
- xmlNsPtr copyNsPtr = xmlCopyNamespace((xmlNsPtr)genericPtr);
-
- if(copyNsPtr == NULL) return nil;
-
- return [[DDXMLNode alloc] initWithCheckedPrimitive:copyNsPtr nsParent:NULL];
- }
-
- if([self isXmlDtdPtr])
- {
- xmlDtdPtr copyDtdPtr = xmlCopyDtd((xmlDtdPtr)genericPtr);
-
- if(copyDtdPtr == NULL) return nil;
-
- return [[DDXMLNode alloc] initWithCheckedPrimitive:(xmlKindPtr)copyDtdPtr];
- }
-
- return nil;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-#pragma mark Properties
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-- (DDXMLNodeKind)kind
-{
- if(genericPtr != NULL)
- return genericPtr->type;
- else
- return DDXMLInvalidKind;
-}
-
-- (void)setName:(NSString *)name
-{
- if([self isXmlNsPtr])
- {
- xmlNsPtr ns = (xmlNsPtr)genericPtr;
-
- xmlFree((xmlChar *)ns->prefix);
- ns->prefix = xmlStrdup([name xmlChar]);
- }
- else
- {
- // The xmlNodeSetName function works for both nodes and attributes
- xmlNodeSetName((xmlNodePtr)genericPtr, [name xmlChar]);
- }
-}
-
-- (NSString *)name
-{
- if([self isXmlNsPtr])
- {
- xmlNsPtr ns = (xmlNsPtr)genericPtr;
- if(ns->prefix != NULL)
- return [NSString stringWithUTF8String:((const char*)ns->prefix)];
- else
- return @"";
- }
- else
- {
- const char *name = (const char *)((xmlStdPtr)genericPtr)->name;
-
- if(name == NULL)
- return nil;
- else
- return [NSString stringWithUTF8String:name];
- }
-}
-
-- (void)setStringValue:(NSString *)string
-{
- if([self isXmlNsPtr])
- {
- xmlNsPtr ns = (xmlNsPtr)genericPtr;
-
- xmlFree((xmlChar *)ns->href);
- ns->href = xmlEncodeSpecialChars(NULL, [string xmlChar]);
- }
- else if([self isXmlAttrPtr])
- {
- xmlAttrPtr attr = (xmlAttrPtr)genericPtr;
-
- if(attr->children != NULL)
- {
- xmlChar *escapedString = xmlEncodeSpecialChars(attr->doc, [string xmlChar]);
- xmlNodeSetContent((xmlNodePtr)attr, escapedString);
- xmlFree(escapedString);
- }
- else
- {
- xmlNodePtr text = xmlNewText([string xmlChar]);
- attr->children = text;
- }
- }
- else if([self isXmlNodePtr])
- {
- xmlStdPtr node = (xmlStdPtr)genericPtr;
-
- // Setting the content of a node erases any existing child nodes.
- // Therefore, we need to remove them properly first.
- [[self class] removeAllChildrenFromNode:(xmlNodePtr)node];
-
- xmlChar *escapedString = xmlEncodeSpecialChars(node->doc, [string xmlChar]);
- xmlNodeSetContent((xmlNodePtr)node, escapedString);
- xmlFree(escapedString);
- }
-}
-
-/**
- * Returns the content of the receiver as a string value.
- *
- * If the receiver is a node object of element kind, the content is that of any text-node children.
- * This method recursively visits elements nodes and concatenates their text nodes in document order with
- * no intervening spaces.
-**/
-- (NSString *)stringValue
-{
- if([self isXmlNsPtr])
- {
- return [NSString stringWithUTF8String:((const char *)((xmlNsPtr)genericPtr)->href)];
- }
- else if([self isXmlAttrPtr])
- {
- xmlAttrPtr attr = (xmlAttrPtr)genericPtr;
-
- if(attr->children != NULL)
- {
- return [NSString stringWithUTF8String:(const char *)attr->children->content];
- }
-
- return nil;
- }
- else if([self isXmlNodePtr])
- {
- xmlChar *content = xmlNodeGetContent((xmlNodePtr)genericPtr);
-
- NSString *result = [NSString stringWithUTF8String:(const char *)content];
-
- xmlFree(content);
- return result;
- }
-
- return nil;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-#pragma mark Tree Navigation
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-/**
- * Returns the index of the receiver identifying its position relative to its sibling nodes.
- * The first child node of a parent has an index of zero.
-**/
-- (NSUInteger)index
-{
- if([self isXmlNsPtr])
- {
- // The xmlNsPtr has no prev pointer, so we have to search from the parent
- if(nsParentPtr == NULL) return 0;
-
- xmlNsPtr currentNs = nsParentPtr->nsDef;
-
- NSUInteger result = 0;
- while(currentNs != NULL)
- {
- if(currentNs == (xmlNsPtr)genericPtr)
- {
- return result;
- }
- result++;
- currentNs = currentNs->next;
- }
- return 0;
- }
- else
- {
- xmlStdPtr node = ((xmlStdPtr)genericPtr)->prev;
-
- NSUInteger result = 0;
- while(node != NULL)
- {
- result++;
- node = node->prev;
- }
-
- return result;
- }
-}
-
-/**
- * Returns the nesting level of the receiver within the tree hierarchy.
- * The root element of a document has a nesting level of one.
-**/
-- (NSUInteger)level
-{
- xmlNodePtr currentNode;
- if([self isXmlNsPtr])
- currentNode = nsParentPtr;
- else
- currentNode = ((xmlStdPtr)genericPtr)->parent;
-
- NSUInteger result = 0;
- while(currentNode != NULL)
- {
- result++;
- currentNode = currentNode->parent;
- }
-
- return result;
-}
-
-/**
- * Returns the DDXMLDocument object containing the root element and representing the XML document as a whole.
- * If the receiver is a standalone node (that is, a node at the head of a detached branch of the tree), this
- * method returns nil.
-**/
-- (DDXMLDocument *)rootDocument
-{
- xmlStdPtr node;
- if([self isXmlNsPtr])
- node = (xmlStdPtr)nsParentPtr;
- else
- node = (xmlStdPtr)genericPtr;
-
- if(node == NULL || node->doc == NULL)
- return nil;
- else
- return [DDXMLDocument nodeWithPrimitive:(xmlKindPtr)node->doc];
-}
-
-/**
- * Returns the parent node of the receiver.
- *
- * Document nodes and standalone nodes (that is, the root of a detached branch of a tree) have no parent, and
- * sending this message to them returns nil. A one-to-one relationship does not always exists between a parent and
- * its children; although a namespace or attribute node cannot be a child, it still has a parent element.
-**/
-- (DDXMLNode *)parent
-{
- if([self isXmlNsPtr])
- {
- if(nsParentPtr == NULL) return nil;
-
- return [DDXMLNode nodeWithUnknownPrimitive:(xmlKindPtr)nsParentPtr];
- }
-
- xmlStdPtr node = (xmlStdPtr)genericPtr;
-
- if(node->parent == NULL) return nil;
-
- return [DDXMLNode nodeWithUnknownPrimitive:(xmlKindPtr)node->parent];
-}
-
-/**
- * Returns the number of child nodes the receiver has.
- * For performance reasons, use this method instead of getting the count from the array returned by children.
-**/
-- (NSUInteger)childCount
-{
- if(![self isXmlDocPtr] && ![self isXmlNodePtr] && ![self isXmlDtdPtr]) return 0;
-
- NSUInteger result = 0;
-
- xmlNodePtr child = ((xmlStdPtr)genericPtr)->children;
- while(child != NULL)
- {
- result++;
- child = child->next;
- }
-
- return result;
-}
-
-/**
- * Returns an immutable array containing the child nodes of the receiver (as DDXMLNode objects).
-**/
-- (NSArray *)children
-{
- if(![self isXmlDocPtr] && ![self isXmlNodePtr] && ![self isXmlDtdPtr]) return nil;
-
- NSMutableArray *result = [NSMutableArray array];
-
- xmlNodePtr child = ((xmlStdPtr)genericPtr)->children;
- while(child != NULL)
- {
- [result addObject:[DDXMLNode nodeWithUnknownPrimitive:(xmlKindPtr)child]];
-
- child = child->next;
- }
-
- return [[result copy] autorelease];
-}
-
-/**
- * Returns the child node of the receiver at the specified location.
- * Returns a DDXMLNode object or nil if the receiver has no children.
- *
- * If the receive has children and index is out of bounds, an exception is raised.
- *
- * The receiver should be a DDXMLNode object representing a document, element, or document type declaration.
- * The returned node object can represent an element, comment, text, or processing instruction.
-**/
-- (DDXMLNode *)childAtIndex:(NSUInteger)index
-{
- if(![self isXmlDocPtr] && ![self isXmlNodePtr] && ![self isXmlDtdPtr]) return nil;
-
- NSUInteger i = 0;
-
- xmlNodePtr child = ((xmlStdPtr)genericPtr)->children;
-
- if(child == NULL)
- {
- // NSXML doesn't raise an exception if there are no children
- return nil;
- }
-
- while(child != NULL)
- {
- if(i == index)
- {
- return [DDXMLNode nodeWithUnknownPrimitive:(xmlKindPtr)child];
- }
-
- i++;
- child = child->next;
- }
-
- // NSXML version uses this same assertion
- DDCheck(NO, @"index (%u) beyond bounds (%u)", (unsigned)index, (unsigned)i);
-
- return nil;
-}
-
-/**
- * Returns the previous DDXMLNode object that is a sibling node to the receiver.
- *
- * This object will have an index value that is one less than the receiver’s.
- * If there are no more previous siblings (that is, other child nodes of the receiver’s parent) the method returns nil.
-**/
-- (DDXMLNode *)previousSibling
-{
- if([self isXmlNsPtr]) return nil;
-
- xmlStdPtr node = (xmlStdPtr)genericPtr;
-
- if(node->prev == NULL) return nil;
-
- return [DDXMLNode nodeWithUnknownPrimitive:(xmlKindPtr)node->prev];
-}
-
-/**
- * Returns the next DDXMLNode object that is a sibling node to the receiver.
- *
- * This object will have an index value that is one more than the receiver’s.
- * If there are no more subsequent siblings (that is, other child nodes of the receiver’s parent) the
- * method returns nil.
-**/
-- (DDXMLNode *)nextSibling
-{
- if([self isXmlNsPtr]) return nil;
-
- xmlStdPtr node = (xmlStdPtr)genericPtr;
-
- if(node->next == NULL) return nil;
-
- return [DDXMLNode nodeWithUnknownPrimitive:(xmlKindPtr)node->next];
-}
-
-/**
- * Returns the previous DDXMLNode object in document order.
- *
- * You use this method to “walk” backward through the tree structure representing an XML document or document section.
- * (Use nextNode to traverse the tree in the opposite direction.) Document order is the natural order that XML
- * constructs appear in markup text. If you send this message to the first node in the tree (that is, the root element),
- * nil is returned. DDXMLNode bypasses namespace and attribute nodes when it traverses a tree in document order.
-**/
-- (DDXMLNode *)previousNode
-{
- if([self isXmlNsPtr] || [self isXmlAttrPtr]) return nil;
-
- // If the node has a previous sibling,
- // then we need the last child of the last child of the last child etc
-
- // Note: Try to accomplish this task without creating dozens of intermediate wrapper objects
-
- xmlStdPtr node = (xmlStdPtr)genericPtr;
- xmlStdPtr previousSibling = node->prev;
-
- if(previousSibling != NULL)
- {
- if(previousSibling->last != NULL)
- {
- xmlNodePtr lastChild = previousSibling->last;
- while(lastChild->last != NULL)
- {
- lastChild = lastChild->last;
- }
-
- return [DDXMLNode nodeWithUnknownPrimitive:(xmlKindPtr)lastChild];
- }
- else
- {
- // The previous sibling has no children, so the previous node is simply the previous sibling
- return [DDXMLNode nodeWithUnknownPrimitive:(xmlKindPtr)previousSibling];
- }
- }
-
- // If there are no previous siblings, then the previous node is simply the parent
-
- // Note: rootNode.parent == docNode
-
- if(node->parent == NULL || node->parent->type == XML_DOCUMENT_NODE)
- return nil;
- else
- return [DDXMLNode nodeWithUnknownPrimitive:(xmlKindPtr)node->parent];
-}
-
-/**
- * Returns the next DDXMLNode object in document order.
- *
- * You use this method to “walk” forward through the tree structure representing an XML document or document section.
- * (Use previousNode to traverse the tree in the opposite direction.) Document order is the natural order that XML
- * constructs appear in markup text. If you send this message to the last node in the tree, nil is returned.
- * DDXMLNode bypasses namespace and attribute nodes when it traverses a tree in document order.
-**/
-- (DDXMLNode *)nextNode
-{
- if([self isXmlNsPtr] || [self isXmlAttrPtr]) return nil;
-
- // If the node has children, then next node is the first child
- DDXMLNode *firstChild = [self childAtIndex:0];
- if(firstChild)
- return firstChild;
-
- // If the node has a next sibling, then next node is the same as next sibling
-
- DDXMLNode *nextSibling = [self nextSibling];
- if(nextSibling)
- return nextSibling;
-
- // There are no children, and no more siblings, so we need to get the next sibling of the parent.
- // If that is nil, we need to get the next sibling of the grandparent, etc.
-
- // Note: Try to accomplish this task without creating dozens of intermediate wrapper objects
-
- xmlNodePtr parent = ((xmlStdPtr)genericPtr)->parent;
- while(parent != NULL)
- {
- xmlNodePtr parentNextSibling = parent->next;
- if(parentNextSibling != NULL)
- return [DDXMLNode nodeWithUnknownPrimitive:(xmlKindPtr)parentNextSibling];
- else
- parent = parent->parent;
- }
-
- return nil;
-}
-
-/**
- * Detaches the receiver from its parent node.
- *
- * This method is applicable to DDXMLNode objects representing elements, text, comments, processing instructions,
- * attributes, and namespaces. Once the node object is detached, you can add it as a child node of another parent.
-**/
-- (void)detach
-{
- if([self isXmlNsPtr])
- {
- if(nsParentPtr != NULL)
- {
- [[self class] removeNamespace:(xmlNsPtr)genericPtr fromNode:nsParentPtr];
- }
- return;
- }
-
- xmlStdPtr node = (xmlStdPtr)genericPtr;
-
- if(node->parent == NULL) return;
-
- if([self isXmlAttrPtr])
- {
- [[self class] detachAttribute:(xmlAttrPtr)node fromNode:node->parent];
- }
- else if([self isXmlNodePtr])
- {
- [[self class] detachChild:(xmlNodePtr)node fromNode:node->parent];
- }
-}
-
-- (NSString *)XPath
-{
- NSMutableString *result = [NSMutableString stringWithCapacity:25];
-
- // Examples:
- // /rootElement[1]/subElement[4]/thisNode[2]
- // topElement/thisNode[2]