Query Task
Queries XML inputs by using an XQuery program and outputs a file.
Parameters
The following table describes the parameters of the Query task.
Parameter | Description |
---|---|
CollectionsCollectionsCollections |
Optional ITaskItemITaskItemITaskItem[] parameter. Specifies the available collections. If the CollectionURI metadata is defined the item will be added to the specified collection. Otherwise the items will be set as the default collection. |
EnableStaticTypingEnableStaticTypingEnableStaticTyping |
Optional boolBooleanbool parameter.
Specifies whether the static typing feature is enabled.
If not specified, the default value is |
InputInputInput |
Optional ITaskItemITaskItemITaskItem parameter. Specifies the path of an XML input file to use as the context item. |
OptimizationLevelOptimizationLevelOptimizationLevel |
Optional intIntegerint parameter. Specifies the compilation optimization level. The default value is 3. If the value is less than zero or greater than 4, the default optimization level is used. |
OutputOutputOutput |
Required ITaskItemITaskItemITaskItem parameter. Specifies the principal output file from evaluating the query. |
OutputFilesOutputFilesOutputFiles |
Optional ITaskItemITaskItemITaskItem[] output parameter. Receives the output file created by evaluating the query. |
ParametersParametersParameters |
Optional stringStringString parameter. Specifies the values of stylesheet parameters. The value of this parameter should be set to a series of XML elements of the following form: <Parameter Name="..." [Namespace="..."] [Value="..."] [Select="..."] />
The |
ProcessXsiSchemaLocationProcessXsiSchemaLocationProcessXsiSchemaLocation |
Optional boolBooleanbool parameter.
Specifies whether |
XQueryXQueryXQuery |
Required ITaskItemITaskItemITaskItem parameter. Specifies the path of the XQuery program. |
SchemasSchemasSchemas |
Optional ITaskItemITaskItemITaskItem[] parameter. Specifies the set of XML Schema files used for validation. |
SerializationParametersSerializationParametersSerializationParameters |
Optional stringStringString parameter. Specifies the values of serialization parameters. The value of this parameter should be set to a series of XML elements of the following form: <Parameter Name="..." [Namespace="..."] Value="..." />
The |
StripWhitespaceStripWhitespaceStripWhitespace |
Optional boolBooleanbool parameter.
Specifies whether the whitespace will be stripped from source documents.
If not specified, the default value is |
ValidationValidationValidation |
Optional stringStringString parameter.
Specifies whether the source documents will be validated using a DTD ("dtd"), XML Schemas ("schema") or no validation will be performed ("none").
If not specified, the default value is |
Remarks
In addition to having the parameters that are listed in the table, this task inherits parameters from the TaskTaskTask class. For a list of these additional parameters and their descriptions, see Task Base Class.
Example
The following example queries input document document.xml to produce result output.htm using the XQuery program query.xq. Values are supplied for stylesheet parameters 'data' (in namespace 'http://www.example.org/) 'name', 'size' and 'date' are defined. The 'method' serialization parameter is set to XHTML. Input documents are validated using XML Schema against a set of files with extension 'xsd'. Two collections are made available with URIs 'urn:foo' and 'urn:bar'.
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$(MSBuildExtensionsPath32)\XmlPrime.Tasks\XmlPrime.Tasks.Tasks"/> <ItemGroup> <Query Include="query.xq" /> <ContextDocument Include="document.xml" /> <Schemas Include="*.xsd" /> <FooCollection Include="foo*.xml"> <CollectionURI>urn:foo</CollectionURI> </FooCollection> <BarCollection Include="bar*.xml"> <CollectionURI>urn:bar</CollectionURI> </BarCollection> </ItemGroup> <PropertyGroup> <SerializationParameters> <!-- set the serialization method to XHTML --> <Parameter Name="method" Value="xhtml" /> </SerializationParameters> <QueryParameters> <!-- bind parameter 'data' in namespace 'http://www.example.org/' to the document data.xml --> <Parameter Name="data" Namespace="http://www.example.org/" Select="doc('data.xml')" /> <!-- bind parameter 'name' to the string 'Jethro' --> <Parameter Name="name" Value="Jethro" /> <!-- bind parameter 'size' to the XPath expression '1024 * 768' --> <Parameter Name="size" Select="1024 * 768" /> <!-- bind parameter 'date' to the current date --> <Parameter Name="date" Select="current-date()" /> </QueryParameters> </PropertyGroup> <!-- test passing of serialization parameters --> <Target Name="transform"> <Query XQuery="@(Query)" Input="@(ContextDocument)" Collections="@(FooCollection);@(BarCollection)" Parameters="$(QueryParameters)" SerializationParameters="$(SerializationParameters)" Schemas="@(Schemas)" Validation="Schema" Output="output.htm"> <Output TaskParameter="OutputFiles" ItemName="TransformOutputFiles" /> </Query> <Message Text="Wrote output file @(TransformOutputFiles)" /> </Target> </Project>