Best practice Questions

Discussion in 'XML' started by jlamb77@googlemail.com, Apr 20, 2007.

  1. Guest

    Hi,

    I am in the process of creating a schema definition to validate some
    XML data that will look like the following:

    ProductA

    SubProductA
    SubProductB
    SubProductC

    ProductB

    SubProductX
    SubProductY
    SubProductZ

    Now I would like if possible to create a simple type called say
    "Product" which has Enum content of:

    Enum:"ProductA"
    Enum:"ProiductB"
    ......
    ......

    Then also have another simple type for the "SubProduct" with it's Enum
    values as follows:

    Enum:"SubProductA"
    Enum:"SubProductB"
    EnumL:"SubProductX"
    ......


    I am struggling in deciding the best way to structure the complex Type
    so that the Structure is enforcing the fact that SubProductX can only
    be a SubProduct of ProductB......

    I would like the flexability to be able to simply add a new
    ProductType and enforce the relevant subtypes allowed to be detailed
    with them.

    Am fairly new to XSD (3 Weeks in) Any help much appreciated.
     
    , Apr 20, 2007
    #1
    1. Advertising

  2. Andy Dingley Guest

    On 20 Apr, 16:11, wrote:

    > I am in the process of creating a schema definition to validate some
    > XML data that will look like the following:


    Just don't. This isn't an appropriate concept to try and validate
    with schema.


    Sadly it's too difficult to spend the full time explaining, given
    today's workload. Briefly though:

    Schema / DTD validates XML _structure_ and not 'data' content. If you
    follow your approach here, you're pushing 'data' items into the
    structure by using them to generate element names. This would also
    permit DTD / Schema validation ("permit", not "make it easy") of your
    data rules. However this is also a use of XML that's usually a bad
    idea -- you've implemented something that's changeable in practice
    (product structure) and nailed it down with something that really
    implies long-term stability (XML Schema).

    A better approach would be a simple XML Schema based on just <Product>
    as an element and keeping ProductA, ProductB etc. well away from this.
    This does make Schema-based validation difficult though and starts to
    look like a task for OWL instead. Even then, it's still easy to get to
    a stage of complexity where it becomes impossible to validate
    automatically. Better than fluid element names though.
     
    Andy Dingley, Apr 20, 2007
    #2
    1. Advertising

  3. > I am struggling in deciding the best way to structure the complex Type
    > so that the Structure is enforcing the fact that SubProductX can only
    > be a SubProduct of ProductB......


    That sounds like it ought to be something enforced by your application
    code, at least as much because it will change dynamically over time
    based on other tables of product relationships as because it'll be a
    pain to do in schemas. (You don't want to have to change the schema when
    you introduce a new product.)

    Schemas are used to define the structure of a language. What you say
    with the language is a separate question.

    Use the schema system to define the structure of your documents, and
    reasonable ranges for their values... but for nontrivial applications,
    don't assume it's the only check that will be performed. Your
    applications will have to continue applying semantic checks if you want
    to make sure the document means something reasonable.


    (By analogy: A schema for English would conclude that "colorless green
    ideas sleep furiously" is a perfectly reasonable statement, because all
    the words are valid and the sentence structure is acceptable. The fact
    that it's nonsense has to be dealt with at another level.)

    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
     
    Joe Kesselman, Apr 20, 2007
    #3
  4. Guest

    On Apr 20, 8:54 pm, Joe Kesselman <> wrote:
    > > I am struggling in deciding the best way to structure the complex Type
    > > so that the Structure is enforcing the fact that SubProductX can only
    > > be a SubProduct of ProductB......

    >
    > That sounds like it ought to be something enforced by your application
    > code, at least as much because it will change dynamically over time
    > based on other tables of product relationships as because it'll be a
    > pain to do in schemas. (You don't want to have to change the schema when
    > you introduce a new product.)
    >
    > Schemas are used to define the structure of a language. What you say
    > with the language is a separate question.
    >
    > Use the schema system to define the structure of your documents, and
    > reasonable ranges for their values... but for nontrivial applications,
    > don't assume it's the only check that will be performed. Your
    > applications will have to continue applying semantic checks if you want
    > to make sure the document means something reasonable.
    >
    > (By analogy: A schema for English would conclude that "colorless green
    > ideas sleep furiously" is a perfectly reasonable statement, because all
    > the words are valid and the sentence structure is acceptable. The fact
    > that it's nonsense has to be dealt with at another level.)
    >
    > --
    > () ASCII Ribbon Campaign | Joe Kesselman
    > /\ Stamp out HTML e-mail! | System architexture and kinetic poetry


    Thanks very much for your responses i'll take that on board.
     
    , Apr 21, 2007
    #4
    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.
Similar Threads
  1. Robert Rossney
    Replies:
    0
    Views:
    564
    Robert Rossney
    Feb 7, 2006
  2. Bryan Ax
    Replies:
    0
    Views:
    620
    Bryan Ax
    Jun 26, 2003
  3. KimmoA
    Replies:
    66
    Views:
    1,271
    Richard Heathfield
    Sep 14, 2006
  4. vels
    Replies:
    2
    Views:
    345
    Sherman Pendley
    Nov 24, 2007
  5. oldyork90
    Replies:
    1
    Views:
    174
    Jeremy J Starcher
    Sep 10, 2008
Loading...

Share This Page