|
3 | 3 | namespace Schematron; |
4 | 4 |
|
5 | 5 | /// <summary /> |
6 | | -class TagExpressions |
| 6 | +partial class TagExpressions |
7 | 7 | { |
8 | 8 | /// <summary> |
9 | 9 | /// The compiled regular expression to replace the special <c>name</c> and <c>value</c> tags inside a message. |
10 | 10 | /// </summary> |
11 | 11 | /// <remarks> |
12 | 12 | /// Replaces each instance of <c>name</c> and <c>value</c>tags with the value in the current context element. |
13 | 13 | /// </remarks> |
14 | | - public static Regex NameValueOf; |
15 | | - |
16 | | - public static Regex Emph; |
17 | | - public static Regex Dir; |
18 | | - public static Regex Span; |
19 | | - public static Regex Para; |
20 | | - public static Regex Any; |
21 | | - public static Regex AllSchematron; |
22 | | - |
23 | | - /// <summary /> |
24 | | - static TagExpressions() |
25 | | - { |
26 | | - // The element declarations can contain the namespace if expanded in a loaded document. |
27 | | - NameValueOf = new Regex(@"<[^\s>]*\b(name|value-of)\b[^>]*/>", RegexOptions.Compiled); |
28 | | - Emph = new Regex(@"<[^\s>]*\bemph\b[^>]*>", RegexOptions.Compiled); |
29 | | - Dir = new Regex(@"<[^\s]*\bdir\b[^>]*>", RegexOptions.Compiled); |
30 | | - Span = new Regex(@"<[^\s]*\bspan\b[^>]*>", RegexOptions.Compiled); |
31 | | - Para = new Regex(@"<[^\s]*\bp\b[^>]*>", RegexOptions.Compiled); |
32 | | - Any = new Regex(@"<[^\s]*[^>]*>", RegexOptions.Compiled); |
33 | | - // Closing elements don't have an expanded xmlns so they will be matched too. |
34 | | - // TODO: improve this to avoid removing non-schematron closing elements. |
35 | | - var nsPattern = "(?:" + Regex.Escape(Schema.LegacyNamespace) + "|" + Regex.Escape(Schema.IsoNamespace) + ")"; |
36 | | - AllSchematron = new Regex(@"<.*\bxmlns\b[^\s]*" + nsPattern + "[^>]*>|</[^>]*>", RegexOptions.Compiled); |
37 | | - } |
38 | | - |
39 | | - TagExpressions() |
40 | | - { |
41 | | - } |
| 14 | + // The element declarations can contain the namespace if expanded in a loaded document. |
| 15 | + [GeneratedRegex(@"<[^\s>]*\b(name|value-of)\b[^>]*/>")] |
| 16 | + public static partial Regex NameValueOf(); |
| 17 | + |
| 18 | + [GeneratedRegex(@"<[^\s>]*\bemph\b[^>]*>")] |
| 19 | + public static partial Regex Emph(); |
| 20 | + |
| 21 | + [GeneratedRegex(@"<[^\s]*\bdir\b[^>]*>")] |
| 22 | + public static partial Regex Dir(); |
| 23 | + |
| 24 | + [GeneratedRegex(@"<[^\s]*\bspan\b[^>]*>")] |
| 25 | + public static partial Regex Span(); |
| 26 | + |
| 27 | + [GeneratedRegex(@"<[^\s]*\bp\b[^>]*>")] |
| 28 | + public static partial Regex Para(); |
| 29 | + |
| 30 | + [GeneratedRegex(@"<[^\s]*[^>]*>")] |
| 31 | + public static partial Regex Any(); |
| 32 | + |
| 33 | + // Closing elements don't have an expanded xmlns so they will be matched too. |
| 34 | + // TODO: improve this to avoid removing non-schematron closing elements. |
| 35 | + // Pattern derived from Schema.LegacyNamespace and Schema.IsoNamespace (with Regex.Escape applied). |
| 36 | + [GeneratedRegex(@"<.*\bxmlns\b[^\s]*(?:http://www\.ascc\.net/xml/schematron|http://purl\.oclc\.org/dsdl/schematron)[^>]*>|</[^>]*>")] |
| 37 | + public static partial Regex AllSchematron(); |
42 | 38 | } |
43 | 39 |
|
0 commit comments