Re: make a unbroken sequence of id attribute with XSD

Discussion in 'XML' started by eephyne, Mar 18, 2011.

  1. eephyne

    eephyne Guest

    what do you mean by node position ? If this is what i think , i can't use that because the number of object is not fixed

    my id attribute is just a numerical key.
    In concret the xml files will be used for generate different level in a game , each object represent a level and i don't want my program to crash if iselect level 2 and there is no object id="2" , i always verify that in my program but if its possible , it'll be preferable to check it using xsd
    eephyne, Mar 18, 2011
    #1
    1. Advertising

  2. eephyne

    Peter Flynn Guest

    On 18/03/11 16:43, eephyne wrote:
    > what do you mean by node position ? If this is what i think,


    It means:
    <object id="0" /> <!-- this is position 1 -->
    <object id="2" /> <!-- this is position 2 -->
    <object id="1" /> <!-- this is position 3 -->

    > i can't use that because the number of object is not fixed


    But you said it *was* fixed: it is controlled by the value of its
    immediately prior sibling.

    > my id attribute is just a numerical key.


    Avoid using "id" or "ID" as the attribute name unless the type is xml:id
    (or a declared ID type in a DTD) because it will confuse people. XML IDs
    must begin with a letter. Maybe call it "levelnumber" if that is what it is?

    > In concret the xml files will be used for generate different level in
    > a game , each object represent a level


    It might also be a good idea to call the element type "level" rather
    than "object".

    Sometime being meta is too much of a good thing :)

    > and i don't want my program to crash if i select level 2 and there is
    > no object id="2" , i always verify that in my program but if its
    > possible , it'll be preferable to check it using xsd


    At the moment I think you must check it in your processing, eg (using XSLT)

    <xsl:if test="@levelnumber=preceding-sibling::level/@levelnumber+1">

    ///Peter
    --
    XML FAQ: http://xml.silmaril.ie/
    Peter Flynn, Mar 19, 2011
    #2
    1. Advertising

  3. eephyne

    Jongware Guest

    On 19-Mar-11 22:30 PM, Peter Flynn wrote:
    > On 18/03/11 16:43, eephyne wrote:
    >> what do you mean by node position ? If this is what i think,

    >
    > It means:
    > <object id="0" /> <!-- this is position 1 -->
    > <object id="2" /> <!-- this is position 2 -->
    > <object id="1" /> <!-- this is position 3 -->
    >
    >> i can't use that because the number of object is not fixed

    >
    > But you said it *was* fixed: it is controlled by the value of its
    > immediately prior sibling.
    >
    >> my id attribute is just a numerical key.

    >
    > Avoid using "id" or "ID" as the attribute name unless the type is xml:id
    > (or a declared ID type in a DTD) because it will confuse people. XML IDs
    > must begin with a letter. Maybe call it "levelnumber" if that is what it
    > is?
    >
    >> In concret the xml files will be used for generate different level in
    >> a game , each object represent a level

    >
    > It might also be a good idea to call the element type "level" rather
    > than "object".
    >
    > Sometime being meta is too much of a good thing :)
    >
    >> and i don't want my program to crash if i select level 2 and there is
    >> no object id="2" , i always verify that in my program but if its
    >> possible , it'll be preferable to check it using xsd


    Wouldn't it be *far* simpler *not* to specify the level numbers in each
    'object'? If you select "level 2" (and the first one is "level 1"),
    simply load in the 2nd object.

    [Jw]
    Jongware, Mar 21, 2011
    #3
    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. eephyne
    Replies:
    2
    Views:
    932
    Alain Ketterlin
    Mar 18, 2011
  2. eephyne
    Replies:
    1
    Views:
    930
    Martin Honnen
    Mar 18, 2011
  3. eephyne
    Replies:
    1
    Views:
    890
    Peter Flynn
    Mar 21, 2011
  4. eephyne
    Replies:
    2
    Views:
    924
    Joe Kesselman
    Mar 24, 2011
  5. eephyne
    Replies:
    1
    Views:
    881
    Jongware
    Mar 24, 2011
Loading...

Share This Page