FileQueryConnection.Execute(XPathNavigator) Метод
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Переопределяет метод по умолчанию Execute() , чтобы разрешить указать другое расположение для вставки возвращаемых данных.
public:
abstract void Execute(System::Xml::XPath::XPathNavigator ^ output);
public abstract void Execute (System.Xml.XPath.XPathNavigator output);
override this.Execute : System.Xml.XPath.XPathNavigator -> unit
Public MustOverride Sub Execute (output As XPathNavigator)
Параметры
- output
- XPathNavigator
Объект , XPathNavigator указывающий XML-узел в основном или дополнительном источнике данных формы, в которую вставляются возвращаемые данные.
XPathNavigator, переданный в output
качестве параметра, также может указывать для вставки данных в любой XML-файл на локальном компьютере или в хранящийся XmlDocument в памяти.
Исключения
Не удалось завершить операцию запроса.
Параметр, передаваемый этому методу, является пустой ссылкой (Nothing в Visual Basic).
Этому методу передан недопустимый параметр. Например, неправильный тип или формат.
Примеры
В следующем примере метод FileQueryConnectionExecute(output
) класса используется для выполнения запроса к файлу "List.xml" и сохранения выходных данных в xmlDocument, созданном в памяти. Затем вывод, сохраненный в документе XmlDocument, отображается в поле QueryOutput формы.
public void ExecuteOutput_Clicked(object sender, ClickedEventArgs e)
{
// Create the XmlDocument to accept the query results.
XmlDocument outputFile = new XmlDocument();
outputFile.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\" ?><outputRoot></outputRoot>");
// Create XmlNamespaceManager for XmlDocument object. When
// creating a more complex document, use AddNamespace method
// to add a mapping from namespace prefix to namespace URL for
// each namespace to this object.
XmlNamespaceManager outputFileNamespaceManager =
new XmlNamespaceManager(outputFile.NameTable);
// Create an XPathNavigator positioned at the root of the
// XmlDocument output file created above.
XPathNavigator outputFileNavigator = outputFile.CreateNavigator();
XPathNavigator outputRootNavigator =
outputFileNavigator.SelectSingleNode("/outputRoot",
outputFileNamespaceManager);
// Query the XML file defined for the FileQueryConnection
// and log the results in the XmlDocument created above.
FileQueryConnection queryConnection =
(FileQueryConnection)(DataConnections["List.xml"]);
queryConnection.Execute(outputRootNavigator);
// Insert the results of the query from the XmlDocument in the
// QueryOutput field of the main data source of the form.
XPathNavigator mainNavigator = MainDataSource.CreateNavigator();
XPathNavigator queryOutputNavigator =
mainNavigator.SelectSingleNode("/my:myFields/my:QueryOutput",
NamespaceManager);
queryOutputNavigator.SetValue(outputRootNavigator.InnerXml);
}
Public Sub ExecuteOutput_Clicked(ByVal sender As Object , _
ByVal e As ClickedEventArgs)
{
' Create the XmlDocument to accept the query results.
Dim outputFile As XmlDocument = new XmlDocument()
outputFile.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\" ?><outputRoot></outputRoot>")
' Create XmlNamespaceManager for XmlDocument object. When
' creating a more complex document, use AddNamespace method
' to add a mapping from namespace prefix to namespace URL for
' each namespace to this object.
Dim outputFileNamespaceManager As XmlNamespaceManager = _
new XmlNamespaceManager(outputFile.NameTable)
' Create an XPathNavigator positioned at the root of the
' XmlDocument output file created above.
Dim outputFileNavigator As XPathNavigator = _
outputFile.CreateNavigator()
Dim outputRootNavigator As XPathNavigator =
outputFileNavigator.SelectSingleNode("/outputRoot",
outputFileNamespaceManager)
' Query the XML file defined for the FileQueryConnection
' and log the results in the XmlDocument created above.
Dim myQueryConnection As FileQueryConnection = _
DirectCast(DataConnections["List.xml"], FileQueryConnection)
myQueryConnection.Execute(outputRootNavigator);
' Insert the results of the query from the XmlDocument
' in the QueryOutput field of the main data source of the form.
Dim mainNavigator As XPathNavigator = _
MainDataSource.CreateNavigator()
Dim queryOutputNavigator As XPathNavigator =
mainNavigator.SelectSingleNode("/my:myFields/my:QueryOutput", _
NamespaceManager)
queryOutputNavigator.SetValue(outputRootNavigator.InnerXml)
End Sub
Комментарии
output
Установка для параметра пустой ссылки (Nothing в Visual Basic) имеет тот же эффект, что и использование метода Execute по умолчанию (наследуемого от DataConnection базового класса) для возврата данных с помощью декларативных параметров, определенных в шаблоне формы.
Доступ к этому элементу предоставляется только формам, работающим в том же домене, что и текущая открытая форма, а также формам с междоменными правами доступа.
Доступ к этому типу или элементу предоставляется только из кода, выполняющегося в формах, открытых в Microsoft InfoPath Filler или браузере.