DTSXMLOperation 枚举
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
规定处理XML文档时所使用的操作。
public enum class DTSXMLOperation
public enum DTSXMLOperation
type DTSXMLOperation =
Public Enum DTSXMLOperation
- 继承
-
DTSXMLOperation
字段
| 名称 | 值 | 说明 |
|---|---|---|
| Validate | 0 | 验证XML文档是否符合文档类型定义(DTD)或XML模式定义(XSD)。 |
| XSLT | 1 | 对 XML 文档执行 XSL 转换。 |
| XPATH | 2 | 执行 XPath 查询和计算。 |
| Merge | 3 | 合并两个 XML 文档。 通过将源XML文档作为基础文档,它将第二个文档合并到基础文档中。 该操作可以在文档中指定合并位置。 |
| Diff | 4 | 比较两个 XML 文档。 通过以源 XML 文档为基础文档,Diff 操作将其与另一个 XML 文档进行比较,检测差异,然后将差异写入 XML DiffGram 文档。 此运算包含用来自定义比较的属性。 |
| Patch | 5 | 将 Diff 操作(DiffGram 文档)的输出应用到 XML 文档中,创建新的父文档,该文档可包含 DiffGram 文档的内容。 |
示例
以下代码示例展示了该枚举在任务创建后设置 OperationType 右侧的过程。
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Tasks.XMLTask;
namespace XMLTask_API
{
class Program
{
static void Main(string[] args)
{
// Set up the objects and tasks.
Package pkg = new Package();
Executable exec1 = pkg.Executables.Add("STOCK:XMLTask");
TaskHost th = exec1 as TaskHost;
// You can cast the InnerObject to the XmlTask, but it is advised
// that you work with tasks through the TaskHost and its Properties.
// XMLTask myTask = th.InnerObject as XMLTask;
// Create a variable and a FILE connection manager to books.xml.
Variable resultVar = pkg.Variables.Add("resultVariable", false, "", "Variable for the result");
ConnectionManager connMgr = pkg.Connections.Add("FILE");
connMgr.Name = "XMLConnectionManager";
// The file, Books.xml, is stored on the C:\ drive.
connMgr.ConnectionString = @"c:\books.xml";
// Set the XMLTask properties.
// The first property to set is the OperationType. Depending on the
// OperationType, different properties are valid.
// The operation type in this example is VALIDATE.
th.Properties["OperationType"].SetValue(th, DTSXMLOperation.Validate);
th.Properties["SourceType"].SetValue(th, DTSXMLSourceType.FileConnection);
th.Properties["Source"].SetValue(th, connMgr.Name);
th.Properties["OverwriteDestination"].SetValue(th, true);
th.Properties["SaveOperationResult"].SetValue(th, true);
th.Properties["DestinationType"].SetValue(th, DTSXMLSaveResultTo.Variable);
th.Properties["Destination"].SetValue(th, resultVar.Name);
th.Properties["SecondOperandType"].SetValue(th, DTSXMLSourceType.DirectInput);
th.Properties["SecondOperand"].SetValue(th, "<x></x>");
th.Properties["ValidationType"].SetValue(th, DTSXMLValidationType.DTD);
th.Properties["FailOnValidationFaile"].SetValue(th, true);
DTSExecResult valResults = pkg.Validate(pkg.Connections, pkg.Variables, null, null);
Console.WriteLine("RESULTS: {0}", valResults);
}
}
}
示例输出:
结果:成功
注解
该操作决定了该类中 XMLTask 哪些其他属性是有效的。 例如,如果所选操作是 XPATH,则使用属性 PutResultInOneNode 和 XPathOperation 。 当运算为 Validate时, FailOnValidationFail 则可用 标志。 这通常是代码中第一个属性设置,这样你就能立即看到它 XMLTask 正在执行什么任务。