Uncategorized

Gmail Forgotten attachment detector

Do u have the habit of sending an email saying "please see the attachment" and forget to attach the file? Gmail Labs has the solution, After logging to Gmail -> Settings-> Labs. Go down and find the Lab "Forgotten Attachment Detector" .    Google says "Prevents…

Google's Own English to Malayalam Transliteration Tool

Today I wanted to write some post in blogger.com . So I searched for a good english to malayalam translation tool and stumbled upon Google Indic Transliteration . Its awesome and the best Transliteration tool I have ever used. Check this out here: http://www.google.com/transliterate/indic/Malayalam# .  Tip:…

Microsoft Virtual Techdays Nov 24,25 and 26

Microsoft Virtual Techdays are back. its a great opportunity lo learn new Microsoft Innovations . I am looking forward to Silverlight 2 session on Nov24th 10:30 to 3 PM IST and Building Data-Driven Applications with Silverlight 2 and the new Silverlight Control Pack on 25th (2:15…

New Look Gmail – Better Gmail 2

Today I installed Firefox 3 on my machine and was browisng for some cool Add-ons and found this amazing add on “Better Gmail 2″ (  https://addons.mozilla.org/en-US/firefox/addon/6076 ).  it has got 174,670 weekly downloads and 1,086,159 total downloads. It adds useful extra features and skins to Gmail,…

SQL query for finding the 2nd highest salary from an employee table.

This is a very simple SQL query for finding the 2nd highest salary from an employee table. A very common question in .NET interviews. The query is pretty self explanatory. select  top(1)[Name],Salary from Employeewhere  salary  not in (select top (1) salary from employee order by salary desc) ORDER BY SALARY DESC  – Change the top parameter to (nth highest salary – 1)  

Validating an XML File using XSD in .NET .20

Recently I had an issue with .NET 2.0 XML validation. Lets see whats the difference in .NET 2.0 from .NET 1.1  Below given is the.NET 1.1 code for validating an XML File using an XSD File. .NET 1.1 Code //.NET1.1 code////// Methode to validate XML File////// This method expects input XML as string///Path to schema file/// true if xml is validated else falseprivate bool ValidateXmlUsingXsd(string XmlData,String SchemaPath){XmlValidatingReader v = new XmlValidatingReader(XmlData, XmlNodeType.Document, null);v.ValidationType = ValidationType.Schema;v.ValidationEventHandler +=new ValidationEventHandler(MyValidationEventHandler);   while (v.Read()){// Can add code here to process the content.}v.Close(); return isValid; } /// public static void MyValidationEventHandler(object sender,ValidationEventArgs args){//these two variables should be initialized as class level variablesisValid = false;errorMessage = “Validation eventn” + args.Message;////// Method to get XML in a string from an XML file////// } ///private string GetStringFromXML(string fileName){StreamReader rd = new StreamReader(fileName);string str = rd.ReadToEnd();rd.Close();return str;} Calling the method :bool valid = ValidateXmlUsingXsd(str, txtXSD.Text);   There are some changes in the .NET 2.0 code for XML Validation .XmlValidatingReader is marked as obsolete. Need to use XMLReader.Create() using XmlReaderSettngs instead There are some behavioral changes between validation using the XmlReaderSettings and XmlSchemaSet classes and validation using the XmlValidatingReader class. The XmlReaderSettings and XmlSchemaSet classes do not support XML-Data Reduced (XDR) schema validation. The most important difference I found out is that to do XML data validation using a schema, settings.ValidationFlags = XmlSchemaValidationFlags.ReportValidationWarnings;Flag must be enabled. Otherwise the Schema check error will not be displayed. //.NET2.0 codeprivate bool ValidateXmlUsingXsd2(string XmlData,String SchemaPath){XmlReaderSettings settings = new XmlReaderSettings();settings.ValidationType = ValidationType.Schema;settings.Schemas.Add(null, SchemaPath);settings.ValidationFlags = XmlSchemaValidationFlags.ReportValidationWarnings;settings.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack);More about XmlSchemaValidationFlags Enumeration StringReader xmlStream = new StringReader(XmlData);XmlReader reader = XmlReader.Create(xmlStream, settings);while (reader.Read()) ; return isValid;} private static void ValidationCallBack(object sender, ValidationEventArgs e){isValid = false;errorMessage = “Validation Error: ” + e.Message;}   Member nameDescriptionAllowXmlAttributesAllow xml:* attributes even if they are not defined in the schema. The attributes will be validated based on their data type.NoneDo not process identity constraints, inline schemas, schema location hints, or report schema validation warnings.ProcessIdentityConstraintsProcess identity constraints (xs:ID, xs:IDREF, xs:key, xs:keyref, xs:unique) encountered during validation.ProcessInlineSchemaProcess inline schemas encountered during validation.ProcessSchemaLocationProcess schema location hints (xsi:schemaLocation, xsi:noNamespaceSchemaLocation) encountered during validation.ReportValidationWarningsReport schema validation warnings encountered during validation.In a nutshell, Always set settings.ValidationFlags = XmlSchemaValidationFlags.ReportValidationWarnings; when a schema validation is required for the XML in .NET 2.0

1 2 3