Transforming a DataSet Using XSLT

[ Team LiB ] Recipe Transforming a DataSet Using XSLT Problem You need to use an XSLT stylesheet to transform the contents of a DataSet. Solution Create an XslTransform object and call the Transform( ) method. | Team LiB Recipe Transforming a DataSet Using XSLT Problem You need to use an XSLT stylesheet to transform the contents of a DataSet. Solution Create an XslTransform object and call the Transform method. You ll need to add the Microsoft Web Browser control to the Toolbox from the COM tab in the Customize Toolbox Dialog. You ll also need a reference to the Microsoft HTML Object Library from the COM tab in Visual Studio .NET s Add Reference Dialog. Example 8-10 uses one XML file The XSLT stylesheet used to transform the XML for the Categories table in the DataSet into HTML displaying the Categories data in an HTML table. The contents of this XML file are shown in Example 8-10. The sample code contains three event handlers Sets up the sample by filling a DataSet with the Categories table from Northwind. Transform Initializes a WebBrowser control. Once the control is initialized the DocumentComplete event is raised. The handler for the DocumentComplete event completes the XSLT transformation. DocumentComplete Gets the XmlDataDocument for the DataSet creates an XSLTransform class and transforms the XML document using the XSLT stylesheet. The results are displayed both in the WebBrowser control and as XML. Example 8-10. File xml version encoding UTF-8 xsl stylesheet xmlns xsl http 1999 XSL Transform version xsl template match html body table tr bgcolor AAAAAA td Category ID td td Name td td Description td tr xsl for-each select CategoriesDS Categories tr td xsl value-of select CategoryID td td xsl value-of select CategoryName td td xsl value-of select Description td tr xsl for-each table body html xsl template xsl stylesheet The C code is shown in Example 8-11. Example 8-11. File Namespaces variables and constants using System using using using using using using Table name constants .

Bấm vào đây để xem trước nội dung
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.