0

I've created two separate maps, each with the source from a CDM schema. I now have to create a third map, which should select the correct map to use, based on a subtype (field element in the header).

For now I have created a Joint.xslt file, which would contain the logic needed to select and use the correct map.

In my scenario: If the subtype is an 'Invoice', one specific map should be used. If the subtype is a 'ConsolidatedInvoice', another map should be used.

I thought about using an xsl:if element to make a test on the subtype:

<xsl:variable name="var:InvoiceSubType" select="string(Header/InvoiceType/text())" />
<xsl:if test="$var:InvoiceSubType = 'Invoice'">
...use invoice map
</xsl:if>

But I'm unsure about the correct way to go about this. When combining the XSLT from both maps, many variable names are duplicated for instance and cause errors in the joint XSLT.

To use the joint map I've selected it as a custom XSLT path in the map properties, while the source schema is the CDM.

Let me know if you need more information.

Leth
  • 1,033
  • 3
  • 15
  • 40

2 Answers2

1

Well...don't do that. ;) While choosing a template is supported in the XSL, it breaks the Mapper.

The correct BizTalk Way would be to use the Mapper for your Invoice and ConsolidatedInvoice Map, as you've already done, then make the decision about which to apply outside the Maps, such as in an Orchestration.

There is nothing wrong with adding or using an Orchestration for this. Don't worry about 'performance'.

Another option is Promoted Properties, a Send Port Filter and a Loopback Adapter.

Johns-305
  • 10,908
  • 12
  • 21
  • Thanks for your answer, but I am not allowed to use an orchestration for this per company policy. It must be done in XSLT. I am trying to make the descision in a newly created third map. – Leth Mar 12 '18 at 12:35
  • Find out what the policy is, then I can help you explain how it's, well, wrong. Really, there is **absolutely no legitimate reason** for this and means they really don't know how BizTalk works. – Johns-305 Mar 12 '18 at 12:39
0

You can use in Joint.xsl the xsl:include and xsl:import mechanism of XSLT to use both.

Then you can implement xsl:template to apply the map:

<xsl:template match="Header[contains(InvoiceType,'Invoice')]">
    ...
</xsl>

<xsl:template match="Header[contains(InvoiceType,'ConsolidatedInvoice')]">
    ...
</xsl>
felixmondelo
  • 1,324
  • 1
  • 10
  • 19
  • When I try and use the xsl:include element, I get a compile error saying "Resolving of external URIs was prohibited." – Leth Mar 12 '18 at 12:46
  • Yes, is a BizTalk error. Here are posible solutions https://blog.sandro-pereira.com/2010/04/26/biztalk-xslt-reuse-xslinclude-and-xslimport-resolving-of-external-uris-was-prohibited-error/ but my recomendation in your case is using templates and insert your different XSLT inside. – felixmondelo Mar 12 '18 at 14:55