如果您想使用变量作为输入源,那么您正在寻找VariableInput
EnumerationType
暴露在ForEachNodeListLoop
DirectOuterXPath
是您指定 OuterXPathStringSource 的地方,例如<DirectOuterXPath>/ROOT/*</DirectOuterXPath>
虽然不是您请求的准确表示(我全面使用变量),但将其分解<Files><File>Foo.txt</File><File>Bar.txt</File><File>Blee.txt</File></Files>
为 Foo.txt、Bar.txt 和 Blee.txt
<Biml xmlns="http://schemas.varigence.com/biml.xsd">
<Packages>
<Package Name="so_36759813">
<Variables>
<Variable DataType="String" Name="CurrentNode"></Variable>
<Variable DataType="String" Name="SourceXML"><![CDATA[<Files><File>Foo.txt</File><File>Bar.txt</File><File>Blee.txt</File></Files>]]></Variable>
<Variable DataType="String" Name="OuterXPath"><![CDATA[/Files/File]]></Variable>
<Variable DataType="String" Name="InnerXPath"><![CDATA[.]]></Variable>
</Variables>
<Tasks>
<ForEachNodeListLoop
Name="FENLL Shred XML"
EnumerationType="ElementCollection"
InnerElementType="NodeText"
>
<VariableInput VariableName="User.SourceXML" />
<VariableOuterXPath VariableName="User.OuterXPath" />
<VariableInnerXPath VariableName="User.InnerXPath" />
<VariableMappings>
<VariableMapping VariableName="User.CurrentNode" Name="0" />
</VariableMappings>
<Tasks>
<Script ProjectCoreName="ST_EchoBack" Name="SCR Echo Back">
<ScriptTaskProjectReference ScriptTaskProjectName="ST_EchoBack" />
</Script>
</Tasks>
</ForEachNodeListLoop>
</Tasks>
</Package>
</Packages>
<ScriptProjects>
<ScriptTaskProject ProjectCoreName="ST_EchoBack" Name="ST_EchoBack" VstaMajorVersion="0">
<ReadOnlyVariables>
<Variable Namespace="User" VariableName="CurrentNode" DataType="String" />
</ReadOnlyVariables>
<Files>
<File Path="ScriptMain.cs" BuildAction="Compile">using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
namespace ST_EchoBack
{
[Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
public void Main()
{
bool fireAgain = false;
string message = "{0}::{1} : {2}";
foreach (var item in Dts.Variables)
{
Dts.Events.FireInformation(0, "SCR Echo Back", string.Format(message, item.Namespace, item.Name, item.Value), string.Empty, 0, ref fireAgain);
}
Dts.TaskResult = (int)ScriptResults.Success;
}
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
}
} </File>
<File Path="Properties\AssemblyInfo.cs" BuildAction="Compile">
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly: AssemblyVersion("1.0.*")]
</File>
</Files>
<AssemblyReferences>
<AssemblyReference AssemblyPath="System" />
<AssemblyReference AssemblyPath="System.Data" />
<AssemblyReference AssemblyPath="System.Windows.Forms" />
<AssemblyReference AssemblyPath="System.Xml" />
<AssemblyReference AssemblyPath="Microsoft.SqlServer.ManagedDTS.dll" />
<AssemblyReference AssemblyPath="Microsoft.SqlServer.ScriptTask.dll" />
</AssemblyReferences>
</ScriptTaskProject>
</ScriptProjects>
</Biml>