#
# basic Syntaxhighliting for xml documents
# based on HTML Mode

sub XML_Base {
    InsertString '<?xml version="1.0" encoding="ISO-8859-1"?>";';
    LineNew; MoveLineStart;
}


colorize XML {
    SyntaxParser = 'SIMPLE';

    color {
        { 'Normal',     'Editor_Keywords' },
        { 'Command',    'Editor_Default' },
        { 'Comment',    'Lang_Comment' },
        { 'String',     'Lang_String' },
        { 'Symbol',     'Markup_Symbol' },
        { 'Tag',        'Markup_Tag' },
        { 'Special',    'Markup_Special' },
    };

    keyword "Editor_Keywords" {
        "DOCTYPE", "PUBLIC",
    };

    h_state 0 { 'Normal' }
    h_trans { 5, '<', '<!--', 'Comment' }
    h_trans { 1, '<', '<', 'Command' }
    h_trans { 2, '<', '&', 'Symbol' }

    h_state 1 { 'Command' }
    h_trans { 0, '>', '>', 'Command' }
    h_trans { 3, '<', '\'', 'String' }
    h_trans { 4, '<', '"', 'String' }
    h_wtype { -1, -1, -1, 'i', 'a-zA-Z0-9_\-' }

    h_state 2 { 'Symbol' }
    h_trans { 0, '>', ';', 'Symbol' }
    h_trans { 0, '-S', '#a-zA-Z0-9', 'Symbol' }

    h_state 3 { 'String' }
    h_trans { 1, '>', '\'', 'String' }

    h_state 4 { 'String' }
    h_trans { 1, '>', '"', 'String' }

    h_state 5 { 'Comment' }
    h_trans { 6, '>', '--', 'Comment' }

    h_state 6 { 'Special' }
    h_trans { 5, '>', '--', 'Comment' }
    h_trans { 0, '>', '>', 'Comment' }
}

mode XML: PLAIN {
   FileNameRx          = /\.\c{XML}|{XSL}$/;
   FirstLineRx         = /\<\?xml/;
   HilitOn             = 1;
   Colorizer           = "XML";
   MultiLineHilit      = 1;
   AutoHilitParen      = 1;
   AutoIndent          = 1;
   IndentMode          = 'PLAIN';
   TabSize             = 2;

   # limit XML-Depth in function-view
   #RoutineRegexp       = /^ {0,6}\<.+\>/;
   RoutineRegexp       = /^ *\<[^\/!].*[^\/]\>/;

   SaveFolds           = 2;      # save fold info at end of line
   CommentStart        = " <!--";
   CommentEnd          = "-->";
}

eventmap XML {
   abbrev '_xml' {
      KillWordPrev; InsertString '<?xml version="1.0" encoding="ISO-8859-1"?>'; LineNew; MoveLineStart;
      Fail;
   }
}
