using System; using System.Xml; using System.Collections; namespace System.Xml.Schema { /// /// All Methods in this class should use XmlConvert. Some Methods are not present in the /// MS Implementation. We should provide them. /// internal class XmlSchemaUtil { private XmlSchemaUtil() {} public static void CompileID(string id, XmlSchemaObject xso, Hashtable idCollection, ValidationEventHandler h) { //check if the string conforms to http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#ID // 1. ID must be a NCName // 2. ID must be unique in the schema if(id == null) return; if(!CheckNCName(id)) xso.error(h,id+" is not a valid id attribute"); else if(idCollection.ContainsKey(id)) xso.error(h,"Duplicate id attribute "+id); else idCollection.Add(id,xso); } [MonoTODO] public static bool CheckAnyUri(string uri) { return true; } public static bool CheckToken(string token) { //check if the string conforms to http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#token return true; } public static bool CheckNormalizedString(string token) { return true; } public static bool CheckLanguage(string lang) { //check if the string conforms to http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#language return true; } public static bool CheckNCName(string name) { //check if the string conforms to http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#NCName try { XmlConvert.VerifyNCName(name); return true; } catch(Exception ex) { return false; } } public static bool CheckQName(XmlQualifiedName qname) { return true; } public static bool IsValidQName(string qname) { foreach(string part in qname.Split(new char[]{':'},2)) { if(!CheckNCName(part)) return false; } return true; } //FIXME: First remove all the multiple instances of whitespace and then return the strings. //The current method returns empty strings if there are two or more consecutive whitespaces. public static string[] SplitList(string list) { if(list == null || list == string.Empty) return new String[0]; string[] listarr = list.Split(new char[]{' ','\t','\n'}); int pos=0; int i = 0; for(i=0;i