Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Server

BizTalk 2010 Recipes : Document Mapping - Using XSLT Call Templates

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
3/29/2011 9:14:13 PM

1. Problem

You want to use the inline XSLT call template functionality within the Scripting functoid and understand the difference between inline XSLT and an inline XSLT call template.

2. Solution

Use the following steps to add an Inline XSLT Call Template functoid call to a map. The steps assume the schemas shown in the map in Figure 1 are being used.

Figure 1. Scripting/XSLT call template in a map

  1. Click the toolbox, and then click the Advanced Functoids tab. Drop a Scripting functoid onto the map surface.

  2. While the Scripting functoid is highlighted on the mapping grid, click the ellipsis to the right of the FunctoidScript item in the Properties window. In the Configure Scripting Functoid dialog box, on the Script Functoid Configuration tab, select Inline XSLT Call Template for Script Type, place the code shown in Listing 1 into the Inline Script Buffer text box, and then click OK.

    Example 1. Template Code
    <xsl:template name="CreateCompanySchema">
    <xsl:param name="ID" />
    <xsl:param name="Name" />
    <xsl:param name="Role" />
    <xsl:param name="Age" />
    <xsl:element name="Company">
    <xsl:element name="ID">Default Company ID</xsl:element>
    <xsl:element name="Name">Default Company Name</xsl:element>
    <xsl:element name="Employees">
    <xsl:element name="Employee">
    <xsl:element name="ID"><xsl:value-of select="$ID" /></xsl:element>
    <xsl:element name="Name"><xsl:value-of select="$Name" /></xsl:element>
    <xsl:element name="Role"><xsl:value-of select="$Role" /></xsl:element>
    <xsl:element name="Age"><xsl:value-of select="$Age" /></xsl:element>
    </xsl:element>
    </xsl:element>
    </xsl:element>
    </xsl:template>

  3. Create four input parameters by dropping each of the four nodes (ID, Name, Role, and Age) in the source document onto the Scripting functoid.

  4. Drop the output of the functoid onto the root node (Company) of the destination schema.

  5. Test the map. Assuming that the input document that is shown in Listing 2 is used as input, the document shown in Listing 3 will be output.

Example 2. Input Document for the Call Template Example
<ns0:Person xmlns:ns0="http://UsingCallTemplate.Person">
<ID>1</ID>
<Name>S. Brekalo</Name>
<Role>Acupuncturist</Role>
<Age>33</Age>
</ns0:Person>

Example 3. Output Document for the Call Template Example
<Company>
<ID>Default Company ID</ID>
<Name>Default Company Name</Name>
<Employees>
<Employee>
<ID>1</ID>
<Name>S. Brekalo</Name>
<Role>Acupuncturist</Role>
<Age>33</Age>

</Employee>
</Employees>
</Company>

3. How It Works

Calling an XSLT template is very similar to using inline XSLT. The main difference is the way in which values within the source document are passed and accessed. With inline XSLT, node values in the source document are accessed through XSL methods, whereas with called XSLT templates, the values are passed in as parameters.

In the case where code may need to be reused for multiple nodes, it may be more advantageous to create a template that can be reused without modifying the code. Templates will also allow for more traditional programming techniques, such as setting and updating variables dynamically within the template (for example, the ability to update a variable to store the number of loops that have occurred within a for-each loop).

Listing 4 demonstrates the use of inline XSLT rather than a called XSLT template. The output of Listing 4 will produce the same output as that of the XSLT template code shown earlier in Listing 1.

Example 1. Inline XSLT for Comparison
<xsl:element name="Company">
<xsl:element name="ID">Default Company ID</xsl:element>
<xsl:element name="Name">Default Company Name</xsl:element>
<xsl:element name="Employees">
<xsl:element name="Employee">
<xsl:element name="ID">
<xsl:value-of select="//*[local-name()='ID']" />
</xsl:element>
<xsl:element name="Name">
<xsl:value-of select="//*[local-name()='Name']" />
</xsl:element>
<xsl:element name="Role">
<xsl:value-of select="//*[local-name()='Role']" />
</xsl:element>
<xsl:element name="Age">
<xsl:value-of select="//*[local-name()='Age']" /></xsl:element>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:element>
Other -----------------
- Windows Server 2008 R2 Disks
- Windows Server 2008 R2 : File System Access Services and Technologies
- Windows Server 2008 R2 File System Overview/Technologies
- Reviewing the Column Choices in SharePoint 2010 (part 2) - Leveraging Validation Settings & Enforcing Unique Values in Columns
- Reviewing the Column Choices in SharePoint 2010 (part 1) - An Introduction and Practical Application of Calculated Columns
- SharePoint 2010 : Working with Metadata in a Word 2010 Document and Document Libraries
- Windows Server 2008 Server Core : Configuring Directory Services - Creating New Objects Using the DSAdd Utility (part 2)
- Windows Server 2008 Server Core : Configuring Directory Services - Creating New Objects Using the DSAdd Utility (part 1)
- Exchange Server 2010 : OWA (part 2) - OWA Virtual Directory Properties & Exchange Control Panel
- Exchange Server 2010 : OWA (part 1) - Configure File Access and WebReady Document Viewing & Segmentation Settings
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server