Guillaume Pothier wrote:This is absolutely true for real XML IDs, which also have a number of other restrictions (including that they must start with a letter-type character). JiBX doesn't enforce this rule, though, and as long as you're not stating that they're IDs in a schema or DTD you can use JiBX's loose interpretation. Typed IDs is one of the features I've had planned for a while.
First of all thanks for this great library.ID's have to be unique value across the xml document independent of the attribute name as there is no support for multiple sets of IDs in a XML document. So, what do you mean by "manage several sets of IDs?"
Regarding usage of IDs and IDREFs, is there a way to manage several sets of IDs? Consider for instance the following file, which describes how various computer parts form computers:
<base>
<monitors>
<monitor id="1" name="Samsung 753s"/>
<monitor id="2" name="Philips 107E"/>
</monitors>
<keyboards>
<keyboard id="1" name="AOpen"/>
<keyboard id="2" name="LG"/>
</keyboards>
<computers> <computer id="1" monitorId="1" keyboardId="2"/> </computers> </base>
...
Unfortunately, JiBX does not yet support this directly. If you don't have too many of these ID types that you need to work with you should be able to do a work-around fairly easily, though. This would involve using a set-method for unmarshalling each of the is values. The set-method can add an entry to a static hashmap (or a hashmap owned by the root element, or whatever) keyed by the id and with the "this" object as the value. You can then have a set-method on the referencing object that looks up the string it's passed to find the corresponding object (this assumes you don't have forward references; if you do, you'd need to do this last part when unmarshalling is done).
Alternatively, you can just use a unique prefix for each type of id. That way you can make them into true XML ID values, too. This would just require get/set methods on the id-ed object that strip off or add on the unique prefix.
Hope that helps. I'll be on the road for a couple of days and probably not responding, but can fill in details when I get back if needed.
- Dennis
-- Dennis M. Sosnoski Enterprise Java, XML, and Web Services Training and Consulting http://www.sosnoski.com Redmond, WA 425.885.7197
------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click _______________________________________________ jibx-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jibx-users
