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 that are specified in random order. 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. To avoid this extra work, you can hand-tune the schema that is generated by removing the unwanted ROWSETS and then providing 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> <COLUMN NAME="FIRST"></COLUMN> <ROWSET NAME="ORDER"> <COLUMN NAME="NUMBER"></COLUMN> <COLUMN NAME="DAY"></COLUMN> <COLUMN NAME="MONTH"></COLUMN> <COLUMN NAME="YEAR"></COLUMN> <ROWSET NAME="ITEM"> <COLUMN NAME="TITLE"></COLUMN> <COLUMN NAME="AUTHOR"></COLUMN> <COLUMN NAME="PRICE"></COLUMN> </ROWSET> </ROWSET> </ROWSET> '> </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>

© 1999 Microsoft Corporation. All rights reserved. Terms of use.