By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,559 Members | 1,150 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,559 IT Pros & Developers. It's quick & easy.

For XML Schema gurus - populate 2 combo boxes from schema data

P: n/a
The XML Schema design problem to solve is as follows:

We have 2 combo boxes to populate from schema data, let's say:

1. States
2. Cities (and this one gets populated depending on the choice of the

The event management is no problem, the question is, how do we build
our XML Schema (that's going to contain the data for both states and
cities, as we use it to validate the XML that we generate based on the
forms from it, so both have a double purpose), so that we can link
states and cities?
We're using XML Beans as our object model for the schema, and our
application is built in Swing.
We have some other combo boxes based in enumerations, those are OK,
but in this case we have to make a link so that we cannot have one
single huge cities enumeration (and to make sure we don't get funny
state-city matches).

So far we have seen that this might be a possible solution, but as XML
Beans refer to objects by name, we need some sort of link between
state codes and state names...

(there might be typos here...)

<complexType name="STATE1">
<element name="STATENAME" fixed="here_goes_state_name"/>
<element name="CITIES">
<restriction base="string">
<enumeration value="here_go_city_names"/>

Then we would have the list of state codes, something like this:

<simpleType name="STATE_ENUM">
<restriction base="int">
<enumeration value="1"/>
<!-- more codes here -->

We would put all the states (1..n) in some sort of parent collection
so that we would get them in order, as the codes in the STATES_ENUM.
The XML Beans don't have any generic method to get all the children
for a given element, you have to refer them by class name (that's
quite a problem in this case).

We would probably have a separate list for state names, just to
populate the state combo (labels as names, codes as digits that would
go in the generated XML created from the user's choices).

It'd all be a lot easier if we had simple XML files, not schemas, but
it seems there can be no mixture of both (besides, the XML beans do
not allow to generate an object model from an XML file, and we need
the validation for the state and city data in the schema)

does this seem correct? if not, any suggestions?

thanks in advance

Jul 20 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.