1 dp.sh.Brushes.Xml = function()
\r
3 this.CssClass = 'dp-xml';
\r
6 dp.sh.Brushes.Xml.prototype = new dp.sh.Highlighter();
\r
7 dp.sh.Brushes.Xml.Aliases = ['xml', 'xhtml', 'xslt', 'html', 'xhtml'];
\r
9 dp.sh.Brushes.Xml.prototype.ProcessRegexList = function()
\r
11 function push(array, value)
\r
13 array[array.length] = value;
\r
16 /* If only there was a way to get index of a group within a match, the whole XML
\r
17 could be matched with the expression looking something like that:
\r
19 (<!\[CDATA\[\s*.*\s*\]\]>)
\r
20 | (<!--\s*.*\s*?-->)
\r
21 | (<)*(\w+)*\s*(\w+)\s*=\s*(".*?"|'.*?'|\w+)(/*>)*
\r
28 // Match CDATA in the following format <![ ... [ ... ]]>
\r
29 // <\!\[[\w\s]*?\[(.|\s)*?\]\]>
\r
30 this.GetMatches(new RegExp('<\\!\\[[\\w\\s]*?\\[(.|\\s)*?\\]\\]>', 'gm'), 'cdata');
\r
34 this.GetMatches(new RegExp('<!--\\s*.*\\s*?-->', 'gm'), 'comments');
\r
36 // Match attributes and their values
\r
37 // (\w+)\s*=\s*(".*?"|\'.*?\'|\w+)*
\r
38 regex = new RegExp('([\\w-\.]+)\\s*=\\s*(".*?"|\'.*?\'|\\w+)*', 'gm');
\r
39 while((match = regex.exec(this.code)) != null)
\r
41 push(this.matches, new dp.sh.Match(match[1], match.index, 'attribute'));
\r
43 // if xml is invalid and attribute has no property value, ignore it
\r
44 if(match[2] != undefined)
\r
46 push(this.matches, new dp.sh.Match(match[2], match.index + match[0].indexOf(match[2]), 'attribute-value'));
\r
50 // Match opening and closing tag brackets
\r
51 // </*\?*(?!\!)|/*\?*>
\r
52 this.GetMatches(new RegExp('</*\\?*(?!\\!)|/*\\?*>', 'gm'), 'tag');
\r
56 regex = new RegExp('</*\\?*\\s*([\\w-\.]+)', 'gm');
\r
57 while((match = regex.exec(this.code)) != null)
\r
59 push(this.matches, new dp.sh.Match(match[1], match.index + match[0].indexOf(match[1]), 'tag-name'));
\r