HandsOn Exporting Data and Applying a Custom XSL File

1. Open the Customers table in the Northwind database and choose File | Export.

2. In the Export Table 'Customers' To window perform the following:

Select the Learn_XML folder from the Save in drop-down list.

■ Enter ListCustOrders in the File name box.

■ Select XML from the Save as type drop-down list.

3. In the Export XML dialog box, the first two check boxes should be selected. Click the More Options button.

4. In the Data to Export area, the Customers table is automatically selected. Click the check box next to the Orders table to include it in the export.

5. Click the Transforms button.

6. In the Export Transforms window that appears, click the Add button.

Part V

Access displays the Add New Transform window. Switch to the Learn_XML folder and select the ListCustOrders.xsl file that you created in the previous hands-on exercise. Click the Add button to add this file to the list of transforms. The transformation file appears in the list as shown in Figure 29-11.

Figure 29-11: Use this window to indicate a transformation file (stylesheet) to be used after export.

8. In the Export Transforms window, click OK.

9. Back in the Export XML dialog box, change the file extension from xml to html as shown in Figure 29-12.

Export XML

Data I Schema Piesenlation

0 Export Data Data to Export:

Data I Schema Piesenlation

0 Export Data Data to Export:

Customers

EB 0 Orders

< I

Records To Export; 0 All Records

1 ^pty nesting filter O Curort record

II Apply Existing Sort

Encodng: |UTF-8 v

Export Location:

C:\Learn_XNL\Li£tCustOrde/s.html|

Export Location:

C:\Learn_XNL\Li£tCustOrde/s.html|

Records To Export; 0 All Records

1 ^pty nesting filter O Curort record

II Apply Existing Sort

Encodng: |UTF-8 v

I Help 1

J I Canal I

Figure 29-12: To export XML data directly to the HTML file, you must choose the transformation file using the Transforms button, and change the file extension from xml to html.

10. Click the OK button to begin the export.

^^ Note: If the selected transformation file is invalid, you will see an error message. Access will prompt you to save the data for troubleshooting and will bring up the Export XML dialog box. At this time you may want to open the transformation file in Notepad and make appropriate corrections. Once you save the corrected XSL file you should return to the Export XML dialog to try the export again. Before you click the OK button in the Export XML dialog box, ensure that the appropriate tables are selected.

Taking Your VBA Programming Skills to the Web

11. Activate Windows Explorer and open the ListCustOrders.html file. The final result of applying the custom transformation file is shown in Figure 29-13.

a C:U_eürn_XHL\ListCu5t0rdGr3,html ■ Miciosof...

File Edt View Favorites Tocfe Help Q Eco • 0 L*1 Ltl ilJ ,PS"rch

Mrlress ^ f : \ L ean M L \ L i £ h j js t û i d b r ; h h: I v jQ Gff lirl H

Orders by Customer

ALFKI Alitis FntleiMite

Orders by Customer

ALFKI Alitis FntleiMite

I CtLd I"Lr

r-Xr.r—(■. r*ir

1 L0643

1997-08-25

1997-09-02

1997-09-22

(29.46

1 10692

1991-10-03

1997-10-13

1 »74131

(61.02

1 10702

1(57.10.13

1PP7.10.21

1997.11.24

(2334

1 10331

195SO1-0I

199S-01-21

1998-02-12

(69 33

1 10932

L99S-03-16

199S-1E-24

1J9S-04-27

(40 42

1 11011

WtM.0)

1WS.M.I3

Î9ÎJS.0Î-O7

Mil

ANATR Ana Trajillc HjttpareditcLos y kelaàos

Ctiïrtîti

ïrjrptd Data

1 10303

ÏÎ9MS-IS

190É.C0.24

1956.IO.lfi

f 1.61

1 10625

1997-08-83

10S7JB.14

1997-09-C5

(43.90

1 107»

1997-11-28

1997-12-12

1957-12-26

(¡1.99

1 10W

199S-03.[Ü

IM®. 013. Il

l»E.(ÎMl

(39.92

Figure 29-13: XML data can be formatted any way you like by applying a custom transform (see Hands-On 29-11 and 29-12).

12. Close the browser.

0 0

Post a comment