473,406 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Referencing a value from a list

Hi there,

I'm sure this has been posted before but I didn't know how to search
for it because I don't know the name for what I am trying to do so
I'll try and explain it as best I can.

I have an application that captures some data about football players.
I have fields for name, date of birth, nationality etc and things like
position such as Goalkeeper, Striker etc. I need to store all this
data in an XML file. In the case of the positions, I will populate a
control in the program with a predetermined list of available
positions (which also needs to be in the XML file) and then I simply
select one from the list for each player. My question is, how do I
store that for each player?

If I have something like:

<positions>
<position>Goalkeeper</position>
<position>Striker</position>
...
</positions>
<players>
<player>
<player_name>David Beckham</player_name>
<player_position??? what goes here??? </player_position>
...
</player>
</players>

What do I put in my player_position element above? Obviously one
solution is simply to copy the text from the position element but
thats not ideal because when I load the application from the XML file
later I'd want to be able to populate the UI control with the
available positions (which I might change the names of) and then
indicate that David Beckham is in the first position in the list for
exmple and avoid that duplication.

I hope that makes sense!

Thanks,
Caroline Middlebrook

Jan 29 '07 #1
2 1259

On Jan 29, 12:16 pm, "Caroline M"
<caroline.middlebr...@googlemail.comwrote:
I have an application that captures some data about
football players. I have fields for name, date of birth,
nationality etc and things like position such as
Goalkeeper, Striker etc. I need to store all this data in
an XML file.

<positions>
<position>Goalkeeper</position>
<position>Striker</position>
...
</positions>
<players>
<player>
<player_name>David Beckham</player_name>
<player_position??? what goes here???
</player_position>
...
</player>
</players>

What do I put in my player_position element above?
Obviously one solution is simply to copy the text from
the position element but thats not ideal because when I
load the application from the XML file later I'd want to
be able to populate the UI control with the available
positions (which I might change the names of) and then
indicate that David Beckham is in the first position in
the list for exmple and avoid that duplication.
The following approach is oft used, especially by people
with RDBMSy backgrounds:

<football-data>
<positions>
<position id="1">Goalkeeper</position>
<position id="2">Striker</position>
</positions>
<players>
<player>
<player_name position="1">David Beckham</player_name>
</player>
</players>
</football-data>

In this case, however, the following might be a bit better:

<football-data>
<positions>
<position>
<name>Goalkeeper</name>
<players>
<player>
<name>David Beckham</name>
</player>
</players>
</position>
<position>
<name>Striker</name>
</position>
</positions>
</football-data>

Also note that, depending on what you're using to process
this data, you might want to simply do away with the
positions element, store the positions' names within the
player elements and populate whatever needs to be populated
by selecting all the distinct values of player_position
elements in the document. For that matter, depending on
what your final goals (no pun intended) are, you might want
to employ all three of the proposed representations--
probably even more--and transform your data on the fly
using XSLT. You would still need to choose one canonical
representation of data, but it's hard to tell which one
would be best without knowing much more about your project,
so this decision is entirely up to you.

--
Pavel Lepin

Jan 29 '07 #2
Hi Caroline,

You can define an attribute, let's say for instance xml:id, for the
position element and specify a unique value for each position. Then,
in player_position you can have another attribute, for instance
positionId and specify one of those values that you defined for
position.
Depending on the schema language that you use there are different ways
to enforce this. Look for ID and IDREF.

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

On Jan 29, 12:16 pm, "Caroline M"
<caroline.middlebr...@googlemail.comwrote:
Hi there,

I'm sure this has been posted before but I didn't know how to search
for it because I don't know the name for what I am trying to do so
I'll try and explain it as best I can.

I have an application that captures some data about football players.
I have fields for name, date of birth, nationality etc and things like
position such as Goalkeeper, Striker etc. I need to store all this
data in an XML file. In the case of the positions, I will populate a
control in the program with a predetermined list of available
positions (which also needs to be in the XML file) and then I simply
select one from the list for each player. My question is, how do I
store that for each player?

If I have something like:

<positions>
<position>Goalkeeper</position>
<position>Striker</position>
...
</positions>
<players>
<player>
<player_name>David Beckham</player_name>
<player_position??? what goes here??? </player_position>
...
</player>
</players>

What do I put in my player_position element above? Obviously one
solution is simply to copy the text from the position element but
thats not ideal because when I load the application from the XML file
later I'd want to be able to populate the UI control with the
available positions (which I might change the names of) and then
indicate that David Beckham is in the first position in the list for
exmple and avoid that duplication.

I hope that makes sense!

Thanks,
Caroline Middlebrook
Jan 29 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rooksarii | last post by:
Hello folks, Let me first apologize for any impropper terminology I may use as I am presently trying to broaden my Office knowledge by diving into Access head on. My specific problem is this....
13
by: Dan Bass | last post by:
Say I've got an ArrayList, which contains a list of integers. Is it possible to get a reference to one of the integers contained within the collection so that changes to it are reflected in the...
4
by: darrel | last post by:
I have a contact form that a person submits to the server. In ASP, you'd make a page, post the form to another page, which would grab the values and do somethign with them. in ASP.NET, it...
6
by: Mikey_Doc | last post by:
Hi We are running cms 2002, Framework 1.0 with Visual studio 2002. We have just upgraded to Framework 1.1 and visual studio 2003. All of our database connection strings are stored within the...
2
by: amerar | last post by:
Hi All, I'm not a javascript programmer, but I'm trying to accomplish something here that is not working. I have 2 buttons on an HTML form, along with several text fields. If Button #1 is...
1
by: John Kotuby | last post by:
Hi all, I am working on porting an application from VB6 to VB.NET 2003 and am running into some problems. When declaring and populating the parameters for a SQL Stored Procedure by using the...
10
by: rshepard | last post by:
While working with lists of tuples is probably very common, none of my five Python books or a Google search tell me how to refer to specific items in each tuple. I find references to sorting a list...
11
by: ozTinker | last post by:
I'm sure this shouldn't be too difficult, but I lack familiarity with the MS object model. Suppose I have a table "Purchase_Orders" and a form "TEMP" which I am using to look up a customer's...
1
by: rmcellig | last post by:
This is the code I am using at the moment for my pull down menu. It works great. I was wondering if it is possible to have the pull down menu reference a list file instead of entering each item...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.