Is there any way to support keys / keyrefs in XML mapping approach?

Here's a sample bookstore Schema that uses keyrefs. Orders can refer to
many books, a book can be on many orders. In the Order object I just
want to store the primary keys of the books on that order (their ISDN):

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://www.bookstore.org/bookstore-schema";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns="http://www.bookstore.org/bookstore-schema";
elementFormDefault="qualified" attributeFormDefault="unqualified">
  <xsd:element name="bookstore">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="book" type="BookType" minOccurs="0"
maxOccurs="unbounded"/>
        <xsd:element name="order" type="OrderType" minOccurs="0"
maxOccurs="unbounded"/>
      </xsd:sequence>
    </xsd:complexType>
    <xsd:key name="book-pk">
      <xsd:selector xpath="book"/>
      <xsd:field xpath="ISDN"/>
    </xsd:key>
    <xsd:keyref name="book-ref" refer="book-pk">
      <xsd:selector xpath="order/book-ref"/>
      <xsd:field xpath="ISDN"/>
    </xsd:keyref>
  </xsd:element>
  <xsd:complexType name="BookType">
    <xsd:sequence>
      <xsd:element name="ISDN" type="xsd:string"/>
    </xsd:sequence>
  </xsd:complexType>
  <xsd:complexType name="OrderType">
    <xsd:sequence>
      <xsd:element name="order-number" type="xsd:string"/>
      <xsd:element name="book-ref" minOccurs="0" maxOccurs="unbounded">
        <xsd:complexType>
          <xsd:attribute name="ISDN" type="xsd:string"/>
        </xsd:complexType>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>
</xsd:schema>

An instance of this document looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<bookstore xmlns="http://www.bookstore.org/bookstore-schema";>
  <book>
    <ISDN>1234</ISDN>
  </book>
  <book>
    <ISDN>5678</ISDN>
  </book>
  <order>
    <order-number>1000</order-number>
    <book-ref ISDN="1234"/>
    <book-ref ISDN="5678"/>
  </order>
</bookstore>

However I could make the Castor mapping approach work only if the
instance looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<bookstore xmlns="http://www.bookstore.org/bookstore-schema";>
  <book>
    <ISDN>1234</ISDN>
  </book>
  <book>
    <ISDN>5678</ISDN>
  </book>
  <order books="1234 5678">
    <order-number>1000</order-number>
  </order>
</bookstore>

I don't even know how to represent this in a Schema. Any suggestions
would be much appreciated.
Thanks.
Naresh

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to