Previous Next

XML Data Source Applet

Example 4

This example shows how a separate SCHEMA can also be provided to further normalize the data prior to binding. In this example the customer data is more structured. The <NAME> now consists of <FIRST>, <MIDDLE> and <LAST> parts which are specified in random order. Also the <DATE> is now stored as separate components <DAY>, <MONTH> and <YEAR>.
,
//

The problem with this extra structure is that the schema generator now considers the <NAME> and <DATE> nodes as ROWSETS when they are never really going to be repeated. Having them become ROWSETS makes it much more effort to bind to the sub-fields. So to avoid this extra work, you can hand-tune the schema that is generated by removing the unwanted ROWSETS and then provide this in a SCHEMA <PARAM> on the <APPLET> tag as follows:

<applet code=com.ms.xml.dso.XMLDSO.class width=100% height=25 id=xmldso mayscript=true> <param name="URL" value="cust.xml"> <param name="SCHEMA" VALUE=' <ROWSET NAME="CUSTOMER"> <COLUMN NAME="LAST"/> <COLUMN NAME="FIRST"/> <ROWSET NAME="ORDER"> <COLUMN NAME="NUMBER"/> <COLUMN NAME="DAY"/> <COLUMN NAME="MONTH"/> <COLUMN NAME="YEAR"/> <ROWSET NAME="ITEM"> <COLUMN NAME="TITLE"/> <COLUMN NAME="AUTHOR"/> <COLUMN NAME="PRICE"/> </> </> </> '> </applet> The table that binds to this data is as follows: <table id=table datasrc=#xmldso border=2 width=100% cellpadding=3> <tr><td valign=top><span datafld=LAST></span>, <span datafld=FIRST></span> <td valign=top> <table border=2 width=100% cellpadding=3 datasrc=#xmldso datafld=ORDER> <tr><td valign=top><span datafld=MONTH></span>/<span datafld=DAY></span>/<span datafld=YEAR></span> <td valign=top><table border=2 width=100% cellpadding=3 datasrc=#xmldso datafld=ORDER.ITEM> <tr><td valign=top><div datafld=TITLE dataformatas=HTML> <td valign=top><div datafld=AUTHOR dataformatas=HTML> <td valign=top><div datafld=PRICE dataformatas=HTML> </table> </table> </table>

The XML DSO Source Code is in Java.

© 1997 Microsoft Corporation. All rights reserved. Legal Notices.