schema and default xml

Discussion in 'XML' started by inquirydog, Jul 13, 2004.

  1. inquirydog

    inquirydog Guest

    Hi-

    I am using xml to hold configuration data for a project, and
    using
    schema to define what the configuration file should look like. I
    wanted to
    get some advice on an intelligant way to specify and create a default
    config
    file. In other words, when the developer puts a new element in the
    schema
    (ie, backgroundColor), (s)he should also specify the default value
    (ie- green). This could be done in the same file as the schema (I
    could for certain circumstances use the xsl:default attribute for
    simpletypes), or in another file (we could just specify the actual
    default value). Then I would like to be able to do the following:

    1). Autogenerate the default file from however it is
    specified.

    2). In the case of a version upgrade in the schema
    (configuration file), automatically add in the default values to the
    actual configuration file for elements that are added. In other
    words, if version 1 only has a "backgroundColor" element, which in the
    config file is "rose", and in version 2 the schema adds a
    "forgroundColor" with default value "white", a new default file will
    be generated by merging the actual config file with the default of the
    new version (bgcolor=rose, fgcolor=white- the default fgcolor is taken
    since that element is new, the bgcolor default is not set since that
    was already specified in the old config file.

    In theory this can be done the following way.

    1). Encode defaults in the xsd file. For simpleType there is
    a xsd:default attribute which would work, for lists something else
    would need to be done.

    2). Use xslt to translate the data in the xsd file described
    in 1). to an xml file.

    3). Use some sort of xmldiff program to diff the config file
    from the default.

    4). Apply the result to the version n+1 default file to build
    the new default.

    I am unaware of what good xmldiff and xmlmerge style programs
    exist to do this. Suggestiong on any of this idea?

    thanks
    -Inquirydog
    inquirydog, Jul 13, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page