Sunday, February 28, 2010

Using XSLT to Generate SQL Script

Recently, I received a task to check every field configured at FilterConfig.xml file to make sure that each field has the relative columns' name in Table or View which is configured at ScanConfig.xml file.

P.S: The FilterConfig.xml is used for the filter module in our system, and this module is based on the web control "SqlWhereBuilder". (Refer: http://www.codeproject.com/KB/custom-controls/SqlWhereBuilder.aspx)

If some field is configured at FilterConfig.xml file but not exists in relative table or view, there must be something wrong with either configuration or the database schema.

When dipping into the two configuration files. I found that each field is configured under the node "Module", and each module has the relative "Module" node with the same ID name in ScanConfig.xml, and “TableName” is also configured as a property of the "Module" node of that file, the “TableName” shows the real table name or view name in database.

Example:

-1-. FilterConfig.xml
Collapse

<?xml version="1.0" encoding="utf-8"?>
<FilterSchema>
<Module ID="MasterInfo">
 <Field ID="ADDRESS1" Text ="Address" OperatorList ="datatype_text" />
 <Field ID="ADDRESS2" Text ="Address2" OperatorList ="datatype_text" />
 <Field ID="ADDRESSTYPE" Text ="Address Type" OperatorList ="datatype_text" />
</Module>
<FilterSchema>

Read more: Codeproject

Posted via email from jasper22's posterous