2 // System.Xml.Query.XQueryCommand
\r
5 // Tim Coleman (tim@timcoleman.com)
\r
6 // Atsushi Enomoto (atsushi@ximian.com)
\r
8 // Copyright (C) Tim Coleman, 2003
\r
9 // Copyright (C) Novell Inc., 2004
\r
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 using System.Data.SqlXml;
\r
38 using System.Reflection;
\r
39 using System.Security.Policy;
\r
41 using System.Xml.XPath;
\r
43 namespace System.Xml.Query
\r
45 public class XQueryCommand
\r
47 // They are obtained via reflection
\r
48 static Type implType;
\r
49 static MethodInfo compileMethod;
\r
50 static MethodInfo executeMethod;
\r
52 static XQueryCommand ()
\r
54 implType = typeof (XPathNavigator).Assembly.GetType ("Mono.Xml.XPath2.XQueryCommandImpl");
\r
55 compileMethod = implType.GetMethod ("Compile");
\r
56 executeMethod = implType.GetMethod ("Execute");
\r
57 if (compileMethod == null)
\r
58 throw new InvalidOperationException ("Should not happen: XQueryCommandImpl.Compile() was not found.");
\r
59 if (executeMethod == null)
\r
60 throw new InvalidOperationException ("Should not happen: XQueryCommandImpl.Execute() was not found.");
\r
66 public XQueryCommand ()
\r
68 impl = Activator.CreateInstance (implType);
\r
71 #endregion // Constructor
\r
77 public event QueryEventHandler OnMessageEvent;
\r
85 [MonoTODO ("Null Evidence allowed?")]
\r
86 public void Compile (string query)
\r
88 Compile (query, null);
\r
91 public void Compile (string query, Evidence evidence)
\r
93 Compile (new StringReader (query), evidence);
\r
96 [MonoTODO ("Null Evidence allowed?")]
\r
97 public void Compile (TextReader query)
\r
99 Compile (query, null);
\r
103 public void Compile (TextReader query, Evidence evidence)
\r
105 compileMethod.Invoke (impl, new object [] {query, evidence, this});
\r
110 [MonoTODO ("Null args allowed?")]
\r
111 public void Execute (
\r
112 IXPathNavigable contextDocument,
\r
115 Execute (contextDocument, null, null, results);
\r
118 [MonoTODO ("Output StartDocument?")]
\r
119 public void Execute (
\r
120 XmlResolver dataSources,
\r
121 TextWriter results)
\r
123 XmlTextWriter w = new XmlTextWriter (results);
\r
124 Execute (dataSources, null, w);
\r
127 [MonoTODO ("Null args allowed?")]
\r
128 public void Execute (
\r
129 XmlResolver dataSources,
\r
132 Execute (new XPathDocument (), dataSources, null, results);
\r
135 [MonoTODO ("Null args allowed?")]
\r
136 public void Execute (
\r
137 IXPathNavigable contextDocument,
\r
138 XmlArgumentList args,
\r
141 Execute (contextDocument, null, args, results);
\r
144 [MonoTODO ("Null args allowed?")]
\r
145 public void Execute (
\r
146 IXPathNavigable contextDocument,
\r
147 XmlResolver resolver,
\r
150 Execute (contextDocument, resolver, null, results);
\r
153 [MonoTODO("Indentation?;write StartDocument?;Null args allowed?")]
\r
154 public void Execute (
\r
155 string contextDocumentUri,
\r
156 XmlResolver dataSources,
\r
159 Execute (contextDocumentUri, dataSources, null, results);
\r
162 [MonoTODO("Indentation?;write StartDocument?;Null args allowed?")]
\r
163 public void Execute (
\r
164 string contextDocumentUri,
\r
165 XmlResolver dataSources,
\r
166 TextWriter results)
\r
168 Execute (contextDocumentUri, dataSources, null, results);
\r
172 public void Execute (
\r
173 string contextDocumentUri,
\r
174 XmlResolver dataSources,
\r
177 Execute (new XPathDocument (XmlReader.Create (contextDocumentUri)), dataSources, results);
\r
181 public void Execute (
\r
182 XmlResolver dataSources,
\r
183 XmlArgumentList args,
\r
186 Execute ((XPathNavigator) null, dataSources, args, results);
\r
190 public void Execute (
\r
191 IXPathNavigable contextDocument,
\r
192 XmlResolver dataSources,
\r
193 XmlArgumentList args,
\r
196 Execute (contextDocument != null ? contextDocument.CreateNavigator () : null, dataSources, args, results);
\r
200 public void Execute (
\r
201 string contextDocumentUri,
\r
202 XmlResolver dataSources,
\r
203 XmlArgumentList args,
\r
206 Execute (new XPathDocument (XmlReader.Create (contextDocumentUri)), dataSources, args, XmlWriter.Create (results));
\r
210 public void Execute (
\r
211 string contextDocumentUri,
\r
212 XmlResolver dataSources,
\r
213 XmlArgumentList args,
\r
214 TextWriter results)
\r
216 Execute (new XPathDocument (XmlReader.Create (contextDocumentUri)), dataSources, args, XmlWriter.Create (results));
\r
220 public void Execute (
\r
221 string contextDocumentUri,
\r
222 XmlResolver dataSources,
\r
223 XmlArgumentList args,
\r
226 Execute (new XPathDocument (XmlReader.Create (contextDocumentUri)), dataSources, args, results);
\r
229 private void Execute (XPathNavigator context, XmlResolver ds, XmlArgumentList args, XmlWriter output)
\r
231 executeMethod.Invoke (impl, new object [] {context, ds, args, output});
\r
234 #endregion // Methods
\r