Menu

loading a GraphXML file, saving and restoring

2003-06-27
2003-08-28
  • Marc Siramy

    Marc Siramy - 2003-06-27

    This message follows my last message in the help section, concerning the node position.

    I think I've found some problems in Royere.
    I give you the scenerio :
    I write a GraphXML file conforming to GraphXML DTD, then I load it in Royere, eventually move some nodes, save it and after try to restore it.

    GraphXML file is not conform to the GraphXML DTD after saving. And it causes problems when you want to reload the file because at that time, I think Royere wants files that are conforming to the GraphXML DTD.

    I exposed you in my message on node positions the problem with the node,

    I've just found the same problems with  <graph> :
    Royere define for <graph> a enclosing box attribute,
    but it is not recognized when opening the file after saving it in Royere.

    There is an example below with some explanation comments :

    <?xml version='1.0'?>
    <!DOCTYPE GraphXML SYSTEM "file:/C:/dev/MonRoyereProjet/Graphs/testsMarc/GraphXML.dtd"
    >
      <GraphXML xmlns:xlink='http://www.w3.org/1999/xlink/namespace/'>
     
        <!-- with attribute enclosingBox (which is not defined in GraphXML DTD),
        Royere, at loading of document, seems to calculate indefinitely the layout -->
        <!-- <graph enclosingBox='(-227,96 264,50 -302,31 190,15 0,00 0,00)'> -->
       
        <!-- it seems to be no way to define a sort of enclosingBox in GraphXML DTD-->
        <graph>
          <node isMetanode='false' name='1' xlink:actuate='user' xlink:role='Reference to graph' xlink:show='new' xlink:type='simple' xmlns:xlink='http://www.w3.org/1999/xlink/namespace/'>
            <label>
              Paul
            </label>
            <!-- this is the way Royere write positions in GraphXML file -->
            <!--<properties horizontalPosition='0.0' verticalPosition='0.0'>
            </properties> -->
            <!-- this is the way positions are defined in the DTD -->
            <position x='21.0' y='-53.25489899999999' z='0.0'/>
          </node>

    So, I suppose that extending the DTD doesn't work. Maybe there is a problem in the saving module ?

     
    • Marc Siramy

      Marc Siramy - 2003-08-04

      To sum up, I think there are two problems :

      1- definition of the nodes :
      Royere seems to use <properties> instead of <position> in the DTD.

      2- The enclosingBox attribute in <graph>.

      Royere define <properties> and enclosing at the saving of a GraphXML file.

      But when you try to load the file again, it doesn't work because the file doesn't conform with the DTD anymore.
      To by pass <properties> problem, it is possible to manually specify an extension in the GraphXML file,
      like in "UserDefined.xml" example.

      I tried to do the same thing with enclosingBox by writing this, but it didn't work :
      <!DOCTYPE GraphXML SYSTEM "file:GraphXML.dtd" [
      <!ENTITY % admissibleProperties "
         horizontalPosition CDATA #IMPLIED
         verticalPosition CDATA #IMPLIED
      ">
      <!ENTITY % admissibleGraphProperties "
         enclosingBox CDATA #IMPLIED
      ">
      ]>

      Marc

       
    • yugen

      yugen - 2003-08-12

      I noticed that your XML has file has the dimensions
      of the enclosingBox in European format (i.e., a ',' instead of a '.' to denote the decimal point).  This  happens at save time if you are in a European locale.  (I am in the U.S., so my XML saves result in a period instead of a comma.)  I can read files with '.' but not with ','.

      However, there is no hardcoded locale in Royere.  When Royere reads the XML file, EnclosingBox.getDouble() calls Double.valueOf(), which calls FloatingDecimal.readJavaFormatString().  So I looked at the JDK source for FloatingDecimal.readJavaFormatString(), and the way it parses strings assumes a hardcoded locale, i.e., it only looks for '.', not ','.  I would have expected the code to dynamically check the current locale and react accordingly, but it doesn't.  I consider this a bug in the JDK.

      If you change the commas to periods, can you open the XML file?

       
    • Marc Siramy

      Marc Siramy - 2003-08-25

      you are right, I'm in a french locale.

      I've just tested Royere with American locale, and then the XML saves result is a period.
      Then I can open this XML file.

      I've noticed also that the problem only concerns enclosingBox and not node positions (<properties>). Node positions are saved with a '.' and not ','.

      So I wonder if it could be easy to reuse code concerning the saving of node positions for the enclosingBox.

      -Marc

       
      • yugen

        yugen - 2003-08-26

        Good idea.

        The code that writes data to XML is contained in GraphDomMediator.java.  When node coordinates are written, it is done by two calls:

        String.valueOf(coords.getX()))
        String.valueOf(coords.getY()))

        Evidently, String.valueOf() behaves nicely across locales.

        However, the Coordinates.toString() method uses DecimalFormat.format(), which is the same technique used in EnclosingBox.toString(), and this produces different numerical formats depending on locale.

        I think the best fix is to use NumberFormat with a standard locale, as opposed to DecimalFormat.  (See http://www.iro.umontreal.ca/~vaucher/Java/tutorials/Formatting.html .)  I've already checked in the appropriate change to EnclosingBox.java; I will do the same wherever else it is necessary in the Royere codebase.

         
    • Marc Siramy

      Marc Siramy - 2003-08-28

      Thank you for that,

      I downloaded your new EnclosingBox file and I have no problems anymore.

      By precaution, I carried out the same modifications as you in the Coordinates file. But maybe it's not very useful, as I never had problems with nodes.

      I don't think it's necessary to make modifications wherever else.

      Marc

       

Log in to post a comment.