[xsd-users] Question about ID/IDREF

Boris Kolpackov boris at codesynthesis.com
Mon Sep 12 08:38:00 EDT 2005


Mickael,

Vera Mickael <vera.mickael at free.fr> writes:

> Each time I use ID and IDREF, the method in the generated
> model for the attribute that uses IDREF returns a
> java.lang.Object. This makes the generated model very
> difficult to use.

Ok, you mean you have to manually cast it to a concrete type.


> Does xsd generate the same (a method that returns void *) ?

At the moment, xsd generates a member function that returns
a pointer to a type that all generated types inherit from
(similar to java.lang.Object). You have to cast this pointer
to a concrete one.

> Or is there a way to specify the type of the element
> referenced by IDREF, by annotations for example ?

Not at the moment but we have plans to do so. The idea is
to have an attribute that you can use to specify the "real
type" of IDREF, e.g.:

<xsd:complexType name="author">

  ...

  <xsd:attribute name="recommends"
                 type="xsd:IDREF"
                 ref-type="lib:book"/>
</xsd:complexType>


<xsd:complexType name="book">
  <xsd:sequence>
    <xsd:element name="title" type="xsd:string"/>

    ...

  </xsd:sequence>

  <xsd:attribute name="id" type="xsd:ID" use="required"/>
</xsd:complexType>


Then you will be able to write something like this:

author a = ...

cerr << a.recommends ()->title () << endl;


Would you be interested in something like this?

-boris

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 652 bytes
Desc: Digital signature
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20050912/897c3835/attachment.pgp


More information about the xsd-users mailing list