Επεξεργασία

Κοινή χρήση μέσω


XSLT Transformations

XSLT can be applied to the generated XML to transform it into another format. Understanding the XML format in ADO helps in developing XSLT templates that can transform it into a more user-friendly form.

For example, you know that each row of the Recordset is saved as the z:row element inside the rs:data element. Similarly, each field of the Recordset is saved as an attribute-value pair for this element.

Remarks

The following XSLT script can be applied to the XML shown in the previous section to transform it into an HTML table to be displayed in the browser:

<?xml version="1.0" encoding="ISO-8859-1"?>  
<html xmlns:xsl="http://www.w3.org/TR/WD-xsl">  
<body STYLE="font-family:Arial, helvetica, sans-serif; font-size:12pt; background-color:white">  
<table border="1" style="table-layout:fixed" width="600">  
  <col width="200"></col>  
  <tr bgcolor="teal">  
    <th><font color="white">CustomerId</font></th>  
    <th><font color="white">CompanyName</font></th>  
    <th><font color="white">ContactName</font></th>  
  </tr>  
<xsl:for-each select="xml/rs:data/z:row">  
  <tr bgcolor="navy">  
    <td><font color="white"><xsl:value-of select="@CustomerID"/></font></td>  
    <td><font color="white"><xsl:value-of select="@CompanyName"/></font></td>  
    <td><font color="white"><xsl:value-of select="@ContactName"/></font></td>   
  </tr>  
</xsl:for-each>  
</table>  
</body>  
</html>  

The XSLT converts the XML stream generated by the ADO Save method into an HTML table which displays each field of the Recordset along with a table heading. Table headings and rows also are assigned different fonts and colors.

See Also

Persisting Records in XML Format