多部分消息 (BizTalk) 的 XSLT 1.0 帮助

XSLT 1.0 Help for Multi part Message (BizTalk)

要求我聚合消息并为输出中的每条消息填充和循环,下面是我所拥有的但需要帮助从哪里开始。

输入消息:

<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>

期望输出:

<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 我已经开始了:

<?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>

我制作的 XSLT 没有给我想要的输出。 这应该在 XSLT 1.0
中完成 感谢您的帮助 ~

您显示的输出可以使用:

XSLT 1.0

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>

<xsl:template match="/*">
    <ns0:Root xmlns:ns0="http://TestXSLT1._0.Output">
        <!-- header -->
        <SeqNo>
            <xsl:value-of select="InputMessagePart_0/*/Header/SeqNo" />
        </SeqNo>
        <FileName>
            <xsl:value-of select="InputMessagePart_0/*/Header/FileName" />
        </FileName>
        <DestinationLocation>
            <xsl:value-of select="InputMessagePart_1/*/Header/DestinationLocation" />
        </DestinationLocation>
        <DestinationName>
            <xsl:value-of select="InputMessagePart_1/*/Header/DestinationName" />
        </DestinationName>
        <!-- details part 0 -->     
        <xsl:for-each select="InputMessagePart_0/*/Detail">
            <Detail>
                <ItemName>
                    <xsl:value-of select="ItemName" />
                </ItemName>
                <Quantity>
                    <xsl:value-of select="Quantity" />
                </Quantity>
            </Detail>
        </xsl:for-each>
        <!-- details part 1 -->
        <xsl:for-each select="InputMessagePart_1/*/Header/Detail">
            <Detail>
                <ItemName>
                    <xsl:value-of select="ItemName" />
                </ItemName>
                <Rate>
                    <xsl:value-of select="Rate" />
                </Rate>
            </Detail>
        </xsl:for-each>
    </ns0:Root>
</xsl:template>

</xsl:stylesheet>