Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Re: make a unbroken sequence of id attribute with XSD

Reply
Thread Tools

Re: make a unbroken sequence of id attribute with XSD

 
 
eephyne
Guest
Posts: n/a
 
      03-18-2011
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
 
Reply With Quote
 
 
 
 
Peter Flynn
Guest
Posts: n/a
 
      03-19-2011
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/
 
Reply With Quote
 
 
 
 
Jongware
Guest
Posts: n/a
 
      03-21-2011
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]
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: make a unbroken sequence of id attribute with XSD eephyne XML 1 03-24-2011 09:32 AM
Re: make a unbroken sequence of id attribute with XSD eephyne XML 2 03-24-2011 04:00 AM
Re: make a unbroken sequence of id attribute with XSD eephyne XML 1 03-21-2011 08:48 PM
Re: make a unbroken sequence of id attribute with XSD eephyne XML 1 03-18-2011 05:36 PM
make a unbroken sequence of id attribute with XSD eephyne XML 2 03-18-2011 02:50 PM



Advertisments