@@ -5,6 +5,7 @@ namespace Schematron;
55/// <summary />
66partial class TagExpressions
77{
8+ #if NET8_0_OR_GREATER
89 /// <summary>
910 /// The compiled regular expression to replace the special <c>name</c> and <c>value</c> tags inside a message.
1011 /// </summary>
@@ -32,8 +33,42 @@ partial class TagExpressions
3233
3334 // Closing elements don't have an expanded xmlns so they will be matched too.
3435 // TODO: improve this to avoid removing non-schematron closing elements.
35- // Pattern derived from Schema.LegacyNamespace and Schema.IsoNamespace (with Regex.Escape applied).
36+ // Pattern derived from Regex.Escape(Schema.LegacyNamespace) and Regex.Escape(Schema.IsoNamespace).
37+ // If those constants ever change, update the hardcoded escaped values here to match.
3638 [ GeneratedRegex ( @"<.*\bxmlns\b[^\s]*(?:http://www\.ascc\.net/xml/schematron|http://purl\.oclc\.org/dsdl/schematron)[^>]*>|</[^>]*>" ) ]
3739 public static partial Regex AllSchematron ( ) ;
40+ #else
41+ /// <summary>
42+ /// The compiled regular expression to replace the special <c>name</c> and <c>value</c> tags inside a message.
43+ /// </summary>
44+ /// <remarks>
45+ /// Replaces each instance of <c>name</c> and <c>value</c>tags with the value in the current context element.
46+ /// </remarks>
47+ // The element declarations can contain the namespace if expanded in a loaded document.
48+ static readonly Regex _nameValueOf = new Regex ( @"<[^\s>]*\b(name|value-of)\b[^>]*/>" , RegexOptions . Compiled ) ;
49+ public static Regex NameValueOf ( ) => _nameValueOf ;
50+
51+ static readonly Regex _emph = new Regex ( @"<[^\s>]*\bemph\b[^>]*>" , RegexOptions . Compiled ) ;
52+ public static Regex Emph ( ) => _emph ;
53+
54+ static readonly Regex _dir = new Regex ( @"<[^\s]*\bdir\b[^>]*>" , RegexOptions . Compiled ) ;
55+ public static Regex Dir ( ) => _dir ;
56+
57+ static readonly Regex _span = new Regex ( @"<[^\s]*\bspan\b[^>]*>" , RegexOptions . Compiled ) ;
58+ public static Regex Span ( ) => _span ;
59+
60+ static readonly Regex _para = new Regex ( @"<[^\s]*\bp\b[^>]*>" , RegexOptions . Compiled ) ;
61+ public static Regex Para ( ) => _para ;
62+
63+ static readonly Regex _any = new Regex ( @"<[^\s]*[^>]*>" , RegexOptions . Compiled ) ;
64+ public static Regex Any ( ) => _any ;
65+
66+ // Closing elements don't have an expanded xmlns so they will be matched too.
67+ // TODO: improve this to avoid removing non-schematron closing elements.
68+ static readonly Regex _allSchematron = new Regex (
69+ @"<.*\bxmlns\b[^\s]*(?:" + Regex . Escape ( Schema . LegacyNamespace ) + "|" + Regex . Escape ( Schema . IsoNamespace ) + @")[^>]*>|</[^>]*>" ,
70+ RegexOptions . Compiled ) ;
71+ public static Regex AllSchematron ( ) => _allSchematron ;
72+ #endif
3873}
3974
0 commit comments