1using System.Collections.Generic;
2using System.Text.RegularExpressions;
14 private readonly
string text;
37 int i = this.text.IndexOf(
' ');
40 Document.CreateProcessingInstruction(this.text,
string.Empty);
43 Match M = xmlDeclaration.Match(this.text);
45 if (M.Success && M.Index == 0 && M.Length ==
this.text.Length)
47 string Version = M.Groups[
"Version"].Value;
48 string Encoding = M.Groups[
"Encoding"].Value;
49 string Standalone = M.Groups[
"Standalone"].Value;
51 Document.AppendChild(Document.CreateXmlDeclaration(Version, Encoding, Standalone));
55 string Target = this.text.Substring(0, i);
56 string Data = this.text.Substring(i + 1).Trim();
58 Document.AppendChild(Document.CreateProcessingInstruction(Target, Data));
63 private static readonly Regex xmlDeclaration =
new Regex(
"\\s*xml\\s*(((version=['\"](?'Version'[^'\"]*)['\"])|(encoding=['\"](?'Encoding'[^'\"]*)['\"])|(standalone=['\"](?'Standalone'[^'\"]*)['\"]))\\s*)*", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.IgnoreCase);
73 int i = this.text.IndexOf(
' ');
77 return CheckAgainst is XmlProcessingInstruction PI && PI.Target == this.text &&
string.IsNullOrEmpty(PI.Data) ?
82 Match M = xmlDeclaration.Match(this.text);
84 if (M.Success && M.Index == 0 && M.Length ==
this.text.Length)
86 string Version = M.Groups[
"Version"].Value;
87 string Encoding = M.Groups[
"Encoding"].Value;
88 string Standalone = M.Groups[
"Standalone"].Value;
90 return CheckAgainst is XmlDeclaration D && D.Version == Version && D.Encoding == Encoding &&
95 string Target = this.text.Substring(0, i);
96 string Data = this.text.Substring(i + 1).Trim();
98 return CheckAgainst is XmlProcessingInstruction PI && PI.Target == Target && PI.Data == Data ?
111 return (CheckAgainst is XmlProcessingInstruction || CheckAgainst is XmlDeclaration);
Class managing a script expression.
int Length
Length of expression covered by node.
ScriptNode Parent
Parent node.
int Start
Start position in script expression.
Base class for all XML Script leaf nodes in a parsed script tree.
XML Script processing instruction node.
override bool IsApplicable(XmlNode CheckAgainst)
If the node is applicable in pattern matching against CheckAgainst .
XmlScriptProcessingInstruction(string Text, int Start, int Length, Expression Expression)
XML Script processing instruction node.
override PatternMatchResult PatternMatch(XmlNode CheckAgainst, Dictionary< string, IElement > AlreadyFound)
Performs a pattern match operation.
PatternMatchResult
Status result of a pattern matching operation.