diff options
author | stuconnolly <stuart02@gmail.com> | 2010-11-05 21:15:18 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2010-11-05 21:15:18 +0000 |
commit | a9be9780875d249019bd0cdf55eba960fb6f44be (patch) | |
tree | af7477b3e9c964dedf67ff40385f5724713ccc03 | |
parent | f683094590e4a95eb047893584493ed7b32e2a02 (diff) | |
download | sequelpro-a9be9780875d249019bd0cdf55eba960fb6f44be.tar.gz sequelpro-a9be9780875d249019bd0cdf55eba960fb6f44be.tar.bz2 sequelpro-a9be9780875d249019bd0cdf55eba960fb6f44be.zip |
Complete the implementation of supporting MySQL's XML schema format when exporting. Also, restore our old format and give the user the choice during export (defaults to MySQL schema). Completes the implementation of issue #840.
-rw-r--r-- | Interfaces/English.lproj/ExportDialog.xib | 390 | ||||
-rw-r--r-- | Source/SPConstants.h | 7 | ||||
-rw-r--r-- | Source/SPExportController.h | 4 | ||||
-rw-r--r-- | Source/SPExportController.m | 17 | ||||
-rw-r--r-- | Source/SPExportFileUtilities.m | 11 | ||||
-rw-r--r-- | Source/SPExportInitializer.m | 5 | ||||
-rw-r--r-- | Source/SPXMLExporter.h | 28 | ||||
-rw-r--r-- | Source/SPXMLExporter.m | 313 | ||||
-rw-r--r-- | Source/SPXMLExporterDelegate.m | 21 |
9 files changed, 662 insertions, 134 deletions
diff --git a/Interfaces/English.lproj/ExportDialog.xib b/Interfaces/English.lproj/ExportDialog.xib index 17f90795..1d2668e2 100644 --- a/Interfaces/English.lproj/ExportDialog.xib +++ b/Interfaces/English.lproj/ExportDialog.xib @@ -21,8 +21,7 @@ </object> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="2"/> - <integer value="1086"/> + <integer value="1215"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -55,7 +54,7 @@ <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> <string key="NSWindowContentMinSize">{449, 480}</string> <object class="NSView" key="NSWindowView" id="13817034"> - <reference key="NSNextResponder"/> + <nil key="NSNextResponder"/> <int key="NSvFlags">256</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -426,7 +425,6 @@ </object> </object> <string key="NSFrameSize">{451, 480}</string> - <reference key="NSSuperview"/> </object> <string key="NSScreenRect">{{0, 0}, {1680, 1028}}</string> <string key="NSMinSize">{449, 502}</string> @@ -2311,14 +2309,14 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <object class="NSTabViewItem" id="317037302"> <string key="NSIdentifier">xml</string> <object class="NSView" key="NSView" id="855848511"> - <nil key="NSNextResponder"/> + <reference key="NSNextResponder" ref="683006936"/> <int key="NSvFlags">256</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSTextField" id="65089502"> <reference key="NSNextResponder" ref="855848511"/> <int key="NSvFlags">268</int> - <string key="NSFrame">{{11, 200}, {72, 14}}</string> + <string key="NSFrame">{{11, 112}, {72, 14}}</string> <reference key="NSSuperview" ref="855848511"/> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="649072289"> @@ -2334,11 +2332,11 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <object class="NSTextField" id="700877238"> <reference key="NSNextResponder" ref="855848511"/> <int key="NSvFlags">268</int> - <string key="NSFrame">{{14, 173}, {55, 19}}</string> + <string key="NSFrame">{{14, 85}, {55, 19}}</string> <reference key="NSSuperview" ref="855848511"/> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="120501725"> - <int key="NSCellFlags">-1804468671</int> + <int key="NSCellFlags">-1267597759</int> <int key="NSCellFlags2">272761856</int> <string key="NSContents"/> <reference key="NSSupport" ref="26"/> @@ -2348,8 +2346,140 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <reference key="NSTextColor" ref="876496808"/> </object> </object> + <object class="NSButton" id="68485429"> + <reference key="NSNextResponder" ref="855848511"/> + <int key="NSvFlags">268</int> + <string key="NSFrame">{{11, 152}, {179, 18}}</string> + <reference key="NSSuperview" ref="855848511"/> + <bool key="NSEnabled">YES</bool> + <object class="NSButtonCell" key="NSCell" id="628367768"> + <int key="NSCellFlags">-2080244224</int> + <int key="NSCellFlags2">131072</int> + <string key="NSContents">Structure</string> + <reference key="NSSupport" ref="26"/> + <reference key="NSControlView" ref="68485429"/> + <int key="NSButtonFlags">1211912703</int> + <int key="NSButtonFlags2">2</int> + <reference key="NSNormalImage" ref="191147027"/> + <reference key="NSAlternateImage" ref="506551266"/> + <string key="NSAlternateContents"/> + <string key="NSKeyEquivalent"/> + <int key="NSPeriodicDelay">200</int> + <int key="NSPeriodicInterval">25</int> + </object> + </object> + <object class="NSTextField" id="283307909"> + <reference key="NSNextResponder" ref="855848511"/> + <int key="NSvFlags">268</int> + <string key="NSFrame">{{12, 176}, {180, 14}}</string> + <reference key="NSSuperview" ref="855848511"/> + <bool key="NSEnabled">YES</bool> + <object class="NSTextFieldCell" key="NSCell" id="442957493"> + <int key="NSCellFlags">68288064</int> + <int key="NSCellFlags2">272761856</int> + <string key="NSContents">Include:</string> + <reference key="NSSupport" ref="26"/> + <reference key="NSControlView" ref="283307909"/> + <reference key="NSBackgroundColor" ref="683790803"/> + <reference key="NSTextColor" ref="804867667"/> + </object> + </object> + <object class="NSButton" id="542859898"> + <reference key="NSNextResponder" ref="855848511"/> + <int key="NSvFlags">268</int> + <string key="NSFrame">{{11, 132}, {179, 18}}</string> + <reference key="NSSuperview" ref="855848511"/> + <bool key="NSEnabled">YES</bool> + <object class="NSButtonCell" key="NSCell" id="588899969"> + <int key="NSCellFlags">-2080244224</int> + <int key="NSCellFlags2">131072</int> + <string key="NSContents">Content</string> + <reference key="NSSupport" ref="26"/> + <reference key="NSControlView" ref="542859898"/> + <int key="NSButtonFlags">1211912703</int> + <int key="NSButtonFlags2">2</int> + <reference key="NSNormalImage" ref="191147027"/> + <reference key="NSAlternateImage" ref="506551266"/> + <string key="NSAlternateContents"/> + <string key="NSKeyEquivalent"/> + <int key="NSPeriodicDelay">200</int> + <int key="NSPeriodicInterval">25</int> + </object> + </object> + <object class="NSPopUpButton" id="132499812"> + <reference key="NSNextResponder" ref="855848511"/> + <int key="NSvFlags">268</int> + <string key="NSFrame">{{59, 193}, {119, 22}}</string> + <reference key="NSSuperview" ref="855848511"/> + <bool key="NSEnabled">YES</bool> + <object class="NSPopUpButtonCell" key="NSCell" id="732046199"> + <int key="NSCellFlags">-2076049856</int> + <int key="NSCellFlags2">133120</int> + <reference key="NSSupport" ref="26"/> + <reference key="NSControlView" ref="132499812"/> + <int key="NSButtonFlags">109199615</int> + <int key="NSButtonFlags2">129</int> + <string key="NSAlternateContents"/> + <string key="NSKeyEquivalent"/> + <int key="NSPeriodicDelay">400</int> + <int key="NSPeriodicInterval">75</int> + <object class="NSMenuItem" key="NSMenuItem" id="135121460"> + <reference key="NSMenu" ref="294897844"/> + <string key="NSTitle">MySQL Schema</string> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <int key="NSState">1</int> + <reference key="NSOnImage" ref="626013002"/> + <reference key="NSMixedImage" ref="428837307"/> + <string key="NSAction">_popUpItemAction:</string> + <reference key="NSTarget" ref="732046199"/> + </object> + <bool key="NSMenuItemRespectAlignment">YES</bool> + <object class="NSMenu" key="NSMenu" id="294897844"> + <string key="NSTitle">OtherViews</string> + <object class="NSMutableArray" key="NSMenuItems"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="135121460"/> + <object class="NSMenuItem" id="208450572"> + <reference key="NSMenu" ref="294897844"/> + <string key="NSTitle">Plain Schema</string> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="626013002"/> + <reference key="NSMixedImage" ref="428837307"/> + <string key="NSAction">_popUpItemAction:</string> + <reference key="NSTarget" ref="732046199"/> + </object> + </object> + <reference key="NSMenuFont" ref="695505032"/> + </object> + <int key="NSPreferredEdge">1</int> + <bool key="NSUsesItemFromMenu">YES</bool> + <bool key="NSAltersState">YES</bool> + <int key="NSArrowPosition">2</int> + </object> + </object> + <object class="NSTextField" id="875960206"> + <reference key="NSNextResponder" ref="855848511"/> + <int key="NSvFlags">268</int> + <string key="NSFrame">{{11, 198}, {46, 14}}</string> + <reference key="NSSuperview" ref="855848511"/> + <bool key="NSEnabled">YES</bool> + <object class="NSTextFieldCell" key="NSCell" id="713176599"> + <int key="NSCellFlags">68288064</int> + <int key="NSCellFlags2">272761856</int> + <string key="NSContents">Format:</string> + <reference key="NSSupport" ref="26"/> + <reference key="NSControlView" ref="875960206"/> + <reference key="NSBackgroundColor" ref="683790803"/> + <reference key="NSTextColor" ref="804867667"/> + </object> + </object> </object> <string key="NSFrame">{{10, 7}, {189, 229}}</string> + <reference key="NSSuperview" ref="683006936"/> </object> <string key="NSLabel">XML</string> <reference key="NSColor" ref="683790803"/> @@ -2358,10 +2488,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <object class="NSTabViewItem" id="938710386"> <string key="NSIdentifier">pdf</string> <object class="NSView" key="NSView" id="1016607584"> - <reference key="NSNextResponder" ref="683006936"/> + <nil key="NSNextResponder"/> <int key="NSvFlags">256</int> <string key="NSFrame">{{10, 7}, {189, 229}}</string> - <reference key="NSSuperview" ref="683006936"/> </object> <string key="NSLabel">PDF</string> <reference key="NSColor" ref="683790803"/> @@ -2379,14 +2508,14 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <reference key="NSTabView" ref="683006936"/> </object> </object> - <reference key="NSSelectedTabViewItem" ref="938710386"/> + <reference key="NSSelectedTabViewItem" ref="317037302"/> <reference key="NSFont" ref="695505032"/> <int key="NSTvFlags">4</int> <bool key="NSAllowTruncatedLabels">YES</bool> <bool key="NSDrawsBackground">YES</bool> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="1016607584"/> + <reference ref="855848511"/> </object> </object> <object class="NSScrollView" id="505274803"> @@ -3215,6 +3344,38 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> </object> <int key="connectionID">1350</int> </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">exportXMLIncludeContent</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="542859898"/> + </object> + <int key="connectionID">1363</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">exportXMLIncludeStructure</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="68485429"/> + </object> + <int key="connectionID">1364</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">exportXMLFormatPopUpButton</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="132499812"/> + </object> + <int key="connectionID">1373</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">toggleXMLOutputFormat:</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="132499812"/> + </object> + <int key="connectionID">1374</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -4373,6 +4534,11 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <bool key="EncodedWithXMLCoder">YES</bool> <reference ref="700877238"/> <reference ref="65089502"/> + <reference ref="68485429"/> + <reference ref="283307909"/> + <reference ref="542859898"/> + <reference ref="875960206"/> + <reference ref="132499812"/> </object> <reference key="parent" ref="317037302"/> </object> @@ -4664,6 +4830,100 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <reference key="object" ref="846378668"/> <reference key="parent" ref="58358184"/> </object> + <object class="IBObjectRecord"> + <int key="objectID">1355</int> + <reference key="object" ref="68485429"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="628367768"/> + </object> + <reference key="parent" ref="855848511"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">1356</int> + <reference key="object" ref="283307909"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="442957493"/> + </object> + <reference key="parent" ref="855848511"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">1357</int> + <reference key="object" ref="542859898"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="588899969"/> + </object> + <reference key="parent" ref="855848511"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">1358</int> + <reference key="object" ref="588899969"/> + <reference key="parent" ref="542859898"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">1359</int> + <reference key="object" ref="442957493"/> + <reference key="parent" ref="283307909"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">1360</int> + <reference key="object" ref="628367768"/> + <reference key="parent" ref="68485429"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">1365</int> + <reference key="object" ref="132499812"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="732046199"/> + </object> + <reference key="parent" ref="855848511"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">1366</int> + <reference key="object" ref="732046199"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="294897844"/> + </object> + <reference key="parent" ref="132499812"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">1367</int> + <reference key="object" ref="294897844"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="135121460"/> + <reference ref="208450572"/> + </object> + <reference key="parent" ref="732046199"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">1368</int> + <reference key="object" ref="135121460"/> + <reference key="parent" ref="294897844"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">1369</int> + <reference key="object" ref="208450572"/> + <reference key="parent" ref="294897844"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">1371</int> + <reference key="object" ref="875960206"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="713176599"/> + </object> + <reference key="parent" ref="855848511"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">1372</int> + <reference key="object" ref="713176599"/> + <reference key="parent" ref="875960206"/> + </object> </object> </object> <object class="NSMutableDictionary" key="flattenedProperties"> @@ -4745,10 +5005,13 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <string>1150.IBPluginDependency</string> <string>1152.IBPluginDependency</string> <string>1153.IBPluginDependency</string> + <string>1153.IBViewBoundsToFrameTransform</string> <string>1154.IBPluginDependency</string> <string>1155.IBPluginDependency</string> <string>1156.IBPluginDependency</string> + <string>1156.IBViewBoundsToFrameTransform</string> <string>1157.IBPluginDependency</string> + <string>1157.IBViewBoundsToFrameTransform</string> <string>1158.IBPluginDependency</string> <string>1159.IBPluginDependency</string> <string>1160.IBPluginDependency</string> @@ -4863,6 +5126,25 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <string>1341.IBPluginDependency</string> <string>1342.IBPluginDependency</string> <string>1343.IBPluginDependency</string> + <string>1355.IBPluginDependency</string> + <string>1355.IBViewBoundsToFrameTransform</string> + <string>1356.IBPluginDependency</string> + <string>1356.IBViewBoundsToFrameTransform</string> + <string>1357.IBPluginDependency</string> + <string>1357.IBViewBoundsToFrameTransform</string> + <string>1358.IBPluginDependency</string> + <string>1359.IBPluginDependency</string> + <string>1360.IBPluginDependency</string> + <string>1365.IBPluginDependency</string> + <string>1365.IBViewBoundsToFrameTransform</string> + <string>1366.IBPluginDependency</string> + <string>1367.IBEditorWindowLastContentRect</string> + <string>1367.IBPluginDependency</string> + <string>1368.IBPluginDependency</string> + <string>1369.IBPluginDependency</string> + <string>1371.IBPluginDependency</string> + <string>1371.IBViewBoundsToFrameTransform</string> + <string>1372.IBPluginDependency</string> <string>2.IBPluginDependency</string> <string>2.IBUserGuides</string> <string>294.IBEditorWindowLastContentRect</string> @@ -4936,7 +5218,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <boolean value="NO"/> <boolean value="YES"/> <string>{449, 480}</string> - <string>{{226, 235}, {450, 359}}</string> + <string>{{463, 507}, {450, 359}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <object class="NSMutableDictionary"> @@ -5052,10 +5334,19 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <object class="NSAffineTransform"> + <bytes key="NSTransformStruct">P4AAAL+AAABBQAAAwywAAA</bytes> + </object> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <object class="NSAffineTransform"> + <bytes key="NSTransformStruct">P4AAAL+AAABBQAAAw1QAAA</bytes> + </object> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <object class="NSAffineTransform"> + <bytes key="NSTransformStruct">P4AAAL+AAABBMAAAw0AAAA</bytes> + </object> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -5219,6 +5510,35 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <object class="NSAffineTransform"> + <bytes key="NSTransformStruct">P4AAAL+AAADCeAAAwvQAAA</bytes> + </object> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <object class="NSAffineTransform"> + <bytes key="NSTransformStruct">P4AAAL+AAADCdAAAww4AAA</bytes> + </object> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <object class="NSAffineTransform"> + <bytes key="NSTransformStruct">P4AAAL+AAADCdAAAwswAAA</bytes> + </object> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <object class="NSAffineTransform"> + <bytes key="NSTransformStruct">P4AAAL+AAABCnAAAwxYAAA</bytes> + </object> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>{{746, 640}, {140, 37}}</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <object class="NSAffineTransform"> + <bytes key="NSTransformStruct">P4AAAL+AAABBMAAAwxIAAA</bytes> + </object> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <object class="NSMutableArray"> <bool key="EncodedWithXMLCoder">YES</bool> </object> @@ -5306,7 +5626,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> </object> </object> <nil key="sourceID"/> - <int key="maxID">1354</int> + <int key="maxID">1374</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -5415,6 +5735,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <string>doSelectionUpperCase:</string> <string>doTranspose:</string> <string>insertNULLvalue:</string> + <string>moveSelectionLineDown:</string> + <string>moveSelectionLineUp:</string> <string>selectCurrentLine:</string> <string>selectCurrentWord:</string> <string>selectEnclosingBrackets:</string> @@ -5434,6 +5756,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <string>id</string> <string>id</string> <string>id</string> + <string>id</string> + <string>id</string> </object> </object> <object class="NSMutableDictionary" key="actionInfosByName"> @@ -5450,6 +5774,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <string>doSelectionUpperCase:</string> <string>doTranspose:</string> <string>insertNULLvalue:</string> + <string>moveSelectionLineDown:</string> + <string>moveSelectionLineUp:</string> <string>selectCurrentLine:</string> <string>selectCurrentWord:</string> <string>selectEnclosingBrackets:</string> @@ -5497,6 +5823,14 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <string key="candidateClassName">id</string> </object> <object class="IBActionInfo"> + <string key="name">moveSelectionLineDown:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">moveSelectionLineUp:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> <string key="name">selectCurrentLine:</string> <string key="candidateClassName">id</string> </object> @@ -5557,6 +5891,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <string>toggleSQLIncludeContent:</string> <string>toggleSQLIncludeDropSyntax:</string> <string>toggleSQLIncludeStructure:</string> + <string>toggleXMLOutputFormat:</string> </object> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -5574,6 +5909,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <string>id</string> <string>id</string> <string>id</string> + <string>id</string> </object> </object> <object class="NSMutableDictionary" key="actionInfosByName"> @@ -5594,6 +5930,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <string>toggleSQLIncludeContent:</string> <string>toggleSQLIncludeDropSyntax:</string> <string>toggleSQLIncludeStructure:</string> + <string>toggleXMLOutputFormat:</string> </object> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -5653,6 +5990,10 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <string key="name">toggleSQLIncludeStructure:</string> <string key="candidateClassName">id</string> </object> + <object class="IBActionInfo"> + <string key="name">toggleXMLOutputFormat:</string> + <string key="candidateClassName">id</string> + </object> </object> </object> <object class="NSMutableDictionary" key="outlets"> @@ -5704,6 +6045,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <string>exportTablelistScrollView</string> <string>exportTypeTabBar</string> <string>exportUseUTF8BOMButton</string> + <string>exportXMLFormatPopUpButton</string> + <string>exportXMLIncludeContent</string> + <string>exportXMLIncludeStructure</string> <string>exportXMLNULLValuesAsTextField</string> <string>exporterView</string> <string>tableContentInstance</string> @@ -5758,6 +6102,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <string>NSScrollView</string> <string>NSTabView</string> <string>NSButton</string> + <string>NSPopUpButton</string> + <string>NSButton</string> + <string>NSButton</string> <string>NSTextField</string> <string>NSView</string> <string>id</string> @@ -5815,6 +6162,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <string>exportTablelistScrollView</string> <string>exportTypeTabBar</string> <string>exportUseUTF8BOMButton</string> + <string>exportXMLFormatPopUpButton</string> + <string>exportXMLIncludeContent</string> + <string>exportXMLIncludeStructure</string> <string>exportXMLNULLValuesAsTextField</string> <string>exporterView</string> <string>tableContentInstance</string> @@ -6005,6 +6355,18 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes> <string key="candidateClassName">NSButton</string> </object> <object class="IBToOneOutletInfo"> + <string key="name">exportXMLFormatPopUpButton</string> + <string key="candidateClassName">NSPopUpButton</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">exportXMLIncludeContent</string> + <string key="candidateClassName">NSButton</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">exportXMLIncludeStructure</string> + <string key="candidateClassName">NSButton</string> + </object> + <object class="IBToOneOutletInfo"> <string key="name">exportXMLNULLValuesAsTextField</string> <string key="candidateClassName">NSTextField</string> </object> diff --git a/Source/SPConstants.h b/Source/SPConstants.h index a3665661..29207b89 100644 --- a/Source/SPConstants.h +++ b/Source/SPConstants.h @@ -83,6 +83,13 @@ enum { }; typedef NSUInteger SPSQLExportInsertDivider; +// XML export formats +enum { + SPXMLExportMySQLFormat = 0, + SPXMLExportPlainFormat = 1 +}; +typedef NSUInteger SPXMLExportFormat; + // Table row count query usage levels typedef enum { SPRowCountFetchNever = 0, diff --git a/Source/SPExportController.h b/Source/SPExportController.h index 32cf189a..24c30b39 100644 --- a/Source/SPExportController.h +++ b/Source/SPExportController.h @@ -104,6 +104,9 @@ IBOutlet NSTextField *exportCSVNULLValuesAsTextField; // XML + IBOutlet NSPopUpButton *exportXMLFormatPopUpButton; + IBOutlet NSButton *exportXMLIncludeStructure; + IBOutlet NSButton *exportXMLIncludeContent; IBOutlet NSTextField *exportXMLNULLValuesAsTextField; /** @@ -239,6 +242,7 @@ - (IBAction)toggleAdvancedExportOptionsView:(id)sender; - (IBAction)exportCustomQueryResultAsFormat:(id)sender; +- (IBAction)toggleXMLOutputFormat:(id)sender; - (IBAction)toggleSQLIncludeStructure:(id)sender; - (IBAction)toggleSQLIncludeContent:(id)sender; - (IBAction)toggleSQLIncludeDropSyntax:(id)sender; diff --git a/Source/SPExportController.m b/Source/SPExportController.m index 3ca2c996..755a4f74 100644 --- a/Source/SPExportController.m +++ b/Source/SPExportController.m @@ -493,6 +493,23 @@ static const NSString *SPTableViewDropColumnID = @"drop"; } /** + * Toggles the options available depending on the selected XML output format. + */ +- (IBAction)toggleXMLOutputFormat:(id)sender +{ + if ([sender indexOfSelectedItem] == SPXMLExportMySQLFormat) { + [exportXMLIncludeStructure setEnabled:YES]; + [exportXMLIncludeContent setEnabled:YES]; + [exportXMLNULLValuesAsTextField setEnabled:NO]; + } + else if ([sender indexOfSelectedItem] == SPXMLExportPlainFormat) { + [exportXMLIncludeStructure setEnabled:NO]; + [exportXMLIncludeContent setEnabled:NO]; + [exportXMLNULLValuesAsTextField setEnabled:YES]; + } +} + +/** * Toggles the display of the advanced options box. */ - (IBAction)toggleAdvancedExportOptionsView:(id)sender diff --git a/Source/SPExportFileUtilities.m b/Source/SPExportFileUtilities.m index fd4be8b0..86631495 100644 --- a/Source/SPExportFileUtilities.m +++ b/Source/SPExportFileUtilities.m @@ -86,13 +86,16 @@ [header appendFormat:@"- %@: %@\n", NSLocalizedString(@"Database", @"export header database label"), [tableDocumentInstance database]]; [header appendFormat:@"- %@ Time: %@\n", NSLocalizedString(@"Generation Time", @"export header generation time label"), [NSDate date]]; [header appendString:@"-\n-->\n\n"]; - [header appendFormat:@"<%@ xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n", (exportSource == SPTableExport) ? @"mysqldump" : @"resultset"]; - if (exportSource == SPTableExport) { - [header appendFormat:@"<database name=\"%@\">\n\n", [tableDocumentInstance database]]; + if ([exportXMLFormatPopUpButton indexOfSelectedItem] == SPXMLExportMySQLFormat) { + [header appendFormat:@"<%@ xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n", (exportSource == SPTableExport) ? @"mysqldump" : @"resultset"]; + + if (exportSource == SPTableExport) { + [header appendFormat:@"<database name=\"%@\">\n\n", [tableDocumentInstance database]]; + } } else { - [header appendString:@"\n"]; + [header appendFormat:@"<%@>\n\n", [[tableDocumentInstance database] HTMLEscapeString]]; } [file writeData:[header dataUsingEncoding:NSUTF8StringEncoding]]; diff --git a/Source/SPExportInitializer.m b/Source/SPExportInitializer.m index 7b1b9451..9544bf4b 100644 --- a/Source/SPExportInitializer.m +++ b/Source/SPExportInitializer.m @@ -503,7 +503,10 @@ // Regardless of the export source, set exporter's table name as it's used in the output // of table and table content exports. [xmlExporter setXmlTableName:table]; - + + [xmlExporter setXmlFormat:[exportXMLFormatPopUpButton indexOfSelectedItem]]; + [xmlExporter setXmlOutputIncludeStructure:[exportXMLIncludeStructure state]]; + [xmlExporter setXmlOutputIncludeContent:[exportXMLIncludeContent state]]; [xmlExporter setXmlNULLString:[exportXMLNULLValuesAsTextField stringValue]]; // If required create separate files diff --git a/Source/SPXMLExporter.h b/Source/SPXMLExporter.h index 8d7a740c..f7b94f86 100644 --- a/Source/SPXMLExporter.h +++ b/Source/SPXMLExporter.h @@ -41,27 +41,47 @@ NSString *xmlTableName; NSString *xmlNULLString; + + BOOL xmlOutputIncludeStructure; + BOOL xmlOutputIncludeContent; + + SPXMLExportFormat xmlFormat; } /** * @property delegate Exporter delegate */ -@property(readwrite, assign) NSObject <SPXMLExporterProtocol> *delegate; +@property (readwrite, assign) NSObject <SPXMLExporterProtocol> *delegate; /** * @property xmlDataArray Data array */ -@property(readwrite, retain) NSArray *xmlDataArray; +@property (readwrite, retain) NSArray *xmlDataArray; /** * @property xmlTableName Table name */ -@property(readwrite, retain) NSString *xmlTableName; +@property (readwrite, retain) NSString *xmlTableName; /** * @property xmlNULLString XML NULL string */ -@property(readwrite, retain) NSString *xmlNULLString; +@property (readwrite, retain) NSString *xmlNULLString; + +/** + * @property xmlOutputIncludeStructure Include table structure + */ +@property (readwrite, assign) BOOL xmlOutputIncludeStructure; + +/** + * @property xmlOutputIncludeContent Include table content + */ +@property (readwrite, assign) BOOL xmlOutputIncludeContent; + +/** + * @property xmlFormat + */ +@property (readwrite, assign) SPXMLExportFormat xmlFormat; - (id)initWithDelegate:(NSObject *)exportDelegate; diff --git a/Source/SPXMLExporter.m b/Source/SPXMLExporter.m index 1ff32018..962d5a53 100644 --- a/Source/SPXMLExporter.m +++ b/Source/SPXMLExporter.m @@ -35,6 +35,9 @@ @synthesize xmlDataArray; @synthesize xmlTableName; @synthesize xmlNULLString; +@synthesize xmlOutputIncludeStructure; +@synthesize xmlOutputIncludeContent; +@synthesize xmlFormat; /** * Initialise an instance of SPXMLExporter using the supplied delegate. @@ -62,13 +65,20 @@ { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + BOOL isTableExport = NO; + NSArray *xmlRow = nil; NSArray *fieldNames = nil; NSString *dataConversionString = nil; + + // Result sets + MCPResult *statusResult = nil; + MCPResult *structureResult = nil; MCPStreamingResult *streamingResult = nil; + NSMutableArray *xmlTags = [NSMutableArray array]; NSMutableString *xmlString = [NSMutableString string]; - NSMutableString *xmlItem = [NSMutableString string]; + NSMutableString *xmlItem = [NSMutableString string]; NSUInteger xmlRowCount = 0; NSUInteger i, totalRows, currentRowIndex, lastProgressValue, currentPoolDataLength; @@ -76,7 +86,8 @@ // Check to see if we have at least a table name or data array if ((![self xmlTableName]) && (![self xmlDataArray]) || ([[self xmlTableName] length] == 0) && ([[self xmlDataArray] count] == 0) || - (![self xmlNULLString])) + (([self xmlFormat] == SPXMLExportMySQLFormat) && ((![self xmlOutputIncludeStructure]) && (![self xmlOutputIncludeContent]))) || + (([self xmlFormat] == SPXMLExportPlainFormat) && (![self xmlNULLString]))) { [pool release]; return; @@ -92,67 +103,105 @@ // Make a streaming request for the data if the data array isn't set if ((![self xmlDataArray]) && [self xmlTableName]) { - totalRows = [[[[connection queryString:[NSString stringWithFormat:@"SELECT COUNT(1) FROM %@", [[self xmlTableName] backtickQuotedString]]] fetchRowAsArray] objectAtIndex:0] integerValue]; + + isTableExport = YES; + + totalRows = [[[[connection queryString:[NSString stringWithFormat:@"SELECT COUNT(1) FROM %@", [[self xmlTableName] backtickQuotedString]]] fetchRowAsArray] objectAtIndex:0] integerValue]; streamingResult = [connection streamingQueryString:[NSString stringWithFormat:@"SELECT * FROM %@", [[self xmlTableName] backtickQuotedString]] useLowMemoryBlockingStreaming:[self exportUsingLowMemoryBlockingStreaming]]; - [xmlString appendFormat:@"\t<table_data name=\"%@\">\n\n", [self xmlTableName]]; + // Only include the structure if necessary + if (([self xmlFormat] == SPXMLExportMySQLFormat) && [self xmlOutputIncludeStructure]) { + + structureResult = [connection queryString:[NSString stringWithFormat:@"SHOW COLUMNS FROM %@", [[self xmlTableName] backtickQuotedString]]]; + statusResult = [connection queryString:[NSString stringWithFormat:@"SHOW TABLE STATUS LIKE %@", [[self xmlTableName] tickQuotedString]]]; + + if ([structureResult numOfRows] && [statusResult numOfRows]) { + + [statusResult dataSeek:0]; + [structureResult dataSeek:0]; + + [xmlString appendFormat:@"\t<table_structure name=\"%@\">\n", [self xmlTableName]]; + + for (i = 0; i < [structureResult numOfRows]; i++) + { + NSDictionary *row = [structureResult fetchRowAsDictionary]; + + [xmlString appendFormat:@"\t\t<field field=\"%@\" type=\"%@\" null=\"%@\" key=\"%@\" default=\"%@\" extra=\"%@\" />\n", + [row objectForKey:@"Field"], + [row objectForKey:@"Type"], + [row objectForKey:@"Null"], + [row objectForKey:@"Key"], + [row objectForKey:@"Default"], + [row objectForKey:@"Extra"]]; + } + + NSDictionary *row = [statusResult fetchRowAsDictionary]; + + [xmlString appendFormat:@"\n\t\t<options name=\"%@\" engine=\"%@\" version=\"%@\" row_format=\"%@\" rows=\"%@\" avg_row_length=\"%@\" data_length=\"%@\" max_data_length=\"%@\" index_length=\"%@\" data_free=\"%@\" create_time=\"%@\" update_time=\"%@\" collation=\"%@\" create_options=\"%@\" comment=\"%@\" />\n", + [row objectForKey:@"Name"], + [row objectForKey:@"Engine"], + [row objectForKey:@"Version"], + [row objectForKey:@"Row_format"], + [row objectForKey:@"Rows"], + [row objectForKey:@"Avg_row_length"], + [row objectForKey:@"Data_length"], + [row objectForKey:@"Max_data_length"], + [row objectForKey:@"Index_length"], + [row objectForKey:@"Data_free"], + [row objectForKey:@"Create_time"], + [row objectForKey:@"Update_time"], + [row objectForKey:@"Collation"], + [row objectForKey:@"Create_options"], + [row objectForKey:@"Comment"]]; + + [xmlString appendFormat:@"\t</table_structure>\n\n"]; + } + } + + if (([self xmlFormat] == SPXMLExportMySQLFormat) && [self xmlOutputIncludeContent]) { + [xmlString appendFormat:@"\t<table_data name=\"%@\">\n\n", [self xmlTableName]]; + } + + [[self exportOutputFile] writeData:[xmlString dataUsingEncoding:[self exportOutputEncoding]]]; } else { totalRows = [[self xmlDataArray] count]; } - // Set up an array of encoded field names as opening and closing tags - fieldNames = ([self xmlDataArray]) ? [[self xmlDataArray] objectAtIndex:0] : [streamingResult fetchFieldNames]; + // Only proceed to export the content if this is not a table export or it is and include content is selected + if ((!isTableExport) || (isTableExport && [self xmlOutputIncludeContent])) { - [[self exportOutputFile] writeData:[xmlString dataUsingEncoding:[self exportOutputEncoding]]]; - - // Set up the starting row, which is 0 for streaming result sets and - // 1 for supplied arrays which include the column headers as the first row. - currentRowIndex = 0; - - if ([self xmlDataArray]) currentRowIndex++; - - // Drop into the processing loop - NSAutoreleasePool *xmlExportPool = [[NSAutoreleasePool alloc] init]; - - currentPoolDataLength = 0; - - // Inform the delegate that we are about to start writing the data to disk - [delegate performSelectorOnMainThread:@selector(xmlExportProcessWillBeginWritingData:) withObject:self waitUntilDone:NO]; - - while (1) - { - // Check for cancellation flag - if ([self isCancelled]) { - if (streamingResult) { - [connection cancelCurrentQuery]; - [streamingResult cancelResultLoad]; - } - - [xmlExportPool release]; - [pool release]; + // Set up an array of encoded field names as opening and closing tags + fieldNames = ([self xmlDataArray]) ? NSArrayObjectAtIndex([self xmlDataArray], 0) : [streamingResult fetchFieldNames]; + + for (i = 0; i < [fieldNames count]; i++) + { + [xmlTags addObject:[NSMutableArray array]]; - return; + [NSArrayObjectAtIndex(xmlTags, i) addObject:[NSString stringWithFormat:@"\t\t<%@>", [[NSArrayObjectAtIndex(fieldNames, i) description] HTMLEscapeString]]]; + [NSArrayObjectAtIndex(xmlTags, i) addObject:[NSString stringWithFormat:@"</%@>\n", [[NSArrayObjectAtIndex(fieldNames, i) description] HTMLEscapeString]]]; } - // Retrieve the next row from the supplied data, either directly from the array... - if ([self xmlDataArray]) { - xmlRow = NSArrayObjectAtIndex([self xmlDataArray], currentRowIndex); - } - // Or by reading an appropriate row from the streaming result - else { - xmlRow = [streamingResult fetchNextRowAsArray]; - - if (!xmlRow) break; + // If required, write an opening tag in the form of the table name + if ([self xmlFormat] == SPXMLExportPlainFormat) { + [[self exportOutputFile] writeData:[[NSString stringWithFormat:@"\t<%@>\n", ([self xmlTableName]) ? [[self xmlTableName] HTMLEscapeString] : @"custom"] dataUsingEncoding:[self exportOutputEncoding]]]; } - // Get the cell count if we don't already have it stored - if (!xmlRowCount) xmlRowCount = [xmlRow count]; + // Set up the starting row, which is 0 for streaming result sets and + // 1 for supplied arrays which include the column headers as the first row. + currentRowIndex = 0; + + if ([self xmlDataArray]) currentRowIndex++; + + // Drop into the processing loop + NSAutoreleasePool *xmlExportPool = [[NSAutoreleasePool alloc] init]; + + currentPoolDataLength = 0; - // Construct the row - [xmlString setString:@"\t<row>\n"]; + // Inform the delegate that we are about to start writing the data to disk + [delegate performSelectorOnMainThread:@selector(xmlExportProcessWillBeginWritingData:) withObject:self waitUntilDone:NO]; - for (i = 0; i < xmlRowCount; i++) + while (1) { // Check for cancellation flag if ([self isCancelled]) { @@ -167,76 +216,126 @@ return; } - BOOL dataIsNULL = NO; - id data = NSArrayObjectAtIndex(xmlRow, i); + // Retrieve the next row from the supplied data, either directly from the array... + if ([self xmlDataArray]) { + xmlRow = NSArrayObjectAtIndex([self xmlDataArray], currentRowIndex); + } + // Or by reading an appropriate row from the streaming result + else { + xmlRow = [streamingResult fetchNextRowAsArray]; + + if (!xmlRow) break; + } - // Retrieve the contents of this tag - if ([data isKindOfClass:[NSData class]]) { - dataConversionString = [[NSString alloc] initWithData:data encoding:[self exportOutputEncoding]]; + // Get the cell count if we don't already have it stored + if (!xmlRowCount) xmlRowCount = [xmlRow count]; + + // Construct the row + [xmlString setString:@"\t<row>\n"]; + + for (i = 0; i < xmlRowCount; i++) + { + // Check for cancellation flag + if ([self isCancelled]) { + if (streamingResult) { + [connection cancelCurrentQuery]; + [streamingResult cancelResultLoad]; + } + + [xmlExportPool release]; + [pool release]; + + return; + } - if (dataConversionString == nil) { - dataConversionString = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; + BOOL dataIsNULL = NO; + id data = NSArrayObjectAtIndex(xmlRow, i); + + // Retrieve the contents of this tag + if ([data isKindOfClass:[NSData class]]) { + dataConversionString = [[NSString alloc] initWithData:data encoding:[self exportOutputEncoding]]; + + if (dataConversionString == nil) { + dataConversionString = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; + } + + [xmlItem setString:[NSString stringWithString:dataConversionString]]; + [dataConversionString release]; + } + else if ([data isKindOfClass:[NSNull class]]) { + dataIsNULL = YES; + + if ([self xmlFormat] == SPXMLExportPlainFormat) { + [xmlItem setString:[self xmlNULLString]]; + } + } + else if ([data isKindOfClass:[MCPGeometryData class]]) { + [xmlItem setString:[data wktString]]; + } + else { + [xmlItem setString:[data description]]; } - [xmlItem setString:[NSString stringWithString:dataConversionString]]; - [dataConversionString release]; - } - else if ([data isKindOfClass:[NSNull class]]) { - dataIsNULL = YES; - } - else if ([data isKindOfClass:[MCPGeometryData class]]) { - [xmlItem setString:[data wktString]]; - } - else { - [xmlItem setString:[data description]]; + if ([self xmlFormat] == SPXMLExportMySQLFormat) { + [xmlString appendFormat:@"\t\t<field name=\"%@\"", [[NSArrayObjectAtIndex(fieldNames, i) description] HTMLEscapeString]]; + + if (dataIsNULL) { + [xmlString appendString:@" xsi:nil=\"true\" \\>\n"]; + } + else { + [xmlString appendFormat:@">%@</field>\n", [xmlItem HTMLEscapeString]]; + } + } + else if ([self xmlFormat] == SPXMLExportPlainFormat) { + // Add the opening and closing tag and the contents to the XML string + [xmlString appendString:NSArrayObjectAtIndex(NSArrayObjectAtIndex(xmlTags, i), 0)]; + [xmlString appendString:[xmlItem HTMLEscapeString]]; + [xmlString appendString:NSArrayObjectAtIndex(NSArrayObjectAtIndex(xmlTags, i), 1)]; + } } - - [xmlString appendFormat:@"\t\t<field name=\"%@\"", [[NSArrayObjectAtIndex(fieldNames, i) description] HTMLEscapeString]]; - if (dataIsNULL) { - [xmlString appendString:@" xsi:nil=\"true\" \\>\n"]; - } - else { - [xmlString appendFormat:@">%@</field>\n", [xmlItem HTMLEscapeString]]; - } - } - - [xmlString appendString:@"\t</row>\n\n"]; + [xmlString appendString:@"\t</row>\n\n"]; + + // Record the total length for use with pool flushing + currentPoolDataLength += [xmlString length]; + + // Write the row to the filehandle + [[self exportOutputFile] writeData:[xmlString dataUsingEncoding:[self exportOutputEncoding]]]; + + // Update the progress counter and progress bar + currentRowIndex++; + + // Update the progress + if (totalRows && (currentRowIndex * ([self exportMaxProgress] / totalRows)) > lastProgressValue) { - // Record the total length for use with pool flushing - currentPoolDataLength += [xmlString length]; - - // Write the row to the filehandle - [[self exportOutputFile] writeData:[xmlString dataUsingEncoding:[self exportOutputEncoding]]]; - - // Update the progress counter and progress bar - currentRowIndex++; - - // Update the progress - if (totalRows && (currentRowIndex * ([self exportMaxProgress] / totalRows)) > lastProgressValue) { + NSInteger progress = (currentRowIndex * ([self exportMaxProgress] / totalRows)); + + [self setExportProgressValue:progress]; + + lastProgressValue = progress; + } - NSInteger progress = (currentRowIndex * ([self exportMaxProgress] / totalRows)); + // Inform the delegate that the export's progress has been updated + [delegate performSelectorOnMainThread:@selector(xmlExportProcessProgressUpdated:) withObject:self waitUntilDone:NO]; - [self setExportProgressValue:progress]; - - lastProgressValue = progress; + // Drain the autorelease pool as required to keep memory usage low + if (currentPoolDataLength > 250000) { + [xmlExportPool release]; + xmlExportPool = [[NSAutoreleasePool alloc] init]; + } + + // If an array was supplied and we've processed all rows, break + if ([self xmlDataArray] && totalRows == currentRowIndex) break; } - // Inform the delegate that the export's progress has been updated - [delegate performSelectorOnMainThread:@selector(xmlExportProcessProgressUpdated:) withObject:self waitUntilDone:NO]; - - // Drain the autorelease pool as required to keep memory usage low - if (currentPoolDataLength > 250000) { - [xmlExportPool release]; - xmlExportPool = [[NSAutoreleasePool alloc] init]; + if (([self xmlFormat] == SPXMLExportMySQLFormat) && isTableExport) { + [[self exportOutputFile] writeData:[@"\t</table_data>\n\n" dataUsingEncoding:[self exportOutputEncoding]]]; + } + else if ([self xmlFormat] == SPXMLExportPlainFormat) { + [[self exportOutputFile] writeData:[[NSString stringWithFormat:@"\t</%@>\n\n", ([self xmlTableName]) ? [[self xmlTableName] HTMLEscapeString] : @"custom"] dataUsingEncoding:[self exportOutputEncoding]]]; } - // If an array was supplied and we've processed all rows, break - if ([self xmlDataArray] && totalRows == currentRowIndex) break; - } - - if ((![self xmlDataArray]) && [self xmlTableName]) { - [[self exportOutputFile] writeData:[@"\t</table_data>\n\n" dataUsingEncoding:[self exportOutputEncoding]]]; + [xmlExportPool release]; } // Write data to disk @@ -248,7 +347,6 @@ // Inform the delegate that the export process is complete [delegate performSelectorOnMainThread:@selector(xmlExportProcessComplete:) withObject:self waitUntilDone:NO]; - [xmlExportPool release]; [pool release]; } @@ -259,8 +357,7 @@ { if (xmlDataArray) [xmlDataArray release], xmlDataArray = nil; if (xmlTableName) [xmlTableName release], xmlTableName = nil; - - [xmlNULLString release], xmlNULLString = nil; + if (xmlNULLString) [xmlNULLString release], xmlNULLString = nil; [super dealloc]; } diff --git a/Source/SPXMLExporterDelegate.m b/Source/SPXMLExporterDelegate.m index cae852ac..9d8b97cf 100644 --- a/Source/SPXMLExporterDelegate.m +++ b/Source/SPXMLExporterDelegate.m @@ -69,8 +69,16 @@ // If we're exporting to multiple files then close the file handle of the exporter // that just finished, ensuring its data is written to disk. if (exportToMultipleFiles) { - [[exporter exportOutputFile] writeData:[(exportSource == SPTableExport) ? @"</database>\n</mysqldump>\n" : @"</resultset>\n" dataUsingEncoding:[connection stringEncoding]]]; + NSString *string = @""; + if ([exporter xmlFormat] == SPXMLExportMySQLFormat) { + string = (exportSource == SPTableExport) ? @"</database>\n</mysqldump>\n" : @"</resultset>\n";; + } + else if ([exporter xmlFormat] == SPXMLExportPlainFormat) { + string = [NSString stringWithFormat:@"</%@>\n", [[tableDocumentInstance database] HTMLEscapeString]]; + } + + [[exporter exportOutputFile] writeData:[string dataUsingEncoding:[connection stringEncoding]]]; [[exporter exportOutputFile] close]; } @@ -82,9 +90,16 @@ } // Otherwise if the exporter list is empty, close the progress sheet else { - [[exporter exportOutputFile] writeData:[(exportSource == SPTableExport) ? @"</database>\n</mysqldump>\n" : @"</resultset>\n" dataUsingEncoding:[connection stringEncoding]]]; + NSString *string = @""; + + if ([exporter xmlFormat] == SPXMLExportMySQLFormat) { + string = (exportSource == SPTableExport) ? @"</database>\n</mysqldump>\n" : @"</resultset>\n";; + } + else if ([exporter xmlFormat] == SPXMLExportPlainFormat) { + string = [NSString stringWithFormat:@"</%@>\n", [[tableDocumentInstance database] HTMLEscapeString]]; + } - // Close the last exporter's file handle + [[exporter exportOutputFile] writeData:[string dataUsingEncoding:[connection stringEncoding]]]; [[exporter exportOutputFile] close]; [NSApp endSheet:exportProgressWindow returnCode:0]; |