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