Suggestion to XML format?

Discussion in 'XML' started by carl, Mar 24, 2010.

  1. carl

    carl Guest

    I need to setup various parameters for a sequence of processes that are
    exectued in my application.

    Some of the parameters are common parameters for all processes while others
    are unique for the give process. Currently I was thinking of doing:

    <main>
    <parameters>
    <parameter id="steps" value="10000"/>
    <parameter id="outPutFolder" value="c:\test"/>
    <parameter id="color_type" value="3"/>
    </parameters>
    <processA>
    <parameters>
    <parameter id="x_type" value="1"/>
    <parameter id="y_type" value="3"/>
    </parameters>
    </processA>
    <processB>
    <parameters>
    <parameter id="interpolator_type" value="1"/>
    <parameter id="space_type" value="4"/>
    <parameter id="frame_type" value="2"/>
    </parameters>
    <levels>
    <level order = "1">
    <parameters>
    <parameter id="grid_size" value="3"/>
    <parameter id="numb_of_samples" value="5000"/>
    </parameters>
    </level>
    <level order = "2">
    <parameters>
    <parameter id="grid_size" value="6"/>
    <parameter id="numb_of_samples" value="10000"/>
    </parameters>
    </level>
    </levels>
    </processB>
    </main>



    In the above example the first set of parameters are common for all
    processes and subprocesses. Next parameters local for each process and its
    subprocesses are specified.

    Is this a good way to organize a xml file for the above described purpose?
    Or could it be clarified/reduced in size?
     
    carl, Mar 24, 2010
    #1
    1. Advertisements

  2. carl

    Peter Flynn Guest

    It's usually better to make the structure as generic and extensible as
    possible.

    1. Give each parameter block an attribute to identify the process, so
    that you don't need to use element types named after the processes
    (which may change over time) -- it's much easier to specify and
    control attributes than element types.

    2. Use the implicit inheritance of the hierarchical model to encapsulate
    the level data *inside* the parameter block for that process. That
    way it can't get lost or misidentified so easily: the process now
    "owns" the level data associated with it.

    3. Don't abuse "id" as an attribute name when the values are not
    guaranteed unique in the file. I know that the attribute name "id"
    doesn't necessarily mean it must be declared as type ID, but the very
    name is associated with that concept, and if you are sending this to
    other people or external processes, it is VERY misleading to use "id"
    when you actually just mean a name label. Call it "name" and then
    there is no confusion.

    <main>
    <parameters process="global">
    <parameter name="steps" value="10000"/>
    <parameter name="outPutFolder" value="c:\test"/>
    <parameter name="color_type" value="3"/>
    </parameters>
    <parameters process="A">
    <parameter name="x_type" value="1"/>
    <parameter name="y_type" value="3"/>
    </parameters>
    <parameters process="B">
    <parameter name="interpolator_type" value="1"/>
    <parameter name="space_type" value="4"/>
    <parameter name="frame_type" value="2"/>
    <levels>
    <level order = "1">
    <parameters>
    <parameter name="grid_size" value="3"/>
    <parameter name="numb_of_samples" value="5000"/>
    </parameters>
    </level>
    <level order = "2">
    <parameters>
    <parameter name="grid_size" value="6"/>
    <parameter name="numb_of_samples" value="10000"/>
    </parameters>
    </level>
    </levels>
    </parameters>
    </main>

    There is probably a lot more optimisation that could be done, but we'd
    need to become familiar with your business process to do that.

    ///Peter
     
    Peter Flynn, Mar 28, 2010
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.