1
votes

I'm dumping the schema from the table into a Tag Annotation for the package.

        <Annotation AnnotationType="Tag" Tag="PackageSchema">
            <#=Table.Schema#>
        </Annotation>

In the BIML for creating a master package I'm creating a sequence container for each schema and putting the packages in the corresponding container. At least that's what I'm asking it to do.

<Package Name="01-Master" ConstraintMode="Linear">
    <Tasks>
        <# foreach (var SchemaNode in RootNode.Schemas) { #>
            <Container Name="SEQC <#=SchemaNode.Name#>" ConstraintMode = "Parallel">
                <Tasks>
                    <# foreach (var Pckg in RootNode.Packages.Where(pkgschema => pkgschema.GetTag("PackageSchema")==SchemaNode.Name)) { #>
                        <ExecutePackage Name="EP <#=Pckg.Name#>" DelayValidation="true">
                            <ExternalProjectPackage Package="<#=Pckg.Name#>.dtsx">
                            </ExternalProjectPackage>
                        </ExecutePackage>
                    <# } #>
                </Tasks>
            </Container>
        <# } #>
    </Tasks>

When that runs I get a Master package with empty sequence containers. I took the where out of the package foreach, and it generates but puts all packages in every container. I put the GetTag in the name of the package just to make sure it picked it up correctly.

<# foreach (var Pckg in RootNode.Packages) { #>
    <ExecutePackage Name="EP <#=Pckg.Name#>" DelayValidation="true">
        <ExternalProjectPackage Package="<#=Pckg.Name#>.dtsx--<#=Pckg.GetTag("PackageSchema")#>--<#=SchemaNode.Name#>">

The tag was put into the package name but it is padded with lots of space around it.

<ExecutePackage Name="EP Application_TransactionTypes" DelayValidation="true">
    <ExternalProjectPackage Package="Application_TransactionTypes.dtsx--                 Application             --Application" />
</ExecutePackage>
<ExecutePackage Name="EP Purchasing_PurchaseOrderLines" DelayValidation="true">
    <ExternalProjectPackage Package="Purchasing_PurchaseOrderLines.dtsx--                 Purchasing             --Application" />
</ExecutePackage>

So I'm guessing that the padded value is why the RootNode.Packages.Where is not matching up to the schema name. I can't figure out how to trim off the spaces though. I tried putting a trim() in different places but the BIML engine complains about it. I was able to get rid of the leading spaces by taking the tabs out in front of the actual annotation in the BIML but it still pads the end.

Any ideas on why the tag is getting padded, or maybe I'm completely off base here and it's not the spaces around the tag.

2

2 Answers

2
votes

This is one of those "rock and a hard place" situations. In a much earlier version, we actually automatically trimmed annotation tag values to remove the leading and trailing whitespace. This caused issues for users in scenarios where they really needed that whitespace.

There are a few workarounds for this:

  1. As Bill pointed out, just delete the whitespace in your BimlScript.
  2. If you really want the whitespace in the BimlScript for readability, wrap the value in a CDATA block so that the newlines outside of the CDATA block are ignored. The syntax for this would be:
<Annotation AnnotationType="Tag" Tag="PackageSchema">
    <![CDATA[<#=table.Schema#>]]>
</Annotation>
  1. Alternatively, if you want to keep the whitespace for readability and don't like CDATA, you can trim the whitespace from the annotation value at the point of use. The syntax for this would be:

<#=Pckg.GetTag("PackageSchema").Trim()#>

1
votes

This is one of the ugly places where Biml/XML formatting is biting you in the backside

    <Annotation AnnotationType="Tag" Tag="PackageSchema">
        <#=Table.Schema#>
    </Annotation>

If you change that definition to the following, does everything "magically" work?

    <Annotation AnnotationType="Tag" Tag="PackageSchema"><#=Table.Schema#></Annotation>

I assume so because I ran into a similar issue with package parameters...