Procedure
1. Develop the dll (signature required) using System;
Using System. Collections. Generic;
Using System. Text;
Using System. Xml;
Using System. Xml. Schema;
Namespace ETLXmlParser
{
Public class ETLXmlParser
{
Private static bool isValid = true;
Public static bool Validate (string XmlFilepath, string XsdFilePath)
{
Try {
XmlReader reader;
XmlReaderSettings settings = new XmlReaderSettings ();
XmlSchemaSet schemaSet = new XmlSchemaSet ();
SchemaSet. Add (null, XsdFilePath );
Settings. Schemas. Add (schemaSet );
Settings. ValidationType = ValidationType. Schema;
Settings. ValidationEventHandler + = new ValidationEventHandler (settings_ValidationEventHandler );
Settings. ValidationFlags = rule. ReportValidationWarnings | rule. ProcessInlineSchema | rule. AllowXmlAttributes | XmlSchemaValidationFlags. ProcessIdentityConstraints | rule. ProcessSchemaLocation;
Reader = XmlReader. Create (XmlFilepath, settings );
While (reader. Read ())
{
String xmlFile = reader. Value;
}
Reader. Close ();
Return isValid;
}
Catch (Exception ex)
{
Return false;
}
}
Private static void settings_ValidationEventHandler (object sender, ValidationEventArgs e)
{
IsValid = false;
}
}
}
2. Copy the compiled dll to C: \ Program Files \ Microsoft SQL Server \ 90 \ DTS \ PipelineComponents (SQL Server Installation Directory) and C: \ WINDOWS \ Microsoft. NET \ Framework \ v2.0.50727
3. Drag the DLL to the C: \ WINDOWS \ assemblyfolder, or use the command to install the dll(gacutil.exe/I myassembly. dll)
4. Drag a Script Task into SSIS, design the Script, and add the application dll