Validate XSL Against XML
here we shows, how to create a class library for validating a certain XSL file against an XML file. He examines the concept with the help of a series of steps with relevant source code and explanations.
the user is required to provide his or her own XSL file to generate his or her own HTML page based on an XML file we provide. In this situation, the need to verify that the XSL file will display appropriate results and not an empty page is required.
The general steps of this article will be:
1. Create a Class library project
2. Create three methods: 1 public and 2 private
3. Create a property which returns a Hash table containing the invalid Nodes in XSL file
4. Test the class library
Create a class library projectFirst, open Visual Studio 2005, click on file/New project and choose Visual C# Class library.
Name the project as XslValidator. Import Two namespaces.
1. System.Xml
2. System.Collections
we will write the necessary code for this class library to work. First, we will create 4 fields.
private XmlDocument xslDoc = null;
private XmlDocument xmlDoc = null;
private bool IsValidTag = false;
public Hashtable htTagValidation = new Hashtable();
here i declared 2 XML documents; one for the XSL file and the other for the XML file.