/*
 * JsMin
 * Javascript Compressor
 * http://www.crockford.com/
 * http://www.smallsharptools.com/
*/

dp.sh.Brushes.Xml=function()
{
    this.CssClass='dp-xml';
}

dp.sh.Brushes.Xml.prototype=new dp.sh.Highlighter();
dp.sh.Brushes.Xml.Aliases=['xml','xhtml','xslt','html','xhtml'];
dp.sh.Brushes.Xml.prototype.ProcessRegexList=function()
{
    function push(array,value)
    {
        array[array.length]=value;
    }
    
    var index=0;
    var match=null;
    var regex=null;
    this.GetMatches(new RegExp('(\&lt;|<)\\!\\[[\\w\\s]*?\\[(.|\\s)*?\\]\\](\&gt;|>)','gm'),'cdataXML');
    this.GetMatches(new RegExp('(\&lt;|<)!--\\s*.*?\\s*--(\&gt;|>)','gm'),'comments');
    regex=new RegExp('([:\\w-\.]+)\\s*=\\s*(".*?"|\'.*?\'|\\w+)*|(\\w+)','gm');
    
    var keywords='abstract as base bool break byte case catch char checked class const '+'continue decimal default delegate do double else enum event explicit '+'extern false finally fixed float for foreach get goto if implicit in int '+'interface internal is lock long namespace new null object operator out '+'override params private protected public readonly ref return sbyte sealed set '+'short sizeof stackalloc static string struct switch this throw true try '+'typeof uint ulong unchecked unsafe ushort using virtual void while';
    var classkeywords='SqlConnection SqlCommand SqlDataReader EventArgs ConfigurationManager CredentialCache';
                
    while((match=regex.exec(this.code))!=null)
    {
        if(match[1]==null)
        {
            continue;
        }
        push(this.matches,new dp.sh.Match(match[1],match.index,'attributeXML'));
        
        if(match[2]!=undefined)
        {        
            if (match[2].substring(0, 7) == "'&lt;%#" || match[2].substring(0, 7) == "'&lt;%=")
            {     
                var x = match[2].length - 6;
                var y = match[2].length - 1;                
                push(this.matches,new dp.sh.Match(match[2].substring(1,6),match.index+match[0].indexOf(match[2].substring(1,6)),'aspTag'));
                
                var cscharpFunction = match[2].substring(7,x);        
                
                var cssharpMatch = cscharpFunction.match(dp.sh.RegexLib.SingleQuotedString);                                                                                                                                                                                                                                       
                if (cssharpMatch != null)
                {
                    for( var i = 0; i < cssharpMatch.length; ++i )
                    {
                        push(this.matches,new dp.sh.Match(cssharpMatch[i],match.index+match[0].indexOf(cssharpMatch[i]),'stringCSharp'));
                    }
                }
                
                cssharpMatch = cscharpFunction.match(dp.sh.RegexLib.DoubleQuotedString);                                                                                                                                                                                                                                       
                if (cssharpMatch != null)
                {
                    for( var i = 0; i < cssharpMatch.length; ++i )
                    {
                        push(this.matches,new dp.sh.Match(cssharpMatch[i],match.index+match[0].indexOf(cssharpMatch[i]),'stringCSharp'));
                    }
                }
                             
                cssharpMatch = cscharpFunction.match(this.GetKeywords(keywords));                                                                                                                                                                                                                                       
                if (cssharpMatch != null)
                {
                    for( var i = 0; i < cssharpMatch.length; ++i )
                    {
                        push(this.matches,new dp.sh.Match(cssharpMatch[i],match.index+match[0].indexOf(cssharpMatch[i]),'keywordCSharp'));
                    }
                }
                
                cssharpMatch = cscharpFunction.match(this.GetKeywords(classkeywords));                                                                                                                                                                                                                                       
                if (cssharpMatch != null)
                {
                    for( var i = 0; i < cssharpMatch.length; ++i )
                    {
                        push(this.matches,new dp.sh.Match(cssharpMatch[i],match.index+match[0].indexOf(cssharpMatch[i]),'classkeywordCSharp'));
                    }
                }
                                                
                push(this.matches,new dp.sh.Match(match[2].substring(x,y),match.index+match[0].indexOf(match[2].substring(x,y)),'aspTag'));                
            }
            else
            {
                push(this.matches,new dp.sh.Match(match[2],match.index+match[0].indexOf(match[2]),'attribute-valueXML'));
            }
        }
    }
    
    this.GetMatches(new RegExp('(\&lt;|<)/*\\?*(?!\\!)|/*\\?*(\&gt;|>)','gm'),'tagXML');
    regex=new RegExp('(?:\&lt;|<)/*\\?*\\s*([:\\w-\.]+)','gm');
    
    while((match=regex.exec(this.code))!=null)
    {
            push(this.matches,new dp.sh.Match(match[1],match.index+match[0].indexOf(match[1]),'tag-nameXML'));
       
    }
}

