Import from MacDive

Help
terry
2012-04-23
2012-12-06
  • terry

    terry - 2012-04-23

    Trying to import MacDive 2.1.4 xml exportred file but am getting the following error.  Any help would be appreciated.

    Apr 22, 2012 6:22:48 PM net.sf.jdivelog.model.macdivelog.MacDiveLogFileLoader Load
    SEVERE: Error importing MacDiveLog
    java.lang.Exception: Wrong file format
    at net.sf.jdivelog.model.macdivelog.MacDiveLogFileLoader.Load(Unknown Source)
    at net.sf.jdivelog.gui.MainWindow.importMacDiveLog(Unknown Source)
    at net.sf.jdivelog.gui.MainWindow.actionPerformed(Unknown Source)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2012)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2335)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:404)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.AbstractButton.doClick(AbstractButton.java:374)
    at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:829)
    at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:873)
    at java.awt.Component.processMouseEvent(Component.java:6268)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
    at java.awt.Component.processEvent(Component.java:6033)
    at java.awt.Container.processEvent(Container.java:2045)
    at java.awt.Component.dispatchEventImpl(Component.java:4629)
    at java.awt.Container.dispatchEventImpl(Container.java:2103)
    at java.awt.Component.dispatchEvent(Component.java:4455)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4633)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4297)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4227)
    at java.awt.Container.dispatchEventImpl(Container.java:2089)
    at java.awt.Component.dispatchEvent(Component.java:4455)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:649)
    at java.awt.EventQueue.access$000(EventQueue.java:96)
    at java.awt.EventQueue$1.run(EventQueue.java:608)
    at java.awt.EventQueue$1.run(EventQueue.java:606)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:116)
    at java.awt.EventQueue$2.run(EventQueue.java:622)
    at java.awt.EventQueue$2.run(EventQueue.java:620)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:619)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)

     
  • André Schenk

    André Schenk - 2012-04-24

    The exception "Wrong file format" is thrown, if the XML root element is not "logbook".

    Could you please send me this file?

    Best regards,

    André

     
  • terry

    terry - 2012-04-24

    Thanks for replying.  I would be happy to send the file to you, but can't find your email address..perhaps I'm not looking in the right place.  Can you please let me know where to send it?

    Thank you.
    Terry

     
  • André Schenk

    André Schenk - 2012-04-24

    andre_schenk@users.sourceforge.net

     
  • terry

    terry - 2012-04-24

    Sent

     
  • terry

    terry - 2012-04-25

    So I took a took a piece of the xml code from MacDive and have changed the root element to "logbook"  but not sure if I've done that correctly as I still get an error.  Here is the code

    <?xml version="1.0" encoding="UTF-8"?>
    <logbook>
        <units>Imperial</units>
        <schema>2.0.0</schema>
        <dive>
            <date>2011-12-04 10:30:00</date>
            <divenumber>1</divenumber>
            <country>warm country</country>
            <location>PV</location>
            <site>site</site>
            <repetitive></repetitive>
            <sitelat>20.69446</sitelat>
            <sitelon>-105.58273</sitelon>
            <sitezoom>10</sitezoom>
            <diver> my name</diver>
            <computer>No Computer</computer>
            <serial></serial>
            <maxdepth>60.00</maxdepth>
            <avgdepth>40.00</avgdepth>
            <gasmodel></gasmodel>
            <duration>2700</duration>
            <visibility>30</visibility>
            <surfaceint></surfaceint>
            <airstart>3000.00</airstart>
            <airend>600.00</airend>
            <sampleInterval>0</sampleInterval>
            <o2percent>21</o2percent>
            <tempair>78</tempair>
            <temphigh>72</temphigh>
            <templow>68</templow>
            <weather>sunny</weather>
            <weight>25</weight>
            <notes><![CDATA]></notes>
            <tags></tags>
            <buddies>
                <buddy>my bud</buddy>
            </buddies>
            <gear>
                <item>
                    <type>Tank</type>
                    <manufacturer>Rental</manufacturer>
                    <name>AL80</name>
                    <tanksize>80</tanksize>
                    <workingpressure>3000</workingpressure>
                </item>
            </gear>
            <samples></samples>
        </dive>
    </logbook>

    The following is the error:
    Apr 24, 2012 9:40:47 PM net.sf.jdivelog.model.macdivelog.MacDiveLogFileLoader LoadDives
    SEVERE: Error importing MacDiveLog - LoadDives
    java.lang.NumberFormatException: empty String
    at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1012)
    at java.lang.Double.parseDouble(Double.java:527)
    at net.sf.jdivelog.model.macdivelog.MacDiveLogFileLoader.LoadDives(Unknown Source)
    at net.sf.jdivelog.model.macdivelog.MacDiveLogFileLoader.Load(Unknown Source)
    at net.sf.jdivelog.gui.MainWindow.importMacDiveLog(Unknown Source)
    at net.sf.jdivelog.gui.MainWindow.actionPerformed(Unknown Source)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2012)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2335)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:404)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.AbstractButton.doClick(AbstractButton.java:374)
    at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:829)
    at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:873)
    at java.awt.Component.processMouseEvent(Component.java:6268)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
    at java.awt.Component.processEvent(Component.java:6033)
    at java.awt.Container.processEvent(Container.java:2045)
    at java.awt.Component.dispatchEventImpl(Component.java:4629)
    at java.awt.Container.dispatchEventImpl(Container.java:2103)
    at java.awt.Component.dispatchEvent(Component.java:4455)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4633)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4297)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4227)
    at java.awt.Container.dispatchEventImpl(Container.java:2089)
    at java.awt.Component.dispatchEvent(Component.java:4455)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:649)
    at java.awt.EventQueue.access$000(EventQueue.java:96)
    at java.awt.EventQueue$1.run(EventQueue.java:608)
    at java.awt.EventQueue$1.run(EventQueue.java:606)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:116)
    at java.awt.EventQueue$2.run(EventQueue.java:622)
    at java.awt.EventQueue$2.run(EventQueue.java:620)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:619)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)
    Total no of people : 0

    Again, thanks for any help.  It's very much appreciated

    Terry

     
  • André Schenk

    André Schenk - 2012-04-25

    Hi Terry,

    the last error occurred because of the case sensitivity of XML elements. The parser expects "Duration" but your sample contains "duration".

    Is your XML really an export from the "MacDive" program or did you create it by yourself?

    Best regards,

    André

     
  • terry

    terry - 2012-04-25

    Hi Andre.

    A little of both.  I exported the xml from MacDive and then edited it, changing the root element to <logbook> as you suggested and then edited some of the data within the elements to remove the personal data and changed the temperature data to F as it looked like MacDive had exported it in C,  but didn't change any of tags. Here's the original:

    <?xml version="1.0" encoding="UTF-8"?>
    <dives>
        <units>Imperial</units>
        <schema>2.0.0</schema>
        <dive>
            <date>2011-12-04 10:30:00</date>
            <divenumber>1</divenumber>
            <country>Mexico</country>
            <location>Puerto Vallarta</location>
            <site>Las Marietas</site>
            <repetitive></repetitive>
            <sitelat>20.69446</sitelat>
            <sitelon>-105.58273</sitelon>
            <sitezoom>10</sitezoom>
            <diver>Terry</diver>
            <computer>No Computer</computer>
            <serial></serial>
            <maxdepth>60.00</maxdepth>
            <avgdepth>40.00</avgdepth>
            <gasmodel></gasmodel>
            <duration>2700</duration>
            <visibility>30</visibility>
            <surfaceint></surfaceint>
            <airstart>3000.00</airstart>
            <airend>600.00</airend>
            <sampleInterval>0</sampleInterval>
            <o2percent>21</o2percent>
            <tempair>23.33333333333334</tempair>
            <temphigh>21.11111111111111</temphigh>
            <templow>16.66666666666667</templow>
            <weather>sunny</weather>
            <weight>25</weight>
            <notes><![CDATA]></notes>
            <tags></tags>
            <buddies>
                <buddy>David</buddy>
            </buddies>
            <gear>
                <item>
                    <type>Tank</type>
                    <manufacturer>Rental</manufacturer>
                    <name>AL80</name>
                    <tanksize>80</tanksize>
                    <workingpressure>3000</workingpressure>
                </item>
            </gear>
            <samples></samples>
        </dive>
    </dives>

     
  • André Schenk

    André Schenk - 2012-04-25

    Hi Terry,

    that would mean there are different formats for MacDive XML files. That is annoying. Do you know if there exists a format description?

    Best regards,

    André

     
  • terry

    terry - 2012-04-25

    I've asked MacDive's author and if he sends me one, I'll forward it to you.

    Thanks Andre!

    Terry

     
  • terry

    terry - 2012-04-26

    Hi Andre.

    I didn't hear anything back from the MacDive author so I guess the easiest thing for me to do is use the udcf import as it seems to work ok.  It doesn't import <PLACE> though from what I can see.

    Terry

     
  • André Schenk

    André Schenk - 2012-04-26

    Hi Terry,

    after looking into the source code I think it is not as simple as it seems to import the place from an UDCF. Could you please file a change request for that?

    Best regards,

    André

     
  • terry

    terry - 2012-04-26

    Hi Andre.

    I have done as you suggested…I've never field a change request before.  Hopefully I've done it correctly.

    Your assistance has been great.  Thank you so much.

    Terry

     
  • terry

    terry - 2012-04-27

    Hi Andre,

    I'm thinking that I'm going to take a shot at writing a perl scrip to parse MacDive's current xml into what Jdivelog expects.  Can you send me a format description of what the Jdivelog parser is expecting?

    Thanks and best regards.

    Terry

     
  • André Schenk

    André Schenk - 2012-04-27

    Hi Terry,

    I only can point you to the source code.

    Best regards,

    André

     
  • terry

    terry - 2012-04-27

    Great.  That will help.

    Many thanks Andre.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks