wood burning stoves*
The moose likes XML and Related Technologies and the fly likes same element multiple times with default values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "same element multiple times with default values" Watch "same element multiple times with default values" New topic
Author

same element multiple times with default values

Priti Shah
Ranch Hand

Joined: May 10, 2005
Posts: 43
Hi,

I have xml file some thing like this

<classes>
<class id='class1' number='1'></class>
<class id='class2' number='2'></class>
<class id='class3' number='3'></class>
<class id='class4' number='4'></class>
</classes>

I want to write schema for this. Constraint is 'class1' can only have number value '1', 'class2' can only have number values '2' so on...

So i can not use enumeration here because some how i want to keep fix values of both the attributes.

One way of doing this is I can define static elements in schema with predefined values but problem doing this is that it rejects to have element with same name more than once.

Any idea how can it be done ?

Any help is appreciated.
Thanks
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
The constructs you are looking for are



or should I just write a text file, since everything seems to be fixed.

I would recommend Definetive XML Schema.

- m


Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Priti Shah
Ranch Hand

Joined: May 10, 2005
Posts: 43
My main concern here is all elements are of same type 'class'. So can you write above snippet in little bit more detail which includes multiple class elements ?

Thanks
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: same element multiple times with default values