| how would you
| make sure that the correct <rate> went into the corresponding
| <booking>??
Darren,
Ok. I hope this answers your question. Thinking about this, I believe what
you need to implement is the ID and IDREF attribute on the booking and rate
tags. ID would uniquely specify the element, and the IDREF would point to
that element. The value for ID has to be unique in each element in the
document, and the value for IDREF has to match an ID in the document.
See http://www.w3.org/TR/REC-xml#id for more information!
Ohh... there's one more thing...
Hey! Yes! I've got a tip! I can put this in a tip!
<tip type="XML and databases">
If you plan to create an XML document from a database, where several
tables are queried to form the results, and you include the id of the record
in the table in the element in the document which is to contain it, there
arises the possibility of a conflict of ID attribute values, which, per the
XML spec, is a no-no.
One common way to overturn this defeat is to preface the name of the
id number from the table before inserting it into the document. You might
use the target tag name, or the table name from the database, depending on
your structure. For instance:
~~~~~~~~This is broken:
<form id=12>
<name>Login</name>
<descr>The login page</descr>
<url>http://localhost/login.cfm</url>
</form>
<field id=12 idref=12>
<name>username</name>
<type>alphanumeric</type>
<descr>User's user name</descr>
</field>
~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~This works:
<form id="form.12">
<name>Login</name>
<descr>The login page</descr>
<url>http://localhost/login.cfm</url>
</form>
<field id="field.12" idref="form.12">
<name>username</name>
<type>alphanumeric</type>
<descr>User's user name</descr>
</field>
~~~~~~~~~~~~~~~~~~~~~~~~
</tip>