none
XSLT 1.0 BizTalk Map for Multi part Message RRS feed

  • Question

  • Having a requirement where i have aggregated message and populate and loop for each message in output , below is what i have but need help where to start with.

    Input Message :

    <ns0:Root xmlns:ns0="http://schemas.microsoft.com/BizTalk/2003/aggschema">
    <InputMessagePart_0>
    <ns0:Root xmlns:ns0="http://TestXSLT1._0.Inpu1">
      <Header>
        <SeqNo>1</SeqNo>
        <FileName>Test</FileName>
      </Header>
      <Detail>
        <ItemName>Item1</ItemName>
        <Quantity>1</Quantity>
      </Detail>
        <Detail>
        <ItemName>Item2</ItemName>
        <Quantity>2</Quantity>
      </Detail>
    </ns0:Root>
    </InputMessagePart_0>
    <InputMessagePart_1>
    <ns0:Root xmlns:ns0="http://TestXSLT1._0.Input2">
      <FileName>Test</FileName>
      <Header>
        <DestinationLocation>Miami</DestinationLocation>
        <DestinationName>State</DestinationName>
        <Detail>
          <ItemName>Item1</ItemName>
          <Rate>100</Rate>
        </Detail>
        <Detail>
          <ItemName>Item2</ItemName>
          <Rate>200</Rate>
        </Detail>
      </Header>
    </ns0:Root>
    </InputMessagePart_1>
    </ns0:Root>

    Desired OutPut :

    <ns0:Root xmlns:ns0="http://TestXSLT1._0.Output">
      <SeqNo>1</SeqNo>
      <FileName>Test</FileName>
      <DestinationLocation>Miami</DestinationLocation>
      <DestinationName>State</DestinationName>
      <Detail>
        <ItemName>Item1</ItemName>
        <Quantity>1</Quantity>
      </Detail>
        <Detail>
        <ItemName>Item2</ItemName>
        <Quantity>2</Quantity>
      </Detail>
        <Detail>
        <ItemName>Item1</ItemName>
        <Rate>100</Rate>
      </Detail>
        <Detail>
        <ItemName>Item2</ItemName>
        <Rate>200</Rate>
      </Detail>
    </ns0:Root>

    XSLT Started: 

    <?xml version="1.0" encoding="UTF-16"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" exclude-result-prefixes="msxsl var s2 s0 s1" version="1.0" xmlns:ns0="http://TestXSLT1._0.Output" xmlns:s2="http://schemas.microsoft.com/BizTalk/2003/aggschema" xmlns:s0="http://TestXSLT1._0.Input2" xmlns:s1="http://TestXSLT1._0.Inpu1">
      <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
      <xsl:template match="/">
        <xsl:apply-templates select="/s2:Root" />
      </xsl:template>
      <xsl:template match="/s2:Root">
        <ns0:Root>
          <SeqNo>
            <xsl:value-of select="InputMessagePart_0/s1:Root/Header/SeqNo/text()" />
          </SeqNo>
          <FileName>
            <xsl:value-of select="InputMessagePart_0/s1:Root/Header/FileName/text()" />
          </FileName>
          <DestinationLocation>
            <xsl:value-of select="InputMessagePart_1/s0:Root/Header/DestinationLocation/text()" />
          </DestinationLocation>
          <DestinationName>
            <xsl:value-of select="InputMessagePart_1/s0:Root/Header/DestinationName/text()" />
          </DestinationName>
          <xsl:for-each select="InputMessagePart_0/s1:Root/Detail">
            <Detail>
              <ItemName>
                <xsl:value-of select="ItemName/text()" />
              </ItemName>
              <Quantity>
                <xsl:value-of select="Quantity/text()" />
              </Quantity>
              <Rate>
                <xsl:value-of select="../../../InputMessagePart_1/s0:Root/Header/Detail/Rate/text()" />
              </Rate>
            </Detail>
          </xsl:for-each>
        </ns0:Root>
      </xsl:template>
    </xsl:stylesheet>
    The XSLT I have made doesn't give me the desired output. This should be done in XSLT 1.0
    Appreciate for the help


    Sukra


    • Edited by sukra1234 Wednesday, January 22, 2020 5:57 PM
    Wednesday, January 22, 2020 5:56 PM

All replies